Do not try to create bitmap for default constructed Caret

If a Caret is default-constructed, the width and height are still 0,
and the wxBitmap::Create implementations expect valid sizes.

The same applies for the bitmap after a size change.
This commit is contained in:
Stefan Brüns
2020-07-31 16:36:50 +02:00
parent b9f946fcd3
commit d87abd132e

View File

@@ -103,7 +103,8 @@ void wxCaret::InitGeneric()
#ifndef wxHAS_CARET_USING_OVERLAYS
m_xOld =
m_yOld = -1;
m_bmpUnderCaret.Create(m_width, m_height);
if (m_width && m_height)
m_bmpUnderCaret.Create(m_width, m_height);
#endif
}
@@ -174,7 +175,10 @@ void wxCaret::DoSize()
m_overlay.Reset();
#else
// Change bitmap size
m_bmpUnderCaret = wxBitmap(m_width, m_height);
if (m_width && m_height)
m_bmpUnderCaret = wxBitmap(m_width, m_height);
else
m_bmpUnderCaret = wxBitmap();
#endif
if (countVisible > 0)
{