From db9858a93c1ee71458603d5b97dccad95a955c15 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 15 Dec 2016 19:37:12 -0800 Subject: [PATCH] Allow initializing wxWidgets multiple times against one instance of GTK+ See #17751 --- src/gtk/settings.cpp | 21 +++++++++++++++++++++ src/gtk/win_gtk.cpp | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index ad5c244f51..19ee62ec70 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -14,6 +14,7 @@ #ifndef WX_PRECOMP #include "wx/toplevel.h" + #include "wx/module.h" #endif #include "wx/fontutil.h" @@ -1008,3 +1009,23 @@ bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) return false; } } + +#ifdef __WXGTK3__ +class wxSystemSettingsModule: public wxModule +{ +public: + virtual bool OnInit() wxOVERRIDE { return true; } + virtual void OnExit() wxOVERRIDE; + wxDECLARE_DYNAMIC_CLASS(wxSystemSettingsModule); +}; +wxIMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule); + +void wxSystemSettingsModule::OnExit() +{ + GtkSettings* settings = gtk_settings_get_default(); + g_signal_handlers_disconnect_by_func(settings, + (void*)notify_gtk_theme_name, NULL); + g_signal_handlers_disconnect_by_func(settings, + (void*)notify_gtk_font_name, NULL); +} +#endif diff --git a/src/gtk/win_gtk.cpp b/src/gtk/win_gtk.cpp index 6e13eeaa05..1617b0d31a 100644 --- a/src/gtk/win_gtk.cpp +++ b/src/gtk/win_gtk.cpp @@ -325,6 +325,10 @@ GType wxPizza::type() static GType type; if (type == 0) { + type = g_type_from_name("wxPizza"); + if (type) + return type; + const GTypeInfo info = { sizeof(wxPizzaClass), NULL, NULL,