Re: PATCH: Inserting an item in a listview sometimes generates incorrect messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reworked patch to as discussed on wine-devel list.

Changelog:

        * dlls/comctl32/listview.c: Adam Gundy <arg@cyberscience.com>
        When shifting the list's indices, we must not send notify messages
        if we have to refocus. Item modification handlers are not supposed
        to be called here.

--- wine-20030219/dlls/comctl32/listview.c      Fri Feb 14 23:31:45 2003
+++ wine-20030219-new/dlls/comctl32/listview.c  Fri Mar  7 11:47:11 2003
@@ -253,6 +253,7 @@
   BOOL bFirstPaint;            /* Flags if the control has never painted before */
   BOOL bAutoarrange;           /* Autoarrange flag when NOT in LVS_AUTOARRANGE */
   BOOL bFocus;
+  BOOL bDoChangeNotify;                /* send change notification messages? */
   INT nFocusedItem;
   RECT rcFocus;
   DWORD dwStyle;               /* the cached window GWL_STYLE */
@@ -2827,7 +2828,12 @@
 static void LISTVIEW_ShiftIndices(LISTVIEW_INFO *infoPtr, INT nItem, INT direction)
 {
     INT nNewFocus;
-    
+    BOOL bOldChange;
+
+    /* temporarily disable change notification while shifting items */
+    bOldChange = infoPtr->bDoChangeNotify;
+    infoPtr->bDoChangeNotify = FALSE;
+
     TRACE("Shifting %iu, %i steps\n", nItem, direction);
 
     ranges_shift(infoPtr->selectionRanges, nItem, direction, infoPtr->nItemCount);
@@ -2841,6 +2847,8 @@
         LISTVIEW_SetItemFocus(infoPtr, nNewFocus);
     
     /* But we are not supposed to modify nHotItem! */
+
+    infoPtr->bDoChangeNotify = bOldChange;
 }
 
 
@@ -3183,8 +3191,10 @@
     nmlv.lParam = item.lParam;
     
     /* send LVN_ITEMCHANGING notification, if the item is not being inserted */
-    /* and we are _NOT_ virtual (LVS_OWERNDATA) */
-    if(lpItem && !isNew && notify_listview(infoPtr, LVN_ITEMCHANGING, &nmlv))
+    /* and we are _NOT_ virtual (LVS_OWERNDATA), and change notifications */
+    /* are enabled */
+    if(lpItem && !isNew && infoPtr->bDoChangeNotify &&
+       notify_listview(infoPtr, LVN_ITEMCHANGING, &nmlv))
        return FALSE;
 
     /* copy information */
@@ -3234,7 +3244,7 @@
     
     /* send LVN_ITEMCHANGED notification */
     if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam;
-    notify_listview(infoPtr, LVN_ITEMCHANGED, &nmlv);
+    if (infoPtr->bDoChangeNotify) notify_listview(infoPtr, LVN_ITEMCHANGED, &nmlv);
 
     return TRUE;
 }
@@ -7049,6 +7059,7 @@
   infoPtr->bRedraw = TRUE;
   infoPtr->bFirstPaint = TRUE;
   infoPtr->bNoItemMetrics = TRUE;
+  infoPtr->bDoChangeNotify = TRUE;
   infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
   infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
   infoPtr->nEditLabelItem = -1;



Seeya,
 Adam
--
Real Programmers don't comment their code. If it was hard to write,
it should be hard to read, and even harder to modify.
These are all my own opinions.



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux