ListView fix

François Gouget fgouget at codeweavers.com
Fri Mar 2 18:19:46 CST 2001


   Ok, so now that I've got the patch out, there's a weird problem that
I've been having with this piece of code. Apply the following on top of
my previous patch and you'll get the weirdest traces:

--- cut here ---
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/cvs/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.99
diff -u -r1.99 listview.c
--- dlls/comctl32/listview.c	2001/02/28 05:31:02	1.99
+++ dlls/comctl32/listview.c	2001/03/02 23:45:09
@@ -1542,10 +1545,22 @@
   item.stateMask = LVIS_SELECTED;
   item.state = LVIS_SELECTED;
 
+  TRACE("nSelectionMark=%d nItem=%d nFirst=%d
nLast=%d\n",infoPtr->nSelectionMark,nItem,nFirst,nLast);
+#if 0
+  i = nFirst;
+  while (i <= nLast)
+  {
+    TRACE("i=%d\n",i);
+    LISTVIEW_SetItemState(hwnd,i,&item);
+    i++;
+  }
+#else
   for (i = nFirst; i <= nLast; i++);
   {
+    TRACE("i=%d\n",i);
     LISTVIEW_SetItemState(hwnd,i,&item);
   }
+#endif
 
   LISTVIEW_SetItemFocus(hwnd, nItem);
   infoPtr->nSelectionMark = nItem;
--- cut here ---

   Now if I click on item 3 I get the following trace:
...
trace:listview:LISTVIEW_AddGroupSelection nSelectionMark=-1 nItem=3
nFirst=3 nLast=3
trace:listview:LISTVIEW_AddGroupSelection i=4
trace:listview:LISTVIEW_WindowProc hwnd=1908 uMsg=1006 wParam=0
lParam=405b6c30
trace:listview:LISTVIEW_AddSelectionRange Add range 4 - 4
...

   Now, last I checked (i.e. a few minutes a go), 'for (i=3;i<=3;i++)
printf("%d\n",i);' prints 3 and certainly not 4. Also, if I'm not
mistaken this code is strictly equivalent to the while loop in the '#if
0' branch. Yet the while loop works fine but not the for loop.

   In a word this looks like a gcc bug to me!
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
gcc version 2.95.2 20000220 (Debian GNU/Linux)

   How do we normally deal with those?


-- 
François Gouget
fgouget at codeweavers.com




More information about the wine-devel mailing list