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