pull up r19859 from trunk
authorTom Yu <tlyu@mit.edu>
Fri, 28 Sep 2007 23:37:34 +0000 (23:37 +0000)
committerTom Yu <tlyu@mit.edu>
Fri, 28 Sep 2007 23:37:34 +0000 (23:37 +0000)
 r19859@cathode-dark-space:  jaltman | 2007-08-24 10:37:07 -0400
 ticket: new
 subject: NIM: Handle WM_PAINT messages without update regions
 component: windows

 It is possible to receive a WM_PAINT message in Windows without there
 being an update region.  For example, this can be caused by someone
 calling RedrawWindow() with the RDW_INTERNALPAINT flag set.  In this
 case, GetUpdateRect() will indicate that there is no update region and
 calling BeginPaint()/EndPaint() results in incorrect behavior.

 The credentials window in Network Identity Manager needs to perform
 special handling for this case by obtaining a proper device context
 and completing the drawing operation.

ticket: 5680
version_fixed: 1.6.3

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19994 dc483132-0cff-0310-8789-dd5450dbe970

src/windows/identity/ui/credwnd.c

index ed9cad735aa5e9f0b6af41ac717308674b7dc052..222d3038a89f9263469a4b51c3059ce53250a5c7 100644 (file)
@@ -3127,6 +3127,7 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     int selected = 0;
     int rowheight = 0;
     BOOL has_dc = FALSE;
+    BOOL has_updaterect = TRUE;
 
     tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);
     if (tbl == NULL)
@@ -3140,15 +3141,16 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
         has_dc = TRUE;
     }
 
-    if(!has_dc && !GetUpdateRect(hwnd, &r, FALSE)) {
-#ifdef DEBUG
-        assert(FALSE);
-#endif
-        goto _exit;
+    if (!has_dc && !GetUpdateRect(hwnd, &r, FALSE)) {
+        has_updaterect = FALSE;
     }
 
-    if (!has_dc)
-        hdc = BeginPaint(hwnd, &ps);
+    if (!has_dc) {
+        if (has_updaterect)
+            hdc = BeginPaint(hwnd, &ps);
+        else
+            hdc = GetDC(hwnd);
+    }
 
     if(tbl->hf_normal)
         hf_old = SelectFont(hdc, tbl->hf_normal);
@@ -3377,8 +3379,12 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
     if(tbl->hf_normal)
         SelectFont(hdc, hf_old);
 
-    if (!has_dc)
-        EndPaint(hwnd,&ps);
+    if (!has_dc) {
+        if (has_updaterect)
+            EndPaint(hwnd,&ps);
+        else
+            ReleaseDC(hwnd, hdc);
+    }
 
  _exit:
     return TRUE;