From: Vadim Zeitlin Date: Wed, 15 May 2013 13:05:45 +0000 (+0000) Subject: Fix crash in wxGTK wxPopupWindow when creating it without parent. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/b561290c3aa6d8009e4770526b3286d16c905ce9 Fix crash in wxGTK wxPopupWindow when creating it without parent. Popup windows don't necessarily have a parent, so don't crash if parent pointer is NULL in wxPopupWindow::Create(). Closes #15173. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/gtk/popupwin.cpp b/src/gtk/popupwin.cpp index 878798abb9..464e0d40b1 100644 --- a/src/gtk/popupwin.cpp +++ b/src/gtk/popupwin.cpp @@ -109,21 +109,26 @@ bool wxPopupWindow::Create( wxWindow *parent, int style ) // wxPopupWindow is used for different windows as well // gtk_window_set_type_hint( GTK_WINDOW(m_widget), GDK_WINDOW_TYPE_HINT_COMBO ); - GtkWidget *toplevel = gtk_widget_get_toplevel( parent->m_widget ); - if (GTK_IS_WINDOW (toplevel)) + // Popup windows can be created without parent, so handle this correctly. + if (parent) { + GtkWidget *toplevel = gtk_widget_get_toplevel( parent->m_widget ); + if (GTK_IS_WINDOW (toplevel)) + { #if GTK_CHECK_VERSION(2,10,0) #ifndef __WXGTK3__ - if (!gtk_check_version(2,10,0)) + if (!gtk_check_version(2,10,0)) #endif - { - gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (m_widget)); - } + { + gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)), GTK_WINDOW (m_widget)); + } #endif - gtk_window_set_transient_for (GTK_WINDOW (m_widget), GTK_WINDOW (toplevel)); + gtk_window_set_transient_for (GTK_WINDOW (m_widget), GTK_WINDOW (toplevel)); + } + gtk_window_set_screen (GTK_WINDOW (m_widget), gtk_widget_get_screen (GTK_WIDGET (parent->m_widget))); } + gtk_window_set_resizable (GTK_WINDOW (m_widget), FALSE); - gtk_window_set_screen (GTK_WINDOW (m_widget), gtk_widget_get_screen (GTK_WIDGET (parent->m_widget))); g_signal_connect (m_widget, "delete_event", G_CALLBACK (gtk_dialog_delete_callback), this);