Remove sm_cocoaDelegate singleton. We need per-instance data anyway so we
may as well make it the target instead of the userInfo. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35942 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,7 +40,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
WX_NSTimer m_cocoaNSTimer;
|
WX_NSTimer m_cocoaNSTimer;
|
||||||
static const wxObjcAutoRefFromAlloc<struct objc_object *> sm_cocoaDelegate;
|
|
||||||
|
|
||||||
DECLARE_ABSTRACT_CLASS(wxTimer)
|
DECLARE_ABSTRACT_CLASS(wxTimer)
|
||||||
};
|
};
|
||||||
|
@@ -36,16 +36,6 @@
|
|||||||
|
|
||||||
IMPLEMENT_CLASS(wxTimer, wxTimerBase)
|
IMPLEMENT_CLASS(wxTimer, wxTimerBase)
|
||||||
|
|
||||||
// ========================================================================
|
|
||||||
// wxNSTimerDelegate
|
|
||||||
// ========================================================================
|
|
||||||
@interface wxNSTimerDelegate : NSObject
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)onNotify:(NSTimer *)theTimer;
|
|
||||||
@end // interface wxNSTimerDelegate : NSObject
|
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// wxNSTimerData
|
// wxNSTimerData
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
@@ -57,6 +47,7 @@ IMPLEMENT_CLASS(wxTimer, wxTimerBase)
|
|||||||
- (id)init;
|
- (id)init;
|
||||||
- (id)initWithWxTimer:(wxTimer*)theTimer;
|
- (id)initWithWxTimer:(wxTimer*)theTimer;
|
||||||
- (wxTimer*)timer;
|
- (wxTimer*)timer;
|
||||||
|
- (void)onNotify:(NSTimer *)theTimer;
|
||||||
@end // interface wxNSTimerData : NSObject
|
@end // interface wxNSTimerData : NSObject
|
||||||
|
|
||||||
@implementation wxNSTimerData : NSObject
|
@implementation wxNSTimerData : NSObject
|
||||||
@@ -80,13 +71,10 @@ IMPLEMENT_CLASS(wxTimer, wxTimerBase)
|
|||||||
{
|
{
|
||||||
return m_timer;
|
return m_timer;
|
||||||
}
|
}
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation wxNSTimerDelegate : NSObject
|
|
||||||
- (void)onNotify:(NSTimer *)theTimer
|
- (void)onNotify:(NSTimer *)theTimer
|
||||||
{
|
{
|
||||||
wxNSTimerData* theData = [theTimer userInfo];
|
m_timer->Notify(); //wxTimerBase method
|
||||||
[theData timer]->Notify(); //wxTimerBase method
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -94,8 +82,6 @@ IMPLEMENT_CLASS(wxTimer, wxTimerBase)
|
|||||||
// wxTimer
|
// wxTimer
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
const wxObjcAutoRefFromAlloc<struct objc_object*> wxTimer::sm_cocoaDelegate = [[wxNSTimerDelegate alloc] init];
|
|
||||||
|
|
||||||
wxTimer::~wxTimer()
|
wxTimer::~wxTimer()
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
@@ -112,14 +98,14 @@ bool wxTimer::Start(int millisecs, bool oneShot)
|
|||||||
|
|
||||||
wxAutoNSAutoreleasePool thePool;
|
wxAutoNSAutoreleasePool thePool;
|
||||||
|
|
||||||
wxNSTimerData *userInfo = [[wxNSTimerData alloc] initWithWxTimer:this];
|
wxNSTimerData *timerData = [[wxNSTimerData alloc] initWithWxTimer:this];
|
||||||
m_cocoaNSTimer = [[NSTimer
|
m_cocoaNSTimer = [[NSTimer
|
||||||
scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds
|
scheduledTimerWithTimeInterval: millisecs / 1000.0 //seconds
|
||||||
target: wxTimer::sm_cocoaDelegate
|
target: timerData
|
||||||
selector: @selector(onNotify:)
|
selector: @selector(onNotify:)
|
||||||
userInfo: userInfo
|
userInfo: nil
|
||||||
repeats: oneShot == false] retain];
|
repeats: oneShot == false] retain];
|
||||||
[userInfo release];
|
[timerData release];
|
||||||
|
|
||||||
return IsRunning();
|
return IsRunning();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user