]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixes a rare crash.
authorRobert Roebling <robert@roebling.de>
Fri, 31 Dec 2004 10:22:32 +0000 (10:22 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 31 Dec 2004 10:22:32 +0000 (10:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/toplevel.cpp

index ee145443cc0aa0c9133c99db8ea007ba40940444..89ef280b1a7ba145d40c226db166206a9bf36d96 100644 (file)
@@ -506,6 +506,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
     else if ( currentMouseWindow )
     {
         currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ;
+        wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent();
         
         wxevent.SetEventObject( currentMouseWindow ) ;
 
@@ -547,6 +548,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
     #endif
                     HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation ,
                         modifiers , (ControlActionUPP ) -1 ) ;
+                        
+                    // We need to handle the rare case that the control to
+                    // which the currentMouseWindow points gets deleted as
+                    // a reaction to HandleControlClick. This would lead to
+                    // a crash in the update cursor code below.
+                    if (!currentMouseWindowParent->GetChildren().Find( currentMouseWindow ))
+                        currentMouseWindow = NULL;
                 }
                 result = noErr ;
             }
@@ -566,7 +574,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev
         {
             cursorTarget = cursorTarget->GetParent() ;
             if ( cursorTarget )
-                cursorPoint += cursorTarget->GetPosition() ;
+                cursorPoint += cursorTarget->GetPosition();
         }
 
     } // else if ( currentMouseWindow )