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
8278f7b618 (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
This commit is contained in:
Vadim Zeitlin
2018-03-11 14:18:28 +01:00
parent 78ad6ef561
commit e5a1a29e77
5 changed files with 17 additions and 9 deletions

View File

@@ -71,6 +71,10 @@ All:
- Make wxList and wxVector iterators conform to input iterator requirements. - Make wxList and wxVector iterators conform to input iterator requirements.
wxGTK:
- Fix the build with glib < 2.32 (e.g. CentOS 6).
wxMSW: wxMSW:
- Fix hang after clearing wxTAB_TRAVERSAL style on a window with children. - Fix hang after clearing wxTAB_TRAVERSAL style on a window with children.

View File

@@ -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 #define gdk_cairo_set_source_window wx_gdk_cairo_set_source_window
#endif #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 // the following were introduced in GTK+ 3.0

View File

@@ -808,8 +808,7 @@ wxMenu::~wxMenu()
// Destroying a menu generates a "hide" signal even if it's not shown // Destroying a menu generates a "hide" signal even if it's not shown
// currently, so disconnect it to avoid dummy wxEVT_MENU_CLOSE events // currently, so disconnect it to avoid dummy wxEVT_MENU_CLOSE events
// generation. // generation.
g_signal_handlers_disconnect_matched(m_menu, g_signal_handlers_disconnect_by_data(m_menu, this);
GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
if (m_owner) if (m_owner)
{ {
@@ -993,8 +992,7 @@ wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
GtkWidget * const mitem = item->GetMenuItem(); GtkWidget * const mitem = item->GetMenuItem();
g_signal_handlers_disconnect_matched(mitem, g_signal_handlers_disconnect_by_data(mitem, item);
GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, item);
#ifdef __WXGTK3__ #ifdef __WXGTK3__
gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(mitem), NULL);

View File

@@ -589,9 +589,8 @@ wxWebViewWebKit::~wxWebViewWebKit()
if (m_dbusServer) if (m_dbusServer)
{ {
g_dbus_server_stop(m_dbusServer); g_dbus_server_stop(m_dbusServer);
g_signal_handlers_disconnect_matched( g_signal_handlers_disconnect_by_data(
webkit_web_context_get_default(), G_SIGNAL_MATCH_DATA, webkit_web_context_get_default(), m_dbusServer);
0, 0, NULL, NULL, m_dbusServer);
} }
g_clear_object(&m_dbusServer); g_clear_object(&m_dbusServer);
g_clear_object(&m_extension); g_clear_object(&m_extension);

View File

@@ -2675,8 +2675,7 @@ bool wxWindowGTK::Create( wxWindow *parent,
void wxWindowGTK::GTKDisconnect(void* instance) void wxWindowGTK::GTKDisconnect(void* instance)
{ {
g_signal_handlers_disconnect_matched(instance, g_signal_handlers_disconnect_by_data(instance, this);
GSignalMatchType(G_SIGNAL_MATCH_DATA), 0, 0, NULL, NULL, this);
} }
wxWindowGTK::~wxWindowGTK() wxWindowGTK::~wxWindowGTK()