Don't install idle event handler in secondary threads.
I've not seen this happen yet, but it can, and I'm taking this precaution. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22625 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,6 +34,7 @@ public:
|
|||||||
inline void CocoaRequestIdle() { m_isIdle = true; }
|
inline void CocoaRequestIdle() { m_isIdle = true; }
|
||||||
protected:
|
protected:
|
||||||
WX_NSApplication m_cocoaApp;
|
WX_NSApplication m_cocoaApp;
|
||||||
|
WX_NSThread m_cocoaMainThread;
|
||||||
void CocoaInstallIdleHandler();
|
void CocoaInstallIdleHandler();
|
||||||
bool m_isIdle;
|
bool m_isIdle;
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#import <Foundation/NSRunLoop.h>
|
#import <Foundation/NSRunLoop.h>
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
#import <Foundation/NSAutoreleasePool.h>
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
|
#import <Foundation/NSThread.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// globals
|
// globals
|
||||||
@@ -133,6 +134,7 @@ END_EVENT_TABLE()
|
|||||||
bool wxApp::Initialize(int& argc, wxChar **argv)
|
bool wxApp::Initialize(int& argc, wxChar **argv)
|
||||||
{
|
{
|
||||||
wxAutoNSAutoreleasePool pool;
|
wxAutoNSAutoreleasePool pool;
|
||||||
|
m_cocoaMainThread = [NSThread currentThread];
|
||||||
// Mac OS X passes a process serial number command line argument when
|
// Mac OS X passes a process serial number command line argument when
|
||||||
// the application is launched from the Finder. This argument must be
|
// the application is launched from the Finder. This argument must be
|
||||||
// removed from the command line arguments before being handled by the
|
// removed from the command line arguments before being handled by the
|
||||||
@@ -181,6 +183,12 @@ wxApp::wxApp()
|
|||||||
|
|
||||||
void wxApp::CocoaInstallIdleHandler()
|
void wxApp::CocoaInstallIdleHandler()
|
||||||
{
|
{
|
||||||
|
// If we're not the main thread, don't install the idle handler
|
||||||
|
if(m_cocoaMainThread != [NSThread currentThread])
|
||||||
|
{
|
||||||
|
wxLogDebug("Attempt to install idle handler from secondary thread");
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If we're supposed to be stopping, don't add more idle events
|
// If we're supposed to be stopping, don't add more idle events
|
||||||
if(![m_cocoaApp isRunning])
|
if(![m_cocoaApp isRunning])
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user