From 21d5f3f4a1da9d3d7fcaadf1e84df6772c9b6a5d Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 23 Oct 2020 09:20:08 -0700 Subject: [PATCH] Avoid crash if wxMessageBox() is called before GTK is initialized See https://github.com/wxWidgets/wxWidgets/pull/2099 --- src/gtk/msgdlg.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gtk/msgdlg.cpp b/src/gtk/msgdlg.cpp index 3cc63658b9..5530d8bb5c 100644 --- a/src/gtk/msgdlg.cpp +++ b/src/gtk/msgdlg.cpp @@ -109,6 +109,10 @@ void wxMessageDialog::DoSetCustomLabel(wxString& var, const ButtonLabel& label) void wxMessageDialog::GTKCreateMsgDialog() { + // Avoid crash if wxMessageBox() is called before GTK is initialized + if (g_type_class_peek(GDK_TYPE_DISPLAY) == NULL) + return; + GtkWindow * const parent = m_parent ? GTK_WINDOW(m_parent->m_widget) : NULL; GtkMessageType type = GTK_MESSAGE_ERROR;