]> git.saurik.com Git - wxWidgets.git/commitdiff
Retain/release the NSButtonCell during user action so that if the button
authorDavid Elliott <dfe@tgwbd.org>
Tue, 28 Dec 2004 01:40:03 +0000 (01:40 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Tue, 28 Dec 2004 01:40:03 +0000 (01:40 +0000)
is deleted by the user action the program does not crash sending
the setHighlighted:NO message to it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31158 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/cocoa/toolbar.mm

index 3688f0e7b370c308b9b26dd7d5d068e05c3bb6c1..30f61996fdff22b38d4408ab876a1ca1936f6913 100644 (file)
@@ -253,6 +253,7 @@ bool wxToolBar::Cocoa_mouseDragged(WX_NSEvent theEvent)
         NSButtonCell *buttonCell = m_mouseDownTool->GetNSButtonCell();
         if(buttonCell)
         {
         NSButtonCell *buttonCell = m_mouseDownTool->GetNSButtonCell();
         if(buttonCell)
         {
+            [buttonCell retain];
             [buttonCell setHighlighted: YES];
             if([buttonCell trackMouse: theEvent
                 inRect:AddToolPadding(m_mouseDownTool->GetFrameRect()) ofView:m_cocoaNSView
             [buttonCell setHighlighted: YES];
             if([buttonCell trackMouse: theEvent
                 inRect:AddToolPadding(m_mouseDownTool->GetFrameRect()) ofView:m_cocoaNSView
@@ -263,6 +264,7 @@ bool wxToolBar::Cocoa_mouseDragged(WX_NSEvent theEvent)
                 wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked after drag!"));
             }
             [buttonCell setHighlighted: NO];
                 wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked after drag!"));
             }
             [buttonCell setHighlighted: NO];
+            [buttonCell release];
         }
     }
     return wxToolBarBase::Cocoa_mouseDragged(theEvent);
         }
     }
     return wxToolBarBase::Cocoa_mouseDragged(theEvent);
@@ -276,6 +278,7 @@ bool wxToolBar::Cocoa_mouseDown(WX_NSEvent theEvent)
         NSButtonCell *buttonCell = tool->GetNSButtonCell();
         if(buttonCell)
         {
         NSButtonCell *buttonCell = tool->GetNSButtonCell();
         if(buttonCell)
         {
+            [buttonCell retain];
             m_mouseDownTool = tool;
             [buttonCell setHighlighted: YES];
             if([buttonCell trackMouse: theEvent
             m_mouseDownTool = tool;
             [buttonCell setHighlighted: YES];
             if([buttonCell trackMouse: theEvent
@@ -287,6 +290,7 @@ bool wxToolBar::Cocoa_mouseDown(WX_NSEvent theEvent)
                 wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked!"));
             }
             [buttonCell setHighlighted: NO];
                 wxLogTrace(wxTRACE_COCOA,wxT("Button was clicked!"));
             }
             [buttonCell setHighlighted: NO];
+            [buttonCell release];
         }
     }
     return wxToolBarBase::Cocoa_mouseDown(theEvent);
         }
     }
     return wxToolBarBase::Cocoa_mouseDown(theEvent);