From b7fd397eb4a7a17a671b29e818b63718ab618b63 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sun, 24 Oct 2021 12:19:27 +0200 Subject: Use GLib's new g_clear_signal_handler() function to simplify code --- cut-n-paste/toolbar-editor/egg-toolbar-editor.c | 6 ++++++ libmisc/ev-page-action-widget.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c index 551bbde3..cb07011f 100644 --- a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c +++ b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c @@ -149,6 +149,11 @@ egg_toolbar_editor_disconnect_model (EggToolbarEditor *t) { handler = priv->sig_handlers[i]; +#if GLIB_CHECK_VERSION(2,62,0) + if ((handler == 0) || !g_signal_handler_is_connected (model, handler)) + continue; + g_clear_signal_handler (&handler, model); +#else if (handler != 0) { if (g_signal_handler_is_connected (model, handler)) @@ -158,6 +163,7 @@ egg_toolbar_editor_disconnect_model (EggToolbarEditor *t) priv->sig_handlers[i] = 0; } +#endif } } diff --git a/libmisc/ev-page-action-widget.c b/libmisc/ev-page-action-widget.c index c24d9b97..30654d19 100644 --- a/libmisc/ev-page-action-widget.c +++ b/libmisc/ev-page-action-widget.c @@ -202,11 +202,16 @@ ev_page_action_widget_document_changed_cb (EvDocumentModel *model, g_object_unref (action_widget->document); action_widget->document = document; +#if GLIB_CHECK_VERSION(2,62,0) + g_clear_signal_handler (&action_widget->signal_id, + action_widget->doc_model); +#else if (action_widget->signal_id > 0) { g_signal_handler_disconnect (action_widget->doc_model, action_widget->signal_id); action_widget->signal_id = 0; } +#endif action_widget->signal_id = g_signal_connect_object (action_widget->doc_model, "page-changed", @@ -240,6 +245,13 @@ ev_page_action_widget_finalize (GObject *object) EvPageActionWidget *action_widget = EV_PAGE_ACTION_WIDGET (object); if (action_widget->doc_model != NULL) { +#if GLIB_CHECK_VERSION(2,62,0) + if ((action_widget->signal_id != 0) && + (g_signal_handler_is_connected (action_widget->doc_model, + action_widget->signal_id))) + g_clear_signal_handler (&action_widget->signal_id, + action_widget->doc_model); +#else if (action_widget->signal_id > 0) { if (g_signal_handler_is_connected(action_widget->doc_model, action_widget->signal_id)) @@ -247,6 +259,7 @@ ev_page_action_widget_finalize (GObject *object) action_widget->signal_id); action_widget->signal_id = 0; } +#endif g_object_remove_weak_pointer (G_OBJECT (action_widget->doc_model), (gpointer)&action_widget->doc_model); action_widget->doc_model = NULL; -- cgit v1.2.1