From 5ba1ba1162b51a838f4fe2cbfae6b7bdff583ce6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 9 Dec 2018 01:15:08 +0100 Subject: [PATCH] Fix creating disabled windows in wxGTK too Don't forbid calling Enable() before creating the window and just do nothing in this case and do disable the window when it's actually created if it's supposed to be disabled. Note that this doesn't work for classes overriding Enable() directly, such as wxButton or wxCheckBox, currently. --- src/gtk/window.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index e440422ab7..32340aaa62 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2913,6 +2913,11 @@ void wxWindowGTK::PostCreation() SetLayoutDirection(wxLayout_Default); + // if the window had been disabled before being created, it should be + // created in the initially disabled state + if ( !m_isEnabled ) + DoEnable(false); + // unless the window was created initially hidden (i.e. Hide() had been // called before Create()), we should show it at GTK+ level as well if (m_isShown) @@ -4196,7 +4201,12 @@ bool wxWindowGTK::IsShown() const void wxWindowGTK::DoEnable( bool enable ) { - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); + if ( !m_widget ) + { + // The window can be disabled before being created, so just don't do + // anything in this case and, in particular, don't assert. + return; + } gtk_widget_set_sensitive( m_widget, enable ); if (m_wxwindow && (m_wxwindow != m_widget))