X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2f3bc41106f177e3d4ab717961c1a2469abdbef..3adadab4828192deaae9ec74748585ca127271e5:/src/gtk/app.cpp?ds=inline diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 12b3f4dfdd..a8671dbf3d 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -225,18 +225,12 @@ static GPollFunc wxgs_poll_func; extern "C" { static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) { - gdk_threads_enter(); - - wxMutexGuiLeave(); g_mainThreadLocked = true; gint res = (*wxgs_poll_func)(ufds, nfds, timeout); - wxMutexGuiEnter(); g_mainThreadLocked = false; - gdk_threads_leave(); - return res; } } @@ -356,7 +350,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) #if wxUSE_THREADS if (!g_thread_supported()) + { g_thread_init(NULL); + gdk_threads_init(); + } wxgs_poll_func = g_main_context_get_poll_func(NULL); g_main_context_set_poll_func(NULL, wxapp_poll_func); @@ -521,16 +518,21 @@ void wxApp::CleanUp() { if (m_idleSourceId != 0) g_source_remove(m_idleSourceId); -#if wxUSE_THREADS - delete m_idleMutex; - m_idleMutex = NULL; -#endif + // release reference acquired by Initialize() g_type_class_unref(g_type_class_peek(GTK_TYPE_WIDGET)); gdk_threads_leave(); wxAppBase::CleanUp(); + + // delete this mutex as late as possible as it's used from WakeUpIdle(), in + // particular do it after calling the base class CleanUp() which can result + // in it being called +#if wxUSE_THREADS + delete m_idleMutex; + m_idleMutex = NULL; +#endif } void wxApp::WakeUpIdle() @@ -576,3 +578,15 @@ void wxApp::OnAssertFailure(const wxChar *file, } #endif // __WXDEBUG__ + +#if wxUSE_THREADS +void wxGUIAppTraits::MutexGuiEnter() +{ + gdk_threads_enter(); +} + +void wxGUIAppTraits::MutexGuiLeave() +{ + gdk_threads_leave(); +} +#endif // wxUSE_THREADS