From e5a1a29e77884c8617f1c23efb2f374743097d6f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 11 Mar 2018 14:18:28 +0100 Subject: [PATCH] Fix wxGTK build with glib < 2.32 and streamline the code a bit Define g_signal_handlers_disconnect_by_data() if it's not available, i.e. when using glib older than 2.32 where it was added, to fix the build under old systems such as CentOS 6 broken by the changes of 8278f7b618af03ef9fdba6a9eab58f560c084961 (see #18084). Also use it elsewhere instead of g_signal_handlers_disconnect_matched() as it's more readable. Closes https://github.com/wxWidgets/wxWidgets/pull/760 --- docs/changes.txt | 4 ++++ include/wx/gtk/private/gtk2-compat.h | 8 ++++++++ src/gtk/menu.cpp | 6 ++---- src/gtk/webview_webkit2.cpp | 5 ++--- src/gtk/window.cpp | 3 +-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 73471219dd..423d79f114 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -71,6 +71,10 @@ All: - Make wxList and wxVector iterators conform to input iterator requirements. +wxGTK: + +- Fix the build with glib < 2.32 (e.g. CentOS 6). + wxMSW: - Fix hang after clearing wxTAB_TRAVERSAL style on a window with children. diff --git a/include/wx/gtk/private/gtk2-compat.h b/include/wx/gtk/private/gtk2-compat.h index cbdf38a392..e26938e40d 100644 --- a/include/wx/gtk/private/gtk2-compat.h +++ b/include/wx/gtk/private/gtk2-compat.h @@ -425,6 +425,14 @@ static inline void wx_gdk_cairo_set_source_window(cairo_t* cr, GdkWindow* window #define gdk_cairo_set_source_window wx_gdk_cairo_set_source_window #endif +// ---------------------------------------------------------------------------- +// the following were introduced in Glib 2.32 + +#ifndef g_signal_handlers_disconnect_by_data +#define g_signal_handlers_disconnect_by_data(instance, data) \ + g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) +#endif + // ---------------------------------------------------------------------------- // the following were introduced in GTK+ 3.0 diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 1b84b76807..9d164d06df 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -808,8 +808,7 @@ wxMenu::~wxMenu() // Destroying a menu generates a "hide" signal even if it's not shown // currently, so disconnect it to avoid dummy wxEVT_MENU_CLOSE events // generation. - g_signal_handlers_disconnect_matched(m_menu, - GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this); + g_signal_handlers_disconnect_by_data(m_menu, this); if (m_owner) { @@ -993,8 +992,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) GtkWidget * const mitem = item->GetMenuItem(); - g_signal_handlers_disconnect_matched(mitem, - GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, item); + g_signal_handlers_disconnect_by_data(mitem, item); #ifdef __WXGTK3__ gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL); diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index cc495dea75..81f9a9a667 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -589,9 +589,8 @@ wxWebViewWebKit::~wxWebViewWebKit() if (m_dbusServer) { g_dbus_server_stop(m_dbusServer); - g_signal_handlers_disconnect_matched( - webkit_web_context_get_default(), G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, m_dbusServer); + g_signal_handlers_disconnect_by_data( + webkit_web_context_get_default(), m_dbusServer); } g_clear_object(&m_dbusServer); g_clear_object(&m_extension); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 1f1c6244ec..e9397a2e42 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2675,8 +2675,7 @@ bool wxWindowGTK::Create( wxWindow *parent, void wxWindowGTK::GTKDisconnect(void* instance) { - g_signal_handlers_disconnect_matched(instance, - GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this); + g_signal_handlers_disconnect_by_data(instance, this); } wxWindowGTK::~wxWindowGTK()