From f45fe496c02241117732f35c547872981d59fe79 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 3 Sep 2021 00:38:30 +0200 Subject: [PATCH] Fix crash in wxOSX when calling Disable() before Create() This is explicitly allowed and we even have a unit test checking for this, but the test crashed under macOS. Fix this by simply doing nothing in wxWindow::DoEnable() if the window is not created yet. --- src/osx/window_osx.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index bca9a12ddb..d03e3b2467 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1269,6 +1269,11 @@ bool wxWindowMac::OSXShowWithEffect(bool show, void wxWindowMac::DoEnable(bool enable) { + // We can be called before the window is created in order to create it in + // the initially disabled state. + if ( !GetPeer() ) + return; + GetPeer()->Enable( enable ) ; MacInvalidateBorders(); }