From 6a74af89fc2212010a7f8b1e35134688a210e12a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 7 Apr 2007 11:39:44 +0000 Subject: [PATCH] don't access the window after it had been deleted by the focus event handler (patch 1693063) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45294 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 17 +++++++++-------- src/mac/carbon/window.cpp | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 7311613839..4b64709e76 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1880,12 +1880,14 @@ gtk_window_focus_out_callback( GtkWidget *widget, } #endif // wxUSE_CARET - gboolean ret = FALSE; - // don't send the window a kill focus event if it thinks that it doesn't // have focus already if ( win->m_hasFocus ) { + // the event handler might delete the window when it loses focus, so + // check whether this is a custom window before calling it + const bool has_wxwindow = win->m_wxwindow != NULL; + win->m_hasFocus = false; wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() ); @@ -1893,14 +1895,13 @@ gtk_window_focus_out_callback( GtkWidget *widget, (void)win->GTKProcessEvent( event ); - ret = TRUE; + // Disable default focus handling for custom windows + // since the default GTK+ handler issues a repaint + if ( has_wxwindow ) + return TRUE; } - // Disable default focus handling for custom windows - // since the default GTK+ handler issues a repaint - if (win->m_wxwindow) - return ret; - + // continue with normal processing return FALSE; } diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index f66371e586..4d0829742d 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -334,6 +334,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl } #endif + if ( thisWindow->MacIsUserPane() ) + result = noErr ; + if ( controlPart == kControlFocusNoPart ) { #if wxUSE_CARET @@ -367,9 +370,6 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl event.SetEventObject(thisWindow); thisWindow->GetEventHandler()->ProcessEvent(event) ; } - - if ( thisWindow->MacIsUserPane() ) - result = noErr ; } break ; -- 2.47.2