From b48c46285c1fe2e82cd5aea3882155218aff1fe9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 Jan 2021 00:32:12 +0100 Subject: [PATCH] Avoid creating empty bitmap in MSW wxNotebook::OnPaint() It can apparently happen that the window has 0 size and in this creating the bitmap is useless and just triggers an assert. Closes #18879. --- src/msw/notebook.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index aef686b6a0..693b87e4c6 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -787,11 +787,13 @@ void wxNotebook::OnEraseBackground(wxEraseEvent& WXUNUSED(event)) void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); - wxMemoryDC memdc; RECT rc; ::GetClientRect(GetHwnd(), &rc); + if ( !rc.right || !rc.bottom ) + return; + wxBitmap bmp(rc.right, rc.bottom); - memdc.SelectObject(bmp); + wxMemoryDC memdc(bmp); const wxLayoutDirection dir = dc.GetLayoutDirection(); memdc.SetLayoutDirection(dir);