X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0728199b911be9095406cf05059a5a180e707778..3ab6b7e64c3f3e0ad945976dad35677fdf41dd35:/src/gtk/app.cpp?ds=sidebyside diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 33cf2dc6a0..138f2eac56 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -7,12 +7,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __VMS -// vms_jackets.h should for proper working be included before anything else -# include -#undef ConnectionNumber -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -32,10 +26,13 @@ #include #endif -#include "wx/gtk/win_gtk.h" #include "wx/gtk/private.h" #include "wx/apptrait.h" +#if wxUSE_LIBHILDON + #include +#endif // wxUSE_LIBHILDON + #include //----------------------------------------------------------------------------- @@ -51,8 +48,6 @@ // global data //----------------------------------------------------------------------------- -bool g_mainThreadLocked = false; - static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; //----------------------------------------------------------------------------- @@ -221,31 +216,6 @@ bool wxApp::DoIdle() return false; } -#if wxUSE_THREADS - -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; -} -} - -#endif // wxUSE_THREADS - //----------------------------------------------------------------------------- // Access to the root window global //----------------------------------------------------------------------------- @@ -324,6 +294,15 @@ bool wxApp::OnInitGui() } } +#if wxUSE_LIBHILDON + m_hildonProgram = hildon_program_get_instance(); + if ( !m_hildonProgram ) + { + wxLogError(_("Unable to initialize Hildon program")); + return false; + } +#endif // wxUSE_LIBHILDON + return true; } @@ -350,10 +329,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) #if wxUSE_THREADS if (!g_thread_supported()) + { g_thread_init(NULL); - - wxgs_poll_func = g_main_context_get_poll_func(NULL); - g_main_context_set_poll_func(NULL, wxapp_poll_func); + gdk_threads_init(); + } #endif // wxUSE_THREADS // We should have the wxUSE_WCHAR_T test on the _outside_ @@ -400,10 +379,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) bool init_result; + int i; #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert - int i; char **argvGTK = new char *[argc_ + 1]; for ( i = 0; i < argc_; i++ ) { @@ -463,7 +442,7 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) wxArrayString opt, desc; m_traits->GetStandardCmdLineOptions(opt, desc); - for ( int i = 0; i < argc_; i++ ) + for ( i = 0; i < argc_; i++ ) { // leave just the names of the options with values const wxString str = wxString(argv_[i]).BeforeFirst('='); @@ -515,16 +494,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() @@ -570,3 +554,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