From acf2f9ef1f6fb33fc529701a8e94adc8dc52dbeb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 30 Oct 2019 14:18:13 +0100 Subject: [PATCH] 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. --- src/x11/window.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/x11/window.cpp b/src/x11/window.cpp index a48921ee4b..a83d2d33a1 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -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 );