From fa8a793a6ffea7e83559f89fa3a32e169ebc672c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 4 Feb 2002 19:37:02 +0000 Subject: [PATCH] fixed crash when return is pressed in a spinctrl inside a parent which is not a GtkWindow git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14002 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/spinctrl.cpp | 16 ++++++++++++---- src/gtk1/spinctrl.cpp | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 0b9e68f89e..c2091178b6 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -259,12 +259,20 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->GetParent()->IsTopLevel())) top_frame = top_frame->GetParent(); - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - if (window->default_widget) + if ( GTK_IS_WINDOW(top_frame->m_widget) ) { - gtk_widget_activate (window->default_widget); - return; + GtkWindow *window = GTK_WINDOW(top_frame->m_widget); + if ( window ) + { + GtkWidget *widgetDef = window->default_widget; + + if ( widgetDef && GTK_IS_WINDOW(widgetDef) ) + { + gtk_widget_activate(widgetDef); + return; + } + } } } diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index 0b9e68f89e..c2091178b6 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -259,12 +259,20 @@ void wxSpinCtrl::OnChar( wxKeyEvent &event ) wxWindow *top_frame = m_parent; while (top_frame->GetParent() && !(top_frame->GetParent()->IsTopLevel())) top_frame = top_frame->GetParent(); - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - if (window->default_widget) + if ( GTK_IS_WINDOW(top_frame->m_widget) ) { - gtk_widget_activate (window->default_widget); - return; + GtkWindow *window = GTK_WINDOW(top_frame->m_widget); + if ( window ) + { + GtkWidget *widgetDef = window->default_widget; + + if ( widgetDef && GTK_IS_WINDOW(widgetDef) ) + { + gtk_widget_activate(widgetDef); + return; + } + } } } -- 2.47.2