PATCH: Updating treeview scrollbars with an empty tree SEGVs

Adam Gundy arg at cyberscience.com
Wed Mar 5 08:38:52 CST 2003


Hi. Asking the treeview to update its scrollbars when it didn't have any
items in its tree caused it to SEGV.

Cyberscience disclaims all copyright and responsibility... ;-)

Changelog:

        * dlls/comctl32/treeview.c: Adam Gundy <arg at cyberscience.com>
        TREEVIEW_UpdateScrollBars() now copes with an empty tree.

diff -u -r wine-20030219/dlls/comctl32/treeview.c wine-20030219-new/dlls/comctl32/treeview.c
--- wine-20030219/dlls/comctl32/treeview.c      Wed Jan  8 21:09:27 2003
+++ wine-20030219-new/dlls/comctl32/treeview.c  Wed Mar  5 11:05:20 2003
@@ -2690,14 +2690,23 @@
     if (vert)
     {
        si.nPage = TREEVIEW_GetVisibleCount(infoPtr);
-       si.nPos  = infoPtr->firstVisible->visibleOrder;
-       si.nMax  = infoPtr->maxVisibleOrder - 1;
+       if ( si.nPage )
+       {
+           si.nPos  = infoPtr->firstVisible->visibleOrder;
+           si.nMax  = infoPtr->maxVisibleOrder - 1;
 
-       SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
+           SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
 
-       if (!(infoPtr->uInternalStatus & TV_VSCROLL))
-           ShowScrollBar(hwnd, SB_VERT, TRUE);
-       infoPtr->uInternalStatus |= TV_VSCROLL;
+           if (!(infoPtr->uInternalStatus & TV_VSCROLL))
+               ShowScrollBar(hwnd, SB_VERT, TRUE);
+           infoPtr->uInternalStatus |= TV_VSCROLL;
+       }
+       else
+       {
+           if (infoPtr->uInternalStatus & TV_VSCROLL)
+               ShowScrollBar(hwnd, SB_VERT, FALSE);
+           infoPtr->uInternalStatus &= ~TV_VSCROLL;
+       }
     }
     else
     {


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.




More information about the wine-patches mailing list