wxApp *wxTheApp = (wxApp *) NULL;
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
-extern wxResourceCache *wxTheResourceCache;
extern bool g_isIdle;
+bool g_mainThreadLocked = FALSE;
+
//-----------------------------------------------------------------------------
// local functions
//-----------------------------------------------------------------------------
-extern void wxFlushResources();
-
/* forward declaration */
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
void wxapp_install_idle_handler();
void wxWakeUpIdle()
{
+#if wxUSE_THREADS
+ if (!wxThread::IsMain())
+ wxMutexGuiEnter();
+#endif
+
if (g_isIdle)
wxapp_install_idle_handler();
+
+#if wxUSE_THREADS
+ if (!wxThread::IsMain())
+ wxMutexGuiLeave();
+#endif
}
//-----------------------------------------------------------------------------
{
if (!wxTheApp) return TRUE;
-#if (GTK_MINOR_VERSION > 0)
- /* when getting called from GDK's idle handler we
- are no longer within GDK's grab on the GUI
- thread so we must lock it here ourselves */
- GDK_THREADS_ENTER ();
-#endif
+ // when getting called from GDK's time-out handler
+ // we are no longer within GDK's grab on the GUI
+ // thread so we must lock it here ourselves
+ gdk_threads_enter();
/* sent idle event to all who request them */
while (wxTheApp->ProcessIdle()) { }
emptied */
g_isIdle = TRUE;
-#if (GTK_MINOR_VERSION > 0)
- /* release lock again */
- GDK_THREADS_LEAVE ();
-#endif
+ // release lock again
+ gdk_threads_leave();
return TRUE;
}
to the main thread (and processing these in
idle time). */
-#if wxUSE_THREADS
- if (!wxThread::IsMain())
- GDK_THREADS_ENTER ();
-#endif
-
wxTheApp->m_idleTag = gtk_idle_add( wxapp_idle_callback, (gpointer) NULL );
g_isIdle = FALSE;
-
-#if wxUSE_THREADS
- if (!wxThread::IsMain())
- GDK_THREADS_LEAVE ();
-#endif
}
#if wxUSE_THREADS
{
if (wxTheApp->m_wakeUpTimerTag) return;
- wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 100, wxapp_wakeup_timerout_callback, (gpointer) NULL );
+ wxTheApp->m_wakeUpTimerTag = gtk_timeout_add( 50, wxapp_wakeup_timerout_callback, (gpointer) NULL );
}
void wxapp_uninstall_thread_wakeup()
gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
{
- wxapp_uninstall_thread_wakeup();
-
-#if (GTK_MINOR_VERSION > 0)
// when getting called from GDK's time-out handler
// we are no longer within GDK's grab on the GUI
// thread so we must lock it here ourselves
- GDK_THREADS_ENTER ();
-#endif
+ gdk_threads_enter();
+
+ wxapp_uninstall_thread_wakeup();
// unblock other threads wishing to do some GUI things
wxMutexGuiLeave();
+
+ g_mainThreadLocked = TRUE;
// wake up other threads
wxUsleep( 1 );
// block other thread again
wxMutexGuiEnter();
-#if (GTK_MINOR_VERSION > 0)
- // release lock again
- GDK_THREADS_LEAVE ();
-#endif
+ g_mainThreadLocked = FALSE;
wxapp_install_thread_wakeup();
+ // release lock again
+ gdk_threads_leave();
+
return TRUE;
}
wxPendingEventsLocker = new wxCriticalSection();
#endif
-/*
- wxTheFontNameDirectory = new wxFontNameDirectory;
- wxTheFontNameDirectory->Initialize();
-*/
-
wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING );
wxTheColourDatabase->Initialize();
wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES
- wxTheResourceCache = new wxResourceCache( wxKEY_STRING );
-
wxInitializeResourceSystem();
#endif
wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES
- wxFlushResources();
-
- if (wxTheResourceCache)
- delete wxTheResourceCache;
- wxTheResourceCache = (wxResourceCache*) NULL;
-
wxCleanUpResourceSystem();
#endif
if (wxTheColourDatabase)
delete wxTheColourDatabase;
+
wxTheColourDatabase = (wxColourDatabase*) NULL;
-/*
- if (wxTheFontNameDirectory) delete wxTheFontNameDirectory;
- wxTheFontNameDirectory = (wxFontNameDirectory*) NULL;
-*/
-
wxDeleteStockObjects();
wxDeleteStockLists();
int wxEntry( int argc, char *argv[] )
{
+#if wxUSE_THREADS
+ g_thread_init(NULL);
+#endif
+
gtk_set_locale();
#if wxUSE_WCHAR_T
if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL;
#endif
+ gdk_threads_enter();
+
gtk_init( &argc, &argv );
wxSetDetectableAutoRepeat( TRUE );
if (!wxApp::Initialize())
+ {
+ gdk_threads_leave();
return -1;
+ }
if (!wxTheApp)
{
#if wxUSE_UNICODE
wxTheApp->argv = new wxChar*[argc+1];
int mb_argc = 0;
- while (mb_argc < argc) {
- wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
- mb_argc++;
+ while (mb_argc < argc)
+ {
+ wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc]));
+ mb_argc++;
}
wxTheApp->argv[mb_argc] = (wxChar *)NULL;
#else
wxApp::CleanUp();
+ gdk_threads_leave();
+
return retValue;
}