From ec824f7e8d3e8b3465309cda0ff28a25d2d909c9 Mon Sep 17 00:00:00 2001
From: Phil Rosenberg
Date: Tue, 15 Dec 2015 00:27:31 +0000
Subject: [PATCH] Avoid asserts when drawing zero-size wxStaticBox in wxMSW
If a wxStaticBox is rendered, but has zero size in either dimension we
generate assert failures when creating the bitmap. Check for these conditions
and just do not render if this is the case.
Closes #17288.
---
src/msw/statbox.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp
index b3755c90f5..56fe236fac 100644
--- a/src/msw/statbox.cpp
+++ b/src/msw/statbox.cpp
@@ -507,6 +507,11 @@ void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event))
::GetClientRect(GetHwnd(), &rc);
wxPaintDC dc(this);
+ // No need to do anything if the client rectangle is empty and, worse,
+ // doing it would result in an assert when creating the bitmap below.
+ if ( !rc.right || !rc.bottom )
+ return;
+
// draw the entire box in a memory DC
wxMemoryDC memdc(&dc);
wxBitmap bitmap(rc.right, rc.bottom);