#import <Foundation/NSRunLoop.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSAutoreleasePool.h>
+#import <Foundation/NSThread.h>
// ----------------------------------------------------------------------------
// globals
{
wxASSERT(wxTheApp);
wxLogDebug("doIdle called");
- NSRunLoop *rl = [NSRunLoop currentRunLoop];
- // runMode: beforeDate returns YES if something was done
- while(wxTheApp->ProcessIdle()) // FIXME: AND NO EVENTS ARE PENDING
+#ifdef __WXDEBUG__
+ if(wxTheApp->IsInAssert())
{
- wxLogDebug("Looping for idle events");
- #if 1
- if( [rl runMode:[rl currentMode] beforeDate:[NSDate distantPast]])
+ wxLogDebug("Idle events ignored durring assertion dialog");
+ }
+ else
+#endif
+ {
+ NSRunLoop *rl = [NSRunLoop currentRunLoop];
+ // runMode: beforeDate returns YES if something was done
+ while(wxTheApp->ProcessIdle()) // FIXME: AND NO EVENTS ARE PENDING
{
- wxLogDebug("Found actual work to do");
- break;
+ wxLogDebug("Looping for idle events");
+ #if 1
+ if( [rl runMode:[rl currentMode] beforeDate:[NSDate distantPast]])
+ {
+ wxLogDebug("Found actual work to do");
+ break;
+ }
+ #endif
}
- #endif
}
wxLogDebug("Idle processing complete, requesting next idle event");
// Add ourself back into the run loop (on next event) if necessary
bool wxApp::Initialize(int& argc, wxChar **argv)
{
wxAutoNSAutoreleasePool pool;
+ m_cocoaMainThread = [NSThread currentThread];
// Mac OS X passes a process serial number command line argument when
// the application is launched from the Finder. This argument must be
// removed from the command line arguments before being handled by the
wxApp::wxApp()
{
m_topWindow = NULL;
- wxTheApp = this;
m_isIdle = true;
#if WXWIN_COMPATIBILITY_2_2
m_wantDebugOutput = TRUE;
#endif
+#ifdef __WXDEBUG__
+ m_isInAssert = FALSE;
+#endif // __WXDEBUG__
+
argc = 0;
argv = NULL;
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(![m_cocoaApp isRunning])
return;
return true;
}
+#ifdef __WXDEBUG__
+void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg)
+{
+ m_isInAssert = TRUE;
+ wxAppBase::OnAssert(file, line, cond, msg);
+ m_isInAssert = FALSE;
+}
+#endif // __WXDEBUG__
+