Fix empty bitmap issue

Fix: invalidate best size cache that is used in newer wxWidgets versions
This commit is contained in:
Twan van Laarhoven
2020-04-10 16:56:07 +02:00
parent 9e6cfe9b7e
commit be9bae942e
+4
View File
@@ -56,6 +56,7 @@ void CardViewer::redraw() {
}
void CardViewer::onChangeSize() {
InvalidateBestSize();
wxSize ws = GetSize(), cs = GetClientSize();
wxSize desired_cs = (wxSize)getRotation().getExternalSize() + ws - cs;
if (desired_cs != cs) {
@@ -78,6 +79,9 @@ void CardViewer::onPaint(wxPaintEvent&) {
WITH_DYNAMIC_ARG(inOnPaint, true);
#endif
wxSize cs = GetClientSize();
if (cs.GetWidth() == 0 || cs.GetHeight() == 0) {
return; // empty bitmaps are not allowed because some idiots think that 0 is not a number
}
if (!buffer.Ok() || buffer.GetWidth() != cs.GetWidth() || buffer.GetHeight() != cs.GetHeight()) {
buffer = Bitmap(cs.GetWidth(), cs.GetHeight());
up_to_date = false;