Nikolay Sivov : comctl32/treeview: Check passed handle value in WM_COMMAND handler.
Alexandre Julliard
julliard at winehq.org
Fri Aug 7 08:49:16 CDT 2009
Module: wine
Branch: master
Commit: 6bcdc69ec05e6929c9ac5d63fb4a5976301dd4d0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6bcdc69ec05e6929c9ac5d63fb4a5976301dd4d0
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Fri Aug 7 00:13:25 2009 +0400
comctl32/treeview: Check passed handle value in WM_COMMAND handler.
---
dlls/comctl32/tests/treeview.c | 16 ++++++++++++++++
dlls/comctl32/treeview.c | 7 +++++--
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 7c86450..5cfaf20 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -879,9 +879,25 @@ static void test_itemedit(void)
/* item shouldn't be selected automatically after TVM_EDITLABEL */
r = SendMessage(hTree, TVM_GETITEMSTATE, (WPARAM)hRoot, TVIS_SELECTED);
expect(0, r);
+ /* try to cancel with wrong edit handle */
+ r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)NULL);
+ expect(0, r);
+ ok(IsWindow(edit), "Expected edit control to be valid\n");
r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)edit);
expect(0, r);
ok(!IsWindow(edit), "Expected edit control to be destroyed\n");
+ /* try to cancel without creating edit */
+ r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)NULL);
+ expect(0, r);
+
+ /* try to cancel with wrong (not null) handle */
+ edit = (HWND)SendMessage(hTree, TVM_EDITLABEL, 0, (LPARAM)hRoot);
+ ok(IsWindow(edit), "Expected valid handle\n");
+ r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)hTree);
+ expect(0, r);
+ ok(IsWindow(edit), "Expected edit control to be valid\n");
+ r = SendMessage(hTree, WM_COMMAND, MAKEWPARAM(0, EN_KILLFOCUS), (LPARAM)edit);
+ expect(0, r);
/* remove selection after starting edit */
r = TreeView_SelectItem(hTree, hRoot);
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 44bb841..a38434d 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -3651,8 +3651,11 @@ TREEVIEW_Command(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
break;
}
case EN_KILLFOCUS:
- TREEVIEW_EndEditLabelNow(infoPtr, FALSE);
- break;
+ /* apparently we should respect passed handle value */
+ if (infoPtr->hwndEdit != (HWND)lParam) return FALSE;
+
+ TREEVIEW_EndEditLabelNow(infoPtr, FALSE);
+ break;
default:
return SendMessageW(infoPtr->hwndNotify, WM_COMMAND, wParam, lParam);
More information about the wine-cvs
mailing list