[2/2] comctl32/listview: Add a special case for deselect all attempt when nothing is selected

Nikolay Sivov nsivov at codeweavers.com
Thu Jan 10 17:06:38 CST 2013


Add a special case for deselect all attempt when nothing is selected
-------------- next part --------------
>From 0ccfd84700ff741a9b11cf6d00305bdd68d055bf Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri, 11 Jan 2013 03:06:27 +0400
Subject: [PATCH 2/2] Add a special case for deselect all attempt when nothing
 is selected

---
 dlls/comctl32/listview.c       |    4 ++++
 dlls/comctl32/tests/listview.c |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 79d55da..bb6d1b2 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -8857,6 +8857,10 @@ static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE
         UINT oldstate = 0;
         BOOL notify;
 
+        /* special case optimization for recurring attemp to deselect all */
+        if (lvItem.state == 0 && lvItem.stateMask == LVIS_SELECTED && !LISTVIEW_GetSelectedCount(infoPtr))
+            return TRUE;
+
 	/* select all isn't allowed in LVS_SINGLESEL */
 	if ((lvItem.state & lvItem.stateMask & LVIS_SELECTED) && (infoPtr->dwStyle & LVS_SINGLESEL))
 	    return FALSE;
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 25321c3..cff6e92 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2271,7 +2271,7 @@ static void test_multiselect(void)
     item.state = 0;
     item.stateMask = LVIS_SELECTED;
     SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
-    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "deselect all notification 2", TRUE);
+    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "deselect all notification 2", FALSE);
 
     /* any non-zero state value does the same */
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
@@ -3111,7 +3111,7 @@ static void test_ownerdata(void)
     res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item);
     expect(TRUE, res);
 
-    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "ownerdata deselect all notification", TRUE);
+    ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "ownerdata deselect all notification", FALSE);
 
     /* select one, then deselect all */
     item.stateMask = LVIS_SELECTED;
-- 
1.7.10.4




More information about the wine-patches mailing list