]> git.saurik.com Git - wxWidgets.git/commitdiff
don't access the window after it had been deleted by the focus event handler (patch...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 11:39:44 +0000 (11:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 7 Apr 2007 11:39:44 +0000 (11:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45294 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp
src/mac/carbon/window.cpp

index 731161383936942929852d8835e025bfde42ba15..4b64709e76a171d8068d92da670affd4adaa32b0 100644 (file)
@@ -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;
 }
 
index f66371e586076e81be75a3ae8fe7e7f1b4bf6197..4d0829742dfb89cd151a1f59d81d6bc54f09154e 100644 (file)
@@ -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 ;