X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2fcd7f64a536513f8c8e3ecfac51c0a9ed7f92b7..f60b1d829dd8a6d5e47a2adcd3690acb3bd10150:/src/cocoa/timer.mm?ds=sidebyside diff --git a/src/cocoa/timer.mm b/src/cocoa/timer.mm index ad99c3227a..9cef73ce20 100644 --- a/src/cocoa/timer.mm +++ b/src/cocoa/timer.mm @@ -26,6 +26,8 @@ #include "wx/timer.h" #endif +#include "wx/cocoa/autorelease.h" + #import // ============================================================================ @@ -94,6 +96,10 @@ void wxTimer::Init() bool wxTimer::Start(int millisecs, bool oneShot) { + Stop(); + + wxAutoNSAutoreleasePool thePool; + m_cocoaNSTimer = [[NSTimer scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds target: wxTimer::sm_cocoaDelegate @@ -108,9 +114,11 @@ void wxTimer::Stop() { if (m_cocoaNSTimer) { + NSObject* theUserInfo = [m_cocoaNSTimer userInfo]; [m_cocoaNSTimer invalidate]; - [[m_cocoaNSTimer userInfo] release]; + [theUserInfo release]; [m_cocoaNSTimer release]; + m_cocoaNSTimer = NULL; } }