X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2fcd7f64a536513f8c8e3ecfac51c0a9ed7f92b7..09d350c0bc105653e7cd59a8290684a3c4e70d7e:/src/cocoa/timer.mm 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; } }