[2/2] comctl32/listview: Block redrawing entirely after WM_SETREDRAW wParam=FALSE

Nikolay Sivov bunglehead at gmail.com
Wed Aug 12 04:57:27 CDT 2009


Always redrawing is harmless for selfcontained lists but in case of
LVS_OWNERDATA it could easily lead to crash (in app code not in control).
This case's described in http://bugs.winehq.org/show_bug.cgi?id=8421

Here application provided data is simply not ready when we're requesting
it for the first time, of course it shows not very reliable LVN_GETDISPINFO handler in
application itself, but the cause is that we shouldn't sent this notification at all.

Changelog:
    - Block redrawing entirely after WM_SETREDRAW wParam=FALSE

>From 3fe7d40e0509993a6c40db85be897f3270a8e6db Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Wed, 12 Aug 2009 13:42:15 +0400
Subject: Block redrawing entirely after WM_SETREDRAW wParam=FALSE

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

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index a65d832..9bca376 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -9740,6 +9740,8 @@ static LRESULT LISTVIEW_Paint(LISTVIEW_INFO *infoPtr, HDC hdc)
 {
     TRACE("(hdc=%p)\n", hdc);
 
+    if (!is_redrawing(infoPtr)) return 0;
+
     if (infoPtr->bNoItemMetrics && infoPtr->nItemCount)
     {
 	infoPtr->bNoItemMetrics = FALSE;
@@ -9790,7 +9792,13 @@ static LRESULT LISTVIEW_PrintClient(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD optio
         LISTVIEW_EraseBkgnd(infoPtr, hdc);
 
     if (options & PRF_CLIENT)
+    {
+        BOOL redraw_old = infoPtr->bRedraw;
+
+        infoPtr->bRedraw = TRUE;
         LISTVIEW_Paint(infoPtr, hdc);
+        infoPtr->bRedraw = redraw_old;
+    }
 
     return 0;
 }
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 516445c..fb90196 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2834,7 +2834,7 @@ static void test_setredraw(void)
     InvalidateRect(hwnd, NULL, TRUE);
     UpdateWindow(hwnd);
     ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
-                "redraw after WM_SETREDRAW (FALSE)", TRUE);
+                "redraw after WM_SETREDRAW (FALSE)", FALSE);
 
     ret = SendMessage(hwnd, LVM_SETBKCOLOR, 0, CLR_NONE);
     expect(TRUE, ret);
@@ -2842,7 +2842,7 @@ static void test_setredraw(void)
     InvalidateRect(hwnd, NULL, TRUE);
     UpdateWindow(hwnd);
     ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq,
-                "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", TRUE);
+                "redraw after WM_SETREDRAW (FALSE) with CLR_NONE bkgnd", FALSE);
 
     /* message isn't forwarded to header */
     subclass_header(hwnd);
-- 
1.5.6.5





More information about the wine-patches mailing list