https://git.reactos.org/?p=reactos.git;a=commitdiff;h=73e6bc960ac0b0414808b…
commit 73e6bc960ac0b0414808b30700be5f661ed6367c
Author: Thomas Faber <thomas.faber(a)reactos.org>
AuthorDate: Sat Jan 20 02:21:32 2018 +0100
Commit: Thomas Faber <thomas.faber(a)reactos.org>
CommitDate: Sat Jan 20 02:24:01 2018 +0100
[COMCTL32] Unset the toolbar's hot item when deleting a button. CORE-14222
This fixes occasional crashes when hovering over disappearing tray icons.
---
dll/win32/comctl32/toolbar.c | 1 +
modules/rostests/winetests/comctl32/toolbar.c | 16 +++++++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dll/win32/comctl32/toolbar.c b/dll/win32/comctl32/toolbar.c
index 98965f42b8..c2befb228c 100644
--- a/dll/win32/comctl32/toolbar.c
+++ b/dll/win32/comctl32/toolbar.c
@@ -3382,6 +3382,7 @@ TOOLBAR_DeleteButton (TOOLBAR_INFO *infoPtr, INT nIndex)
TOOLBAR_TooltipDelTool(infoPtr, &infoPtr->buttons[nIndex]);
+ infoPtr->nHotItem = -1;
if (infoPtr->nNumButtons == 1) {
TRACE(" simple delete\n");
free_string( infoPtr->buttons );
diff --git a/modules/rostests/winetests/comctl32/toolbar.c
b/modules/rostests/winetests/comctl32/toolbar.c
index f49cd2ae81..fc217eede8 100644
--- a/modules/rostests/winetests/comctl32/toolbar.c
+++ b/modules/rostests/winetests/comctl32/toolbar.c
@@ -857,7 +857,7 @@ static void test_hotitem(void)
ok(ret == 3, "Hot item: %lx, expected 3\n", ret);
g_fBlockHotItemChange = TRUE;
ret = SendMessageA(hToolbar, TB_SETHOTITEM, 2, 0);
- ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 2\n", ret);
+ ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
ret = SendMessageA(hToolbar, TB_GETHOTITEM, 0, 0);
ok(ret == 3, "Hot item: %lx, expected 3\n", ret);
g_fBlockHotItemChange = FALSE;
@@ -888,7 +888,7 @@ static void test_hotitem(void)
/* enabling the button won't change that */
SendMessageA(hToolbar, TB_ENABLEBUTTON, 9, TRUE);
ret = SendMessageA(hToolbar, TB_GETHOTITEM, 0, 0);
- ok(ret == -1, "TB_SETHOTITEM returned %ld, expected -1\n", ret);
+ ok(ret == -1, "TB_GETHOTITEM returned %ld, expected -1\n", ret);
/* disabling a hot button works */
ret = SendMessageA(hToolbar, TB_SETHOTITEM, 3, 0);
@@ -896,7 +896,7 @@ static void test_hotitem(void)
g_fReceivedHotItemChange = FALSE;
SendMessageA(hToolbar, TB_ENABLEBUTTON, 7, FALSE);
ret = SendMessageA(hToolbar, TB_GETHOTITEM, 0, 0);
- ok(ret == 3, "TB_SETHOTITEM returned %ld, expected 3\n", ret);
+ ok(ret == 3, "TB_GETHOTITEM returned %ld, expected 3\n", ret);
ok(g_fReceivedHotItemChange == FALSE, "Unexpected TBN_HOTITEMCHANGE\n");
SendMessageA(hToolbar, TB_SETHOTITEM, 1, 0);
@@ -906,7 +906,17 @@ static void test_hotitem(void)
g_fReceivedHotItemChange = FALSE;
ok(SendMessageA(hToolbar, TB_SETBUTTONINFOA, 1, (LPARAM)&tbinfo) == TRUE,
"TB_SETBUTTONINFOA failed\n");
ret = SendMessageA(hToolbar, TB_GETHOTITEM, 0, 0);
+ ok(ret == 1, "TB_GETHOTITEM returned %ld, expected 1\n", ret);
+ ok(g_fReceivedHotItemChange == FALSE, "Unexpected TBN_HOTITEMCHANGE\n");
+
+ /* deleting a button unsets the hot item */
+ ret = SendMessageA(hToolbar, TB_SETHOTITEM, 0, 0);
ok(ret == 1, "TB_SETHOTITEM returned %ld, expected 1\n", ret);
+ g_fReceivedHotItemChange = FALSE;
+ ret = SendMessageA(hToolbar, TB_DELETEBUTTON, 1, 0);
+ ok(ret == TRUE, "TB_DELETEBUTTON returned %ld, expected TRUE\n", ret);
+ ret = SendMessageA(hToolbar, TB_GETHOTITEM, 0, 0);
+ ok(ret == -1, "TB_GETHOTITEM returned %ld, expected -1\n", ret);
ok(g_fReceivedHotItemChange == FALSE, "Unexpected TBN_HOTITEMCHANGE\n");
DestroyWindow(hToolbar);