Commit ab2cac48 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Fix handling of NULL paint struct in BeginPaint.

parent c1157b79
......@@ -893,20 +893,28 @@ static HWND fix_caret(HWND hWnd, const RECT *scroll_rect, INT dx, INT dy,
HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
{
HRGN hrgn;
HDC hdc;
BOOL erase;
RECT rect;
UINT flags = UPDATE_NONCLIENT | UPDATE_ERASE | UPDATE_PAINT | UPDATE_INTERNALPAINT | UPDATE_NOCHILDREN;
if (!lps) return 0;
HideCaret( hwnd );
if (!(hrgn = send_ncpaint( hwnd, NULL, &flags ))) return 0;
lps->fErase = send_erase( hwnd, flags, hrgn, &lps->rcPaint, &lps->hdc );
erase = send_erase( hwnd, flags, hrgn, &rect, &hdc );
TRACE("hdc = %p box = (%s), fErase = %d\n",
lps->hdc, wine_dbgstr_rect(&lps->rcPaint), lps->fErase);
TRACE("hdc = %p box = (%s), fErase = %d\n", hdc, wine_dbgstr_rect(&rect), erase);
return lps->hdc;
if (!lps)
{
release_dc( hwnd, hdc, TRUE );
return 0;
}
lps->fErase = erase;
lps->rcPaint = rect;
lps->hdc = hdc;
return hdc;
}
......@@ -915,10 +923,10 @@ HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
*/
BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
{
if (!lps) return FALSE;
release_dc( hwnd, lps->hdc, TRUE );
ShowCaret( hwnd );
flush_window_surfaces( FALSE );
if (!lps) return FALSE;
release_dc( hwnd, lps->hdc, TRUE );
return TRUE;
}
......
......@@ -9093,6 +9093,26 @@ static void test_DispatchMessage(void)
if (++count > 10) break;
}
}
flush_sequence();
RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE|RDW_ERASE|RDW_FRAME );
count = 0;
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
{
if (msg.message != WM_PAINT) DispatchMessage( &msg );
else
{
HDC hdc;
flush_sequence();
hdc = BeginPaint( hwnd, NULL );
ok( !hdc, "got valid hdc %p from BeginPaint\n", hdc );
ok( !EndPaint( hwnd, NULL ), "EndPaint succeeded\n" );
ok_sequence( WmDispatchPaint, "WmDispatchPaint", FALSE );
ok( !count, "Got multiple WM_PAINTs\n" );
if (++count > 10) break;
}
}
DestroyWindow(hwnd);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment