From: David Elliott Date: Tue, 28 Dec 2004 01:40:03 +0000 (+0000) Subject: Retain/release the NSButtonCell during user action so that if the button X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c81dc3db6b242e6c47782ff205230c3e22060e95 Retain/release the NSButtonCell during user action so that if the button 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 --- diff --git a/src/cocoa/toolbar.mm b/src/cocoa/toolbar.mm index 3688f0e7b3..30f61996fd 100644 --- a/src/cocoa/toolbar.mm +++ b/src/cocoa/toolbar.mm @@ -253,6 +253,7 @@ bool wxToolBar::Cocoa_mouseDragged(WX_NSEvent theEvent) NSButtonCell *buttonCell = m_mouseDownTool->GetNSButtonCell(); if(buttonCell) { + [buttonCell retain]; [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]; + [buttonCell release]; } } return wxToolBarBase::Cocoa_mouseDragged(theEvent); @@ -276,6 +278,7 @@ bool wxToolBar::Cocoa_mouseDown(WX_NSEvent theEvent) NSButtonCell *buttonCell = tool->GetNSButtonCell(); if(buttonCell) { + [buttonCell retain]; 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]; + [buttonCell release]; } } return wxToolBarBase::Cocoa_mouseDown(theEvent);