X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/165d3652ffb8399626c37e0f65b50560a1369bc5..c6a6bbbf637a5a580b7ab182483d27522f5e3189:/src/gtk/app.cpp diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 97438c2575..fa47355e8f 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -209,7 +209,7 @@ static gint wxapp_idle_callback( gpointer WXUNUSED(data) ) // Release lock again gdk_threads_leave(); - + { // If another idle source was added, remove it #if wxUSE_THREADS @@ -247,12 +247,18 @@ 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; } } @@ -397,19 +403,17 @@ GdkVisual *wxApp::GetGdkVisual() bool wxApp::Initialize(int& argc, wxChar **argv) { - bool init_result; + if ( !wxAppBase::Initialize(argc, argv) ) + return false; #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); #endif // wxUSE_THREADS - gtk_set_locale(); - // We should have the wxUSE_WCHAR_T test on the _outside_ #if wxUSE_WCHAR_T // gtk+ 2.0 supports Unicode through UTF-8 strings @@ -442,10 +446,19 @@ bool wxApp::Initialize(int& argc, wxChar **argv) #else if (encName.empty()) encName = _T("UTF-8"); + + // if wxUSE_INTL==0 it probably indicates that only "C" locale is supported + // by the program anyhow so prevent GTK+ from calling setlocale(LC_ALL, "") + // from gtk_init_check() as it does by default + gtk_disable_setlocale(); + #endif // wxUSE_INTL static wxConvBrokenFileNames fileconv(encName); wxConvFileName = &fileconv; + + bool init_result; + #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert int i; @@ -473,7 +486,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv) { while ( strcmp(wxConvUTF8.cWX2MB(argv[i]), argvGTK[i]) != 0 ) { - memmove(argv + i, argv + i + 1, argc - i); + memmove(argv + i, argv + i + 1, (argc - i)*sizeof(*argv)); } } @@ -502,13 +515,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) // we can not enter threads before gtk_init is done gdk_threads_enter(); - if ( !wxAppBase::Initialize(argc, argv) ) - { - gdk_threads_leave(); - - return false; - } - wxSetDetectableAutoRepeat( true ); #if wxUSE_INTL @@ -557,15 +563,3 @@ void wxApp::SuspendIdleCallback() wxAddEmissionHook(); } } - -#if wxUSE_THREADS -void wxMutexGuiEnter() -{ - gdk_threads_enter(); -} - -void wxMutexGuiLeave() -{ - gdk_threads_leave(); -} -#endif