Fix assert in wxWindowX11::SetBackgroundColour(wxColour())

Setting invalid colour is supposed to work and reset the background to
the default one, but asserted and then crashed due to triggering another
assert while trying to repaint the window while the assert dialog was
shown, in wxX11.

Fix this in the most expedient way by just resetting the background
colour to its initial value.

A better fix would be to leave it invalid but provide an accessor
returning the default value if the background colour is not defined.
This commit is contained in:
Vadim Zeitlin
2019-10-30 14:18:13 +01:00
parent d076859040
commit acf2f9ef1f

View File

@@ -1653,7 +1653,14 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Window WXUNUSED(win
bool wxWindowX11::SetBackgroundColour(const wxColour& col)
{
wxWindowBase::SetBackgroundColour(col);
if ( !wxWindowBase::SetBackgroundColour(col) )
return false;
if ( !m_backgroundColour.IsOk() )
{
// Reset to the default colour as we must have a valid background.
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
}
Display *xdisplay = (Display*) wxGlobalDisplay();
int xscreen = DefaultScreen( xdisplay );