winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2015
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
567 discussions
Start a n
N
ew thread
Huw Davies : comctl32: All negative entries in the toolbar save state are special cases.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 96a6184c305bad35737dd57cecbf1dc9c6e96753 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=96a6184c305bad35737dd57ce…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:56 2015 +0100 comctl32: All negative entries in the toolbar save state are special cases. --- dlls/comctl32/tests/toolbar.c | 52 +++++++++++++++++++++++++++++++++++-------- dlls/comctl32/toolbar.c | 13 +++++------ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 9535947..022d727 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -150,7 +150,7 @@ static LRESULT parent_wnd_notify(LPARAM lParam) NMTBSAVE *save = (NMTBSAVE *)lParam; if (save->iItem == -1) { - save->cbData = save->cbData * 2 + sizeof(DWORD); + save->cbData = save->cbData * 2 + 11 * sizeof(DWORD); save->pData = HeapAlloc( GetProcessHeap(), 0, save->cbData ); save->pData[0] = 0xcafe; save->pCurrent = save->pData + 1; @@ -160,6 +160,22 @@ static LRESULT parent_wnd_notify(LPARAM lParam) save->pCurrent[0] = 0xcafe0000 + save->iItem; save->pCurrent++; } + + /* Add on 5 more pseudo buttons. */ + if (save->iItem == save->cButtons - 1) + { + save->pCurrent[0] = 0xffffffff; + save->pCurrent[1] = 0xcafe0007; + save->pCurrent[2] = 0xfffffffe; + save->pCurrent[3] = 0xcafe0008; + save->pCurrent[4] = 0x80000000; + save->pCurrent[5] = 0xcafe0009; + save->pCurrent[6] = 0x7fffffff; + save->pCurrent[7] = 0xcafe000a; + save->pCurrent[8] = 0x100; + save->pCurrent[9] = 0xcafe000b; + } + /* Return value is ignored */ return 1; } @@ -169,21 +185,37 @@ static LRESULT parent_wnd_notify(LPARAM lParam) if (restore->iItem == -1) { - ok( restore->cButtons == 15, "got %d\n", restore->cButtons ); + ok( restore->cButtons == 25, "got %d\n", restore->cButtons ); ok( *restore->pCurrent == 0xcafe, "got %08x\n", *restore->pCurrent ); /* Skip the last one */ - restore->cButtons = 6; + restore->cButtons = 11; restore->pCurrent++; /* BytesPerRecord is ignored */ restore->cbBytesPerRecord = 10; } else { - ok( *restore->pCurrent == 0xcafe0000 + restore->iItem, "got %08x\n", *restore->pCurrent ); ok( restore->tbButton.iBitmap == -1, "got %08x\n", restore->tbButton.iBitmap ); - ok( restore->tbButton.idCommand == restore->iItem * 2 + 1, "got %08x\n", restore->tbButton.idCommand ); - ok( restore->tbButton.fsState == 0, "got %02x\n", restore->tbButton.fsState ); - ok( restore->tbButton.fsStyle == 0, "got %02x\n", restore->tbButton.fsStyle ); + ok( *restore->pCurrent == 0xcafe0000 + restore->iItem, "got %08x\n", *restore->pCurrent ); + if (restore->iItem < 7 || restore->iItem == 10) + { + if (restore->iItem < 7) + ok( restore->tbButton.idCommand == restore->iItem * 2 + 1, "%d: got %08x\n", restore->iItem, restore->tbButton.idCommand ); + else + ok( restore->tbButton.idCommand == 0x7fffffff, "%d: got %08x\n", restore->iItem, restore->tbButton.idCommand ); + ok( restore->tbButton.fsState == 0, "%d: got %02x\n", restore->iItem, restore->tbButton.fsState ); + ok( restore->tbButton.fsStyle == 0, "%d: got %02x\n", restore->iItem, restore->tbButton.fsStyle ); + } + else + { + ok( restore->tbButton.idCommand == 0, "%d: got %08x\n", restore->iItem, restore->tbButton.idCommand ); + if (restore->iItem == 7) + ok( restore->tbButton.fsState == 0, "%d: got %02x\n", restore->iItem, restore->tbButton.fsState ); + else + ok( restore->tbButton.fsState == TBSTATE_HIDDEN, "%d: got %02x\n", restore->iItem, restore->tbButton.fsState ); + ok( restore->tbButton.fsStyle == BTNS_SEP, "%d: got %02x\n", restore->iItem, restore->tbButton.fsStyle ); + } + ok( restore->tbButton.dwData == 0, "got %08lx\n", restore->tbButton.dwData ); ok( restore->tbButton.iString == 0, "got %08lx\n", restore->tbButton.iString ); @@ -2176,7 +2208,9 @@ static void test_save(void) {0, 13, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, -1} }; static const DWORD expect[] = {0xcafe, 1, 0xcafe0000, 3, 0xcafe0001, 5, 0xcafe0002, 7, 0xcafe0003, - 9, 0xcafe0004, 11, 0xcafe0005, 13, 0xcafe0006 }; + 9, 0xcafe0004, 11, 0xcafe0005, 13, 0xcafe0006, 0xffffffff, 0xcafe0007, + 0xfffffffe, 0xcafe0008, 0x80000000, 0xcafe0009, 0x7fffffff, 0xcafe000a, + 0x100, 0xcafe000b}; params.hkr = HKEY_CURRENT_USER; params.pszSubKey = subkey; @@ -2206,7 +2240,7 @@ static void test_save(void) res = SendMessageW( wnd, TB_SAVERESTOREW, FALSE, (LPARAM)¶ms ); ok( res, "restoring failed\n" ); res = SendMessageW( wnd, TB_BUTTONCOUNT, 0, 0 ); - ok( res == 6, "got %d\n", res ); + ok( res == 11, "got %d\n", res ); DestroyWindow( wnd ); RegOpenKeyW( HKEY_CURRENT_USER, subkey, &key ); diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 9c3707b..e1d2cdb 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4195,18 +4195,15 @@ TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, const TBSAVEPARAMSW *lpSave) nmtbr.tbButton.iBitmap = -1; nmtbr.tbButton.fsState = 0; nmtbr.tbButton.fsStyle = 0; - nmtbr.tbButton.idCommand = 0; - if (*nmtbr.pCurrent == (DWORD)-1) + + if (*nmtbr.pCurrent & 0x80000000) { /* separator */ + nmtbr.tbButton.idCommand = 0; nmtbr.tbButton.fsStyle = TBSTYLE_SEP; - /* when inserting separators, iBitmap controls its size. - 0 sets default size (width) */ - nmtbr.tbButton.iBitmap = 0; + if (*nmtbr.pCurrent != (DWORD)-1) + nmtbr.tbButton.fsState = TBSTATE_HIDDEN; } - else if (*nmtbr.pCurrent == (DWORD)-2) - /* hidden button */ - nmtbr.tbButton.fsState = TBSTATE_HIDDEN; else nmtbr.tbButton.idCommand = (int)*nmtbr.pCurrent;
1
0
0
0
Huw Davies : comctl32: The number of buttons is set by the first TBN_RESTORE notification.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 77ed3733af8b8c45c2a8a89db4a9f31733eec397 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=77ed3733af8b8c45c2a8a89db…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:55 2015 +0100 comctl32: The number of buttons is set by the first TBN_RESTORE notification. --- dlls/comctl32/tests/toolbar.c | 49 +++++++++++++++++++++++++++++++++++++++++++ dlls/comctl32/toolbar.c | 4 ++-- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 18dc534..9535947 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -163,7 +163,45 @@ static LRESULT parent_wnd_notify(LPARAM lParam) /* Return value is ignored */ return 1; } + case TBN_RESTORE: + { + NMTBRESTORE *restore = (NMTBRESTORE *)lParam; + + if (restore->iItem == -1) + { + ok( restore->cButtons == 15, "got %d\n", restore->cButtons ); + ok( *restore->pCurrent == 0xcafe, "got %08x\n", *restore->pCurrent ); + /* Skip the last one */ + restore->cButtons = 6; + restore->pCurrent++; + /* BytesPerRecord is ignored */ + restore->cbBytesPerRecord = 10; + } + else + { + ok( *restore->pCurrent == 0xcafe0000 + restore->iItem, "got %08x\n", *restore->pCurrent ); + ok( restore->tbButton.iBitmap == -1, "got %08x\n", restore->tbButton.iBitmap ); + ok( restore->tbButton.idCommand == restore->iItem * 2 + 1, "got %08x\n", restore->tbButton.idCommand ); + ok( restore->tbButton.fsState == 0, "got %02x\n", restore->tbButton.fsState ); + ok( restore->tbButton.fsStyle == 0, "got %02x\n", restore->tbButton.fsStyle ); + ok( restore->tbButton.dwData == 0, "got %08lx\n", restore->tbButton.dwData ); + ok( restore->tbButton.iString == 0, "got %08lx\n", restore->tbButton.iString ); + + restore->tbButton.iBitmap = 0; + restore->tbButton.fsState = TBSTATE_ENABLED; + restore->tbButton.fsStyle = 0; + restore->tbButton.iString = -1; + + restore->pCurrent++; + /* Altering cButtons after the 1st call makes no difference. */ + restore->cButtons--; + } + /* Returning non-zero from the 1st call aborts the restore, + otherwise the return value is ignored. */ + if (restore->iItem == -1) return 0; + return 1; + } } return 0; } @@ -2161,6 +2199,17 @@ static void test_save(void) ok( size == sizeof(expect), "got %08x\n", size ); ok( !memcmp( data, expect, size ), "mismatch\n" ); + RegCloseKey( key ); + + wnd = NULL; + rebuild_toolbar( &wnd ); + res = SendMessageW( wnd, TB_SAVERESTOREW, FALSE, (LPARAM)¶ms ); + ok( res, "restoring failed\n" ); + res = SendMessageW( wnd, TB_BUTTONCOUNT, 0, 0 ); + ok( res == 6, "got %d\n", res ); + + DestroyWindow( wnd ); + RegOpenKeyW( HKEY_CURRENT_USER, subkey, &key ); RegDeleteValueW( key, value ); RegCloseKey( key ); } diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index e230d885..9c3707b 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4183,13 +4183,13 @@ TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, const TBSAVEPARAMSW *lpSave) if (!TOOLBAR_SendNotify(&nmtbr.hdr, infoPtr, TBN_RESTORE)) { - INT i; + INT i, count = nmtbr.cButtons; /* remove all existing buttons as this function is designed to * restore the toolbar to a previously saved state */ TOOLBAR_DeleteAllButtons(infoPtr); - for (i = 0; i < nmtbr.cButtons; i++) + for (i = 0; i < count; i++) { nmtbr.iItem = i; nmtbr.tbButton.iBitmap = -1;
1
0
0
0
Huw Davies : comctl32: Implement toolbar saving.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 063c7866f5e770c5efaa628e2e49db503f95469b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=063c7866f5e770c5efaa628e2…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:54 2015 +0100 comctl32: Implement toolbar saving. --- dlls/comctl32/tests/toolbar.c | 89 ++++++++++++++++++++++++++++++++++++++++++- dlls/comctl32/toolbar.c | 53 +++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 2041216..18dc534 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -54,6 +54,18 @@ static const struct message ttgetdispinfo_parent_seq[] = { { 0 } }; +static const struct message save_parent_seq[] = { + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, -1 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 0 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 1 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 2 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 3 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 4 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 5 }, + { WM_NOTIFY, sent|id|custdraw, 0, 0, TBN_SAVE, 6 }, + { 0 } +}; + #define DEFINE_EXPECT(func) \ static BOOL expect_ ## func = FALSE, called_ ## func = FALSE @@ -133,6 +145,25 @@ static LRESULT parent_wnd_notify(LPARAM lParam) compare(nmdisp->dwMask, g_dwExpectedDispInfoMask, "%x"); ok(nmdisp->pszText == NULL, "pszText is not NULL\n"); break; + case TBN_SAVE: + { + NMTBSAVE *save = (NMTBSAVE *)lParam; + if (save->iItem == -1) + { + save->cbData = save->cbData * 2 + sizeof(DWORD); + save->pData = HeapAlloc( GetProcessHeap(), 0, save->cbData ); + save->pData[0] = 0xcafe; + save->pCurrent = save->pData + 1; + } + else + { + save->pCurrent[0] = 0xcafe0000 + save->iItem; + save->pCurrent++; + } + /* Return value is ignored */ + return 1; + } + } return 0; } @@ -148,7 +179,19 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, if (defwndproc_counter) msg.flags |= defwinproc; msg.wParam = wParam; msg.lParam = lParam; - if (message == WM_NOTIFY && lParam) msg.id = ((NMHDR*)lParam)->code; + if (message == WM_NOTIFY && lParam) + { + msg.id = ((NMHDR*)lParam)->code; + switch (msg.id) + { + case TBN_SAVE: + { + NMTBSAVE *save = (NMTBSAVE *)lParam; + msg.stage = save->iItem; + } + break; + } + } /* log system messages, except for painting */ if (message < WM_USER && @@ -2079,6 +2122,49 @@ static void test_noresize(void) } +static void test_save(void) +{ + HWND wnd = NULL; + TBSAVEPARAMSW params; + static const WCHAR subkey[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','T','e','s','t',0}; + static const WCHAR value[] = {'t','o','o','l','b','a','r','t','e','s','t',0}; + LONG res; + HKEY key; + BYTE data[100]; + DWORD size = sizeof(data), type; + static const TBBUTTON more_btns[2] = + { + {0, 11, TBSTATE_HIDDEN, BTNS_BUTTON, {0}, 0, -1}, + {0, 13, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, -1} + }; + static const DWORD expect[] = {0xcafe, 1, 0xcafe0000, 3, 0xcafe0001, 5, 0xcafe0002, 7, 0xcafe0003, + 9, 0xcafe0004, 11, 0xcafe0005, 13, 0xcafe0006 }; + + params.hkr = HKEY_CURRENT_USER; + params.pszSubKey = subkey; + params.pszValueName = value; + + rebuild_toolbar_with_buttons( &wnd ); + SendMessageW( wnd, TB_ADDBUTTONSW, sizeof(more_btns) / sizeof(more_btns[0]), (LPARAM)more_btns ); + + flush_sequences(sequences, NUM_MSG_SEQUENCES); + res = SendMessageW( wnd, TB_SAVERESTOREW, TRUE, (LPARAM)¶ms ); + ok( res, "saving failed\n" ); + ok_sequence(sequences, PARENT_SEQ_INDEX, save_parent_seq, "save", FALSE); + DestroyWindow( wnd ); + + res = RegOpenKeyW( HKEY_CURRENT_USER, subkey, &key ); + ok( !res, "got %08x\n", res ); + res = RegQueryValueExW( key, value, NULL, &type, data, &size ); + ok( !res, "got %08x\n", res ); + ok( type == REG_BINARY, "got %08x\n", type ); + ok( size == sizeof(expect), "got %08x\n", size ); + ok( !memcmp( data, expect, size ), "mismatch\n" ); + + RegDeleteValueW( key, value ); + RegCloseKey( key ); +} + START_TEST(toolbar) { WNDCLASSA wc; @@ -2122,6 +2208,7 @@ START_TEST(toolbar) test_create(); test_TB_GET_SET_EXTENDEDSTYLE(); test_noresize(); + test_save(); PostQuitMessage(0); while(GetMessageA(&msg,0,0,0)) { diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index aa9ffcd..e230d885 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4071,12 +4071,55 @@ TOOLBAR_ReplaceBitmap (TOOLBAR_INFO *infoPtr, const TBREPLACEBITMAP *lpReplace) /* helper for TOOLBAR_SaveRestoreW */ static BOOL -TOOLBAR_Save(const TBSAVEPARAMSW *lpSave) +TOOLBAR_Save(TOOLBAR_INFO *infoPtr, const TBSAVEPARAMSW *params) { - FIXME("save to %s %s\n", debugstr_w(lpSave->pszSubKey), - debugstr_w(lpSave->pszValueName)); + NMTBSAVE save; + INT ret, i; + BOOL alloced = FALSE; + HKEY key; - return FALSE; + TRACE( "save to %s %s\n", debugstr_w(params->pszSubKey), debugstr_w(params->pszValueName) ); + + memset( &save, 0, sizeof(save) ); + save.cbData = infoPtr->nNumButtons * sizeof(DWORD); + save.iItem = -1; + save.cButtons = infoPtr->nNumButtons; + save.tbButton.idCommand = -1; + TOOLBAR_SendNotify( &save.hdr, infoPtr, TBN_SAVE ); + + if (!save.pData) + { + save.pData = Alloc( save.cbData ); + if (!save.pData) return FALSE; + alloced = TRUE; + } + if (!save.pCurrent) save.pCurrent = save.pData; + + for (i = 0; i < infoPtr->nNumButtons; i++) + { + save.iItem = i; + save.tbButton.iBitmap = infoPtr->buttons[i].iBitmap; + save.tbButton.idCommand = infoPtr->buttons[i].idCommand; + save.tbButton.fsState = infoPtr->buttons[i].fsState; + save.tbButton.fsStyle = infoPtr->buttons[i].fsStyle; + memset( save.tbButton.bReserved, 0, sizeof(save.tbButton.bReserved) ); + save.tbButton.dwData = infoPtr->buttons[i].dwData; + save.tbButton.iString = infoPtr->buttons[i].iString; + + *save.pCurrent++ = save.tbButton.idCommand; + + TOOLBAR_SendNotify( &save.hdr, infoPtr, TBN_SAVE ); + } + + ret = RegCreateKeyW( params->hkr, params->pszSubKey, &key ); + if (ret == ERROR_SUCCESS) + { + ret = RegSetValueExW( key, params->pszValueName, 0, REG_BINARY, (BYTE *)save.pData, save.cbData ); + RegCloseKey( key ); + } + + if (alloced) Free( save.pData ); + return !ret; } @@ -4211,7 +4254,7 @@ TOOLBAR_SaveRestoreW (TOOLBAR_INFO *infoPtr, WPARAM wParam, const TBSAVEPARAMSW if (lpSave == NULL) return 0; if (wParam) - return TOOLBAR_Save(lpSave); + return TOOLBAR_Save(infoPtr, lpSave); else return TOOLBAR_Restore(infoPtr, lpSave); }
1
0
0
0
Huw Davies : comctl32: Don't leak button text.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 199f51ff78c94925bdbdd13a0c431035358f682b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=199f51ff78c94925bdbdd13a0…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:53 2015 +0100 comctl32: Don't leak button text. --- dlls/comctl32/toolbar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 19d45a0..aa9ffcd 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4088,6 +4088,7 @@ TOOLBAR_DeleteAllButtons(TOOLBAR_INFO *infoPtr) for (i = 0; i < infoPtr->nNumButtons; i++) { + free_string( infoPtr->buttons + i ); TOOLBAR_TooltipDelTool(infoPtr, &infoPtr->buttons[i]); }
1
0
0
0
Huw Davies : comctl32: Add a helper to free button text.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 01cd45cce1ba05069ebe88670c23c9478cadb6e0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=01cd45cce1ba05069ebe88670…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:52 2015 +0100 comctl32: Add a helper to free button text. --- dlls/comctl32/toolbar.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index bbfc6b7..19d45a0 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -353,6 +353,12 @@ static void set_stringT( TBUTTON_INFO *btn, const WCHAR *str, BOOL unicode ) set_string_index( btn, (DWORD_PTR)str, unicode ); } +static void free_string( TBUTTON_INFO *btn ) +{ + set_string_index( btn, 0, TRUE ); + +} + /*********************************************************************** * TOOLBAR_CheckStyle * @@ -3224,8 +3230,7 @@ TOOLBAR_DeleteButton (TOOLBAR_INFO *infoPtr, INT nIndex) if (infoPtr->nNumButtons == 1) { TRACE(" simple delete!\n"); - if (TOOLBAR_ButtonHasString(infoPtr->buttons)) - Free((LPWSTR)infoPtr->buttons[0].iString); + free_string( infoPtr->buttons ); Free (infoPtr->buttons); infoPtr->buttons = NULL; infoPtr->nNumButtons = 0; @@ -3246,8 +3251,7 @@ TOOLBAR_DeleteButton (TOOLBAR_INFO *infoPtr, INT nIndex) (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO)); } - if (TOOLBAR_ButtonHasString(&oldButtons[nIndex])) - Free((LPWSTR)oldButtons[nIndex].iString); + free_string( oldButtons + nIndex ); Free (oldButtons); } @@ -5227,8 +5231,7 @@ TOOLBAR_Destroy (TOOLBAR_INFO *infoPtr) /* delete button data */ for (i = 0; i < infoPtr->nNumButtons; i++) - if (TOOLBAR_ButtonHasString(&infoPtr->buttons[i])) - Free ((LPWSTR)infoPtr->buttons[i].iString); + free_string( infoPtr->buttons + i ); Free (infoPtr->buttons); /* delete strings */
1
0
0
0
Huw Davies : comctl32: Add helpers to set the button text.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: a29b6958e1315814a69730650528bddc92ff4292 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a29b6958e1315814a69730650…
Author: Huw Davies <huw(a)codeweavers.com> Date: Wed Jul 1 09:14:51 2015 +0100 comctl32: Add helpers to set the button text. --- dlls/comctl32/toolbar.c | 52 +++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 2c7ed63..bbfc6b7 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -328,6 +328,31 @@ TOOLBAR_ButtonHasString(const TBUTTON_INFO *btnPtr) return HIWORD(btnPtr->iString) && btnPtr->iString != -1; } +static void set_string_index( TBUTTON_INFO *btn, INT_PTR str, BOOL unicode ) +{ + if (!IS_INTRESOURCE( str ) && str != -1) + { + if (!TOOLBAR_ButtonHasString( btn )) btn->iString = 0; + + if (unicode) + Str_SetPtrW( (WCHAR **)&btn->iString, (WCHAR *)str ); + else + Str_SetPtrAtoW( (WCHAR **)&btn->iString, (char *)str ); + } + else + { + if (TOOLBAR_ButtonHasString( btn )) Free( (WCHAR *)btn->iString ); + + btn->iString = str; + } +} + +static void set_stringT( TBUTTON_INFO *btn, const WCHAR *str, BOOL unicode ) +{ + if (IS_INTRESOURCE( (DWORD_PTR)str ) || (DWORD_PTR)str == -1) return; + set_string_index( btn, (DWORD_PTR)str, unicode ); +} + /*********************************************************************** * TOOLBAR_CheckStyle * @@ -1817,6 +1842,7 @@ TOOLBAR_InternalInsertButtonsT(TOOLBAR_INFO *infoPtr, INT iIndex, UINT nAddButto /* insert new buttons data */ for (iButton = 0; iButton < nAddButtons; iButton++) { TBUTTON_INFO *btnPtr = &infoPtr->buttons[iIndex + iButton]; + INT_PTR str; TOOLBAR_DumpTBButton(lpTbb + iButton, fUnicode); @@ -1827,18 +1853,13 @@ TOOLBAR_InternalInsertButtonsT(TOOLBAR_INFO *infoPtr, INT iIndex, UINT nAddButto btnPtr->fsState = lpTbb[iButton].fsState; btnPtr->fsStyle = lpTbb[iButton].fsStyle; btnPtr->dwData = lpTbb[iButton].dwData; + if (btnPtr->fsStyle & BTNS_SEP) - btnPtr->iString = -1; - else if(!IS_INTRESOURCE(lpTbb[iButton].iString) && lpTbb[iButton].iString != -1) - { - if (fUnicode) - Str_SetPtrW((LPWSTR*)&btnPtr->iString, (LPWSTR)lpTbb[iButton].iString ); - else - Str_SetPtrAtoW((LPWSTR*)&btnPtr->iString, (LPSTR)lpTbb[iButton].iString); - fHasString = TRUE; - } + str = -1; else - btnPtr->iString = lpTbb[iButton].iString; + str = lpTbb[iButton].iString; + set_string_index( btnPtr, str, fUnicode ); + fHasString |= TOOLBAR_ButtonHasString( btnPtr ); TOOLBAR_TooltipAddTool(infoPtr, btnPtr); } @@ -4320,15 +4341,8 @@ TOOLBAR_SetButtonInfo (TOOLBAR_INFO *infoPtr, INT Id, if (lptbbi->dwMask & TBIF_STYLE) btnPtr->fsStyle = lptbbi->fsStyle; - if ((lptbbi->dwMask & TBIF_TEXT) && ((INT_PTR)lptbbi->pszText != -1)) { - /* iString is index, zero it to make Str_SetPtr succeed */ - if (!TOOLBAR_ButtonHasString(btnPtr)) btnPtr->iString = 0; - - if (isW) - Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText); - else - Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, (LPSTR)lptbbi->pszText); - } + if (lptbbi->dwMask & TBIF_TEXT) + set_stringT( btnPtr, lptbbi->pszText, isW ); /* save the button rect to see if we need to redraw the whole toolbar */ oldBtnRect = btnPtr->rect;
1
0
0
0
Michael Stefaniuc : dmime: Pass objects instead of ifaces to helpers.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: a2a2ea03115a9962d8e53e50d58b6d09a19ef3a4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a2a2ea03115a9962d8e53e50d…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Wed Jul 1 09:30:36 2015 +0200 dmime: Pass objects instead of ifaces to helpers. --- dlls/dmime/segtriggertrack.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/dmime/segtriggertrack.c b/dlls/dmime/segtriggertrack.c index 277c26f..882ada2 100644 --- a/dlls/dmime/segtriggertrack.c +++ b/dlls/dmime/segtriggertrack.c @@ -256,8 +256,9 @@ static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_IsDirty (LPPERS return S_FALSE; } -static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) { - ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface); +static HRESULT parse_segment(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk, + IStream *pStm) +{ DMUS_PRIVATE_CHUNK Chunk; DWORD ListSize[3], ListCount[3]; LARGE_INTEGER liMove; /* used when skipping chunks */ @@ -312,7 +313,8 @@ static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (LPPERSIS switch (Chunk.fccID) { case DMUS_FOURCC_REF_LIST: { FIXME_(dmfile)(": DMRF (DM References) list\n"); - hr = IDirectMusicUtils_IPersistStream_ParseReference (iface, &Chunk, pStm, &pObject); + hr = IDirectMusicUtils_IPersistStream_ParseReference((IPersistStream*)&This->PersistStreamVtbl, + &Chunk, pStm, &pObject); if (FAILED(hr)) { ERR(": could not load Reference\n"); return hr; @@ -346,8 +348,9 @@ static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (LPPERSIS return S_OK; } -static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) { - /*ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);*/ +static HRESULT parse_segments_list(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk, + IStream *pStm) +{ HRESULT hr = E_FAIL; DMUS_PRIVATE_CHUNK Chunk; DWORD ListSize[3], ListCount[3]; @@ -374,7 +377,7 @@ static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (LPP switch (Chunk.fccID) { case DMUS_FOURCC_SEGMENT_LIST: { TRACE_(dmfile)(": SEGMENT list\n"); - hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegment (iface, &Chunk, pStm); + hr = parse_segment(This, &Chunk, pStm); if (FAILED(hr)) return hr; break; } @@ -400,8 +403,9 @@ static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (LPP return S_OK; } -static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (LPPERSISTSTREAM iface, DMUS_PRIVATE_CHUNK* pChunk, IStream* pStm) { - /*ICOM_THIS_MULTI(IDirectMusicSegTriggerTrack, PersistStreamVtbl, iface);*/ +static HRESULT parse_seqtrack_list(IDirectMusicSegTriggerTrack *This, DMUS_PRIVATE_CHUNK *pChunk, + IStream *pStm) +{ HRESULT hr = E_FAIL; DMUS_PRIVATE_CHUNK Chunk; DWORD ListSize[3], ListCount[3]; @@ -434,7 +438,7 @@ static HRESULT IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (LPP switch (Chunk.fccID) { case DMUS_FOURCC_SEGMENTS_LIST: { TRACE_(dmfile)(": SEGMENTS list\n"); - hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegmentsList (iface, &Chunk, pStm); + hr = parse_segments_list(This, &Chunk, pStm); if (FAILED(hr)) return hr; break; } @@ -478,7 +482,7 @@ static HRESULT WINAPI IDirectMusicSegTriggerTrack_IPersistStream_Load (LPPERSIST switch (Chunk.fccID) { case DMUS_FOURCC_SEGTRACK_LIST: { TRACE_(dmfile)(": segment trigger track list\n"); - hr = IDirectMusicSegTriggerTrack_IPersistStream_ParseSegTrackList (iface, &Chunk, pStm); + hr = parse_seqtrack_list(This, &Chunk, pStm); if (FAILED(hr)) return hr; break; }
1
0
0
0
Michael Stefaniuc : dmstyle: Mark IPersistStream_Save() as stub.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 40769b4fadae605ee5656bab53205aad92c8b355 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=40769b4fadae605ee5656bab5…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Wed Jul 1 09:29:59 2015 +0200 dmstyle: Mark IPersistStream_Save() as stub. --- dlls/dmstyle/auditiontrack.c | 14 +++++++++++++- dlls/dmstyle/chordtrack.c | 11 ++++++++--- dlls/dmstyle/commandtrack.c | 9 ++++++++- dlls/dmstyle/mutetrack.c | 14 +++++++++++++- dlls/dmstyle/tests/dmstyle.c | 2 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/dlls/dmstyle/auditiontrack.c b/dlls/dmstyle/auditiontrack.c index 3239ed7..3c304ca 100644 --- a/dlls/dmstyle/auditiontrack.c +++ b/dlls/dmstyle/auditiontrack.c @@ -242,6 +242,11 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = { IDirectMusicTrack8Impl_Join }; +static inline IDirectMusicAuditionTrack * impl_from_IPersistStream(IPersistStream *iface) +{ + return CONTAINING_RECORD(iface, IDirectMusicAuditionTrack, dmobj.IPersistStream_iface); +} + static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *stream) { FIXME(": Loading not implemented yet\n"); @@ -251,7 +256,14 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *st static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *stream, BOOL cleardirty) { - return E_NOTIMPL; + IDirectMusicAuditionTrack *This = impl_from_IPersistStream(iface); + + FIXME("(%p, %p, %d): stub\n", This, stream, cleardirty); + + if (!stream) + return E_POINTER; + + return E_NOTIMPL; } static const IPersistStreamVtbl persiststream_vtbl = { diff --git a/dlls/dmstyle/chordtrack.c b/dlls/dmstyle/chordtrack.c index db4befc..fd290bf 100644 --- a/dlls/dmstyle/chordtrack.c +++ b/dlls/dmstyle/chordtrack.c @@ -376,9 +376,14 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pS static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *stream, BOOL cleardirty) { - IDirectMusicChordTrack *This = impl_from_IPersistStream(iface); - FIXME("(%p): Saving not implemented yet\n", This); - return E_NOTIMPL; + IDirectMusicChordTrack *This = impl_from_IPersistStream(iface); + + FIXME("(%p, %p, %d): stub\n", This, stream, cleardirty); + + if (!stream) + return E_POINTER; + + return E_NOTIMPL; } static const IPersistStreamVtbl persiststream_vtbl = { diff --git a/dlls/dmstyle/commandtrack.c b/dlls/dmstyle/commandtrack.c index 9f798e7..e326241 100644 --- a/dlls/dmstyle/commandtrack.c +++ b/dlls/dmstyle/commandtrack.c @@ -319,7 +319,14 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pS static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *stream, BOOL cleardirty) { - return E_NOTIMPL; + IDirectMusicCommandTrack *This = impl_from_IPersistStream(iface); + + FIXME("(%p, %p, %d): stub\n", This, stream, cleardirty); + + if (!stream) + return E_POINTER; + + return E_NOTIMPL; } static const IPersistStreamVtbl persiststream_vtbl = { diff --git a/dlls/dmstyle/mutetrack.c b/dlls/dmstyle/mutetrack.c index c912ee0..67bfbc3 100644 --- a/dlls/dmstyle/mutetrack.c +++ b/dlls/dmstyle/mutetrack.c @@ -247,6 +247,11 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = { IDirectMusicTrack8Impl_Join }; +static inline IDirectMusicMuteTrack * impl_from_IPersistStream(IPersistStream *iface) +{ + return CONTAINING_RECORD(iface, IDirectMusicMuteTrack, dmobj.IPersistStream_iface); +} + static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *stream) { FIXME(": Loading not implemented yet\n"); @@ -256,7 +261,14 @@ static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *st static HRESULT WINAPI IPersistStreamImpl_Save(IPersistStream *iface, IStream *stream, BOOL cleardirty) { - return E_NOTIMPL; + IDirectMusicMuteTrack *This = impl_from_IPersistStream(iface); + + FIXME("(%p, %p, %d): stub\n", This, stream, cleardirty); + + if (!stream) + return E_POINTER; + + return E_NOTIMPL; } static const IPersistStreamVtbl persiststream_vtbl = { diff --git a/dlls/dmstyle/tests/dmstyle.c b/dlls/dmstyle/tests/dmstyle.c index 9468c39..2677daa 100644 --- a/dlls/dmstyle/tests/dmstyle.c +++ b/dlls/dmstyle/tests/dmstyle.c @@ -339,7 +339,7 @@ static void test_track(void) hr = IPersistStream_Save(ps, NULL, TRUE); if (class[i].has_save) - todo_wine ok(hr == E_POINTER, "IPersistStream_Save failed: %08x\n", hr); + ok(hr == E_POINTER, "IPersistStream_Save failed: %08x\n", hr); else ok(hr == E_NOTIMPL, "IPersistStream_Save failed: %08x\n", hr);
1
0
0
0
Michael Stefaniuc : dmstyle: Use the generic IPersistStream for DMStyleTrack.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: 2026a215251f2c7b8defb20451d4c7d63556aaf6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=2026a215251f2c7b8defb2045…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Wed Jul 1 09:27:38 2015 +0200 dmstyle: Use the generic IPersistStream for DMStyleTrack. --- dlls/dmstyle/dmutils.h | 2 -- dlls/dmstyle/styletrack.c | 84 +++++++++++++---------------------------------- 2 files changed, 23 insertions(+), 63 deletions(-) diff --git a/dlls/dmstyle/dmutils.h b/dlls/dmstyle/dmutils.h index 9f2f98e..9fc2904 100644 --- a/dlls/dmstyle/dmutils.h +++ b/dlls/dmstyle/dmutils.h @@ -27,8 +27,6 @@ typedef struct _DMUS_PRIVATE_CHUNK { DWORD dwSize; /* size of the chunk */ } DMUS_PRIVATE_CHUNK, *LPDMUS_PRIVATE_CHUNK; -#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) - /** * Parsing utilities */ diff --git a/dlls/dmstyle/styletrack.c b/dlls/dmstyle/styletrack.c index 0ea9c86..79b4787 100644 --- a/dlls/dmstyle/styletrack.c +++ b/dlls/dmstyle/styletrack.c @@ -18,6 +18,7 @@ */ #include "dmstyle_private.h" +#include "dmobject.h" WINE_DEFAULT_DEBUG_CHANNEL(dmstyle); WINE_DECLARE_DEBUG_CHANNEL(dmfile); @@ -27,9 +28,8 @@ WINE_DECLARE_DEBUG_CHANNEL(dmfile); */ typedef struct IDirectMusicStyleTrack { IDirectMusicTrack8 IDirectMusicTrack8_iface; - const IPersistStreamVtbl *PersistStreamVtbl; + struct dmobject dmobj; /* IPersistStream only */ LONG ref; - DMUS_OBJECTDESC *pDesc; struct list Items; } IDirectMusicStyleTrack; @@ -52,7 +52,7 @@ static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 * IsEqualIID(riid, &IID_IDirectMusicTrack8)) *ret_iface = iface; else if (IsEqualIID(riid, &IID_IPersistStream)) - *ret_iface = &This->PersistStreamVtbl; + *ret_iface = &This->dmobj.IPersistStream_iface; else { WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface); return E_NOINTERFACE; @@ -250,35 +250,6 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = { IDirectMusicTrack8Impl_Join }; -/* IDirectMusicStyleTrack IPersistStream part: */ -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj); -} - -static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface); -} - -static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_Release (LPPERSISTSTREAM iface) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface); -} - -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - TRACE("(%p, %p)\n", This, pClassID); - *pClassID = CLSID_DirectMusicStyleTrack; - return S_OK; -} - -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_IsDirty (LPPERSISTSTREAM iface) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - FIXME("(%p): stub, always S_FALSE\n", This); - return S_FALSE; -} - static HRESULT parse_style_ref(IDirectMusicStyleTrack *This, DMUS_PRIVATE_CHUNK *pChunk, IStream *pStm) { @@ -326,7 +297,7 @@ static HRESULT parse_style_ref(IDirectMusicStyleTrack *This, DMUS_PRIVATE_CHUNK */ case DMUS_FOURCC_REF_LIST: { FIXME_(dmfile)(": DMRF (DM References) list, not yet handled\n"); - hr = IDirectMusicUtils_IPersistStream_ParseReference((IPersistStream*)&This->PersistStreamVtbl, + hr = IDirectMusicUtils_IPersistStream_ParseReference(&This->dmobj.IPersistStream_iface, &Chunk, pStm, &pObject); if (FAILED(hr)) { ERR(": could not load Reference\n"); @@ -418,9 +389,14 @@ static HRESULT parse_styletrack_list(IDirectMusicStyleTrack *This, DMUS_PRIVATE_ return S_OK; } -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREAM iface, IStream* pStm) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); +static inline IDirectMusicStyleTrack *impl_from_IPersistStream(IPersistStream *iface) +{ + return CONTAINING_RECORD(iface, IDirectMusicStyleTrack, dmobj.IPersistStream_iface); +} +static HRESULT WINAPI IPersistStreamImpl_Load(IPersistStream *iface, IStream *pStm) +{ + IDirectMusicStyleTrack *This = impl_from_IPersistStream(iface); DMUS_PRIVATE_CHUNK Chunk; LARGE_INTEGER liMove; HRESULT hr; @@ -461,27 +437,15 @@ static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Load (LPPERSISTSTREA return S_OK; } -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_Save (LPPERSISTSTREAM iface, IStream* pStm, BOOL fClearDirty) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - FIXME("(%p): Saving not implemented yet\n", This); - return E_NOTIMPL; -} - -static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetSizeMax (LPPERSISTSTREAM iface, ULARGE_INTEGER* pcbSize) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - FIXME("(%p, %p): stub\n", This, pcbSize); - return E_NOTIMPL; -} - -static const IPersistStreamVtbl DirectMusicStyleTrack_PersistStream_Vtbl = { - IDirectMusicStyleTrack_IPersistStream_QueryInterface, - IDirectMusicStyleTrack_IPersistStream_AddRef, - IDirectMusicStyleTrack_IPersistStream_Release, - IDirectMusicStyleTrack_IPersistStream_GetClassID, - IDirectMusicStyleTrack_IPersistStream_IsDirty, - IDirectMusicStyleTrack_IPersistStream_Load, - IDirectMusicStyleTrack_IPersistStream_Save, - IDirectMusicStyleTrack_IPersistStream_GetSizeMax +static const IPersistStreamVtbl persiststream_vtbl = { + dmobj_IPersistStream_QueryInterface, + dmobj_IPersistStream_AddRef, + dmobj_IPersistStream_Release, + dmobj_IPersistStream_GetClassID, + unimpl_IPersistStream_IsDirty, + IPersistStreamImpl_Load, + unimpl_IPersistStream_Save, + unimpl_IPersistStream_GetSizeMax }; /* for ClassFactory */ @@ -496,12 +460,10 @@ HRESULT WINAPI create_dmstyletrack(REFIID lpcGUID, void **ppobj) return E_OUTOFMEMORY; } track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl; - track->PersistStreamVtbl = &DirectMusicStyleTrack_PersistStream_Vtbl; - track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); - DM_STRUCT_INIT(track->pDesc); - track->pDesc->dwValidData |= DMUS_OBJ_CLASS; - track->pDesc->guidClass = CLSID_DirectMusicStyleTrack; track->ref = 1; + dmobject_init(&track->dmobj, &CLSID_DirectMusicStyleTrack, + (IUnknown *)&track->IDirectMusicTrack8_iface); + track->dmobj.IPersistStream_iface.lpVtbl = &persiststream_vtbl; list_init (&track->Items); DMSTYLE_LockModule();
1
0
0
0
Michael Stefaniuc : dmstyle: Remove the extraneous IUnknown from DMStyleTrack.
by Alexandre Julliard
01 Jul '15
01 Jul '15
Module: wine Branch: master Commit: f143c16bb8fcbdb382094134763550de27567c80 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f143c16bb8fcbdb3820941347…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Wed Jul 1 09:25:50 2015 +0200 dmstyle: Remove the extraneous IUnknown from DMStyleTrack. --- dlls/dmstyle/styletrack.c | 129 ++++++++++++++++++---------------------------- 1 file changed, 51 insertions(+), 78 deletions(-) diff --git a/dlls/dmstyle/styletrack.c b/dlls/dmstyle/styletrack.c index cc20430..0ea9c86 100644 --- a/dlls/dmstyle/styletrack.c +++ b/dlls/dmstyle/styletrack.c @@ -22,14 +22,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(dmstyle); WINE_DECLARE_DEBUG_CHANNEL(dmfile); -static ULONG WINAPI IDirectMusicStyleTrack_IUnknown_AddRef (LPUNKNOWN iface); -static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface); - /***************************************************************************** * IDirectMusicStyleTrack implementation */ typedef struct IDirectMusicStyleTrack { - const IUnknownVtbl *UnknownVtbl; IDirectMusicTrack8 IDirectMusicTrack8_iface; const IPersistStreamVtbl *PersistStreamVtbl; LONG ref; @@ -37,62 +33,6 @@ typedef struct IDirectMusicStyleTrack { struct list Items; } IDirectMusicStyleTrack; -/* IDirectMusicStyleTrack IUnknown part: */ -static HRESULT WINAPI IDirectMusicStyleTrack_IUnknown_QueryInterface (LPUNKNOWN iface, REFIID riid, LPVOID *ppobj) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface); - TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ppobj); - - if (IsEqualIID (riid, &IID_IUnknown)) { - *ppobj = &This->UnknownVtbl; - IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); - return S_OK; - } else if (IsEqualIID (riid, &IID_IDirectMusicTrack) - || IsEqualIID (riid, &IID_IDirectMusicTrack8)) { - *ppobj = &This->IDirectMusicTrack8_iface; - IDirectMusicTrack8_AddRef (&This->IDirectMusicTrack8_iface); - return S_OK; - } else if (IsEqualIID (riid, &IID_IPersistStream)) { - *ppobj = &This->PersistStreamVtbl; - IDirectMusicStyleTrack_IPersistStream_AddRef ((LPPERSISTSTREAM)&This->PersistStreamVtbl); - return S_OK; - } - - WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ppobj); - return E_NOINTERFACE; -} - -static ULONG WINAPI IDirectMusicStyleTrack_IUnknown_AddRef (LPUNKNOWN iface) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p): AddRef from %d\n", This, ref - 1); - - DMSTYLE_LockModule(); - - return ref; -} - -static ULONG WINAPI IDirectMusicStyleTrack_IUnknown_Release (LPUNKNOWN iface) { - ICOM_THIS_MULTI(IDirectMusicStyleTrack, UnknownVtbl, iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p): ReleaseRef to %d\n", This, ref); - - if (ref == 0) { - HeapFree(GetProcessHeap(), 0, This); - } - - DMSTYLE_UnlockModule(); - - return ref; -} - -static const IUnknownVtbl DirectMusicStyleTrack_Unknown_Vtbl = { - IDirectMusicStyleTrack_IUnknown_QueryInterface, - IDirectMusicStyleTrack_IUnknown_AddRef, - IDirectMusicStyleTrack_IUnknown_Release -}; - /* IDirectMusicStyleTrack IDirectMusicTrack8 part: */ static inline IDirectMusicStyleTrack *impl_from_IDirectMusicTrack8(IDirectMusicTrack8 *iface) { @@ -100,22 +40,51 @@ static inline IDirectMusicStyleTrack *impl_from_IDirectMusicTrack8(IDirectMusicT } static HRESULT WINAPI IDirectMusicTrack8Impl_QueryInterface(IDirectMusicTrack8 *iface, REFIID riid, - void **ppobj) + void **ret_iface) { IDirectMusicStyleTrack *This = impl_from_IDirectMusicTrack8(iface); - return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); + + TRACE("(%p, %s, %p)\n", This, debugstr_dmguid(riid), ret_iface); + + *ret_iface = NULL; + + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDirectMusicTrack) || + IsEqualIID(riid, &IID_IDirectMusicTrack8)) + *ret_iface = iface; + else if (IsEqualIID(riid, &IID_IPersistStream)) + *ret_iface = &This->PersistStreamVtbl; + else { + WARN("(%p, %s, %p): not found\n", This, debugstr_dmguid(riid), ret_iface); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ret_iface); + return S_OK; } static ULONG WINAPI IDirectMusicTrack8Impl_AddRef(IDirectMusicTrack8 *iface) { IDirectMusicStyleTrack *This = impl_from_IDirectMusicTrack8(iface); - return IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; } static ULONG WINAPI IDirectMusicTrack8Impl_Release(IDirectMusicTrack8 *iface) { IDirectMusicStyleTrack *This = impl_from_IDirectMusicTrack8(iface); - return IDirectMusicStyleTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if (!ref) { + HeapFree(GetProcessHeap(), 0, This); + DMSTYLE_UnlockModule(); + } + + return ref; } static HRESULT WINAPI IDirectMusicTrack8Impl_Init(IDirectMusicTrack8 *iface, @@ -284,17 +253,17 @@ static const IDirectMusicTrack8Vtbl dmtrack8_vtbl = { /* IDirectMusicStyleTrack IPersistStream part: */ static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_QueryInterface (LPPERSISTSTREAM iface, REFIID riid, LPVOID *ppobj) { ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&This->UnknownVtbl, riid, ppobj); + return IDirectMusicTrack8_QueryInterface(&This->IDirectMusicTrack8_iface, riid, ppobj); } static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_AddRef (LPPERSISTSTREAM iface) { ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicStyleTrack_IUnknown_AddRef ((LPUNKNOWN)&This->UnknownVtbl); + return IDirectMusicTrack8_AddRef(&This->IDirectMusicTrack8_iface); } static ULONG WINAPI IDirectMusicStyleTrack_IPersistStream_Release (LPPERSISTSTREAM iface) { ICOM_THIS_MULTI(IDirectMusicStyleTrack, PersistStreamVtbl, iface); - return IDirectMusicStyleTrack_IUnknown_Release ((LPUNKNOWN)&This->UnknownVtbl); + return IDirectMusicTrack8_Release(&This->IDirectMusicTrack8_iface); } static HRESULT WINAPI IDirectMusicStyleTrack_IPersistStream_GetClassID (LPPERSISTSTREAM iface, CLSID* pClassID) { @@ -518,22 +487,26 @@ static const IPersistStreamVtbl DirectMusicStyleTrack_PersistStream_Vtbl = { /* for ClassFactory */ HRESULT WINAPI create_dmstyletrack(REFIID lpcGUID, void **ppobj) { - IDirectMusicStyleTrack* track; - - track = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicStyleTrack)); - if (NULL == track) { - *ppobj = NULL; - return E_OUTOFMEMORY; - } - track->UnknownVtbl = &DirectMusicStyleTrack_Unknown_Vtbl; + IDirectMusicStyleTrack *track; + HRESULT hr; + + track = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*track)); + if (!track) { + *ppobj = NULL; + return E_OUTOFMEMORY; + } track->IDirectMusicTrack8_iface.lpVtbl = &dmtrack8_vtbl; track->PersistStreamVtbl = &DirectMusicStyleTrack_PersistStream_Vtbl; track->pDesc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DMUS_OBJECTDESC)); DM_STRUCT_INIT(track->pDesc); track->pDesc->dwValidData |= DMUS_OBJ_CLASS; track->pDesc->guidClass = CLSID_DirectMusicStyleTrack; - track->ref = 0; /* will be inited by QueryInterface */ - list_init (&track->Items); + track->ref = 1; + list_init (&track->Items); + + DMSTYLE_LockModule(); + hr = IDirectMusicTrack8_QueryInterface(&track->IDirectMusicTrack8_iface, lpcGUID, ppobj); + IDirectMusicTrack8_Release(&track->IDirectMusicTrack8_iface); - return IDirectMusicStyleTrack_IUnknown_QueryInterface ((LPUNKNOWN)&track->UnknownVtbl, lpcGUID, ppobj); + return hr; }
1
0
0
0
← Newer
1
...
50
51
52
53
54
55
56
57
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Results per page:
10
25
50
100
200