[Xfce4-commits] [apps/mousepad] 01/01: Use normal signal connection instead of GClosures

noreply at xfce.org noreply at xfce.org
Sun Jul 13 21:55:32 CEST 2014


This is an automated email from the git hooks/post-receive script.

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit b91acccee56db056fb43192f6a0924698496346d
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Sun Jul 13 12:50:15 2014 -0700

    Use normal signal connection instead of GClosures
    
    For the proxy menu item connection that allows the statusbar to show
    the menu items tooltips on hover. This gets rid of tons of console spam
    like this:
    
        (mousepad:8256): GLib-GObject-CRITICAL **:
        g_closure_add_invalidate_notifier: assertion 'closure->n_inotifiers
        < CLOSURE_MAX_N_INOTIFIERS' failed
    
    I guess we exceeded the hardcoded limit (CLOSURE_MAX_N_INOTIFIERS) or
    something. Using regular g_signal_connect*() seems to get rid of all
    these warnings and is less code too.
---
 mousepad/mousepad-window.c |   28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 8c16ef9..b469c38 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -376,10 +376,6 @@ struct _MousepadWindow
   /* the current active document */
   MousepadDocument    *active;
 
-  /* closures for the menu callbacks */
-  GClosure            *menu_item_selected_closure;
-  GClosure            *menu_item_deselected_closure;
-
   /* action group */
   GtkActionGroup      *action_group;
 
@@ -927,16 +923,6 @@ mousepad_window_init (MousepadWindow *window)
   /* signal for handling the window delete event */
   g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (mousepad_window_delete_event), NULL);
 
-  /* allocate a closure for the menu_item_selected() callback */
-  window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_selected), G_OBJECT (window));
-  g_closure_ref (window->menu_item_selected_closure);
-  g_closure_sink (window->menu_item_selected_closure);
-
-  /* allocate a closure for the menu_item_deselected() callback */
-  window->menu_item_deselected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_deselected), G_OBJECT (window));
-  g_closure_ref (window->menu_item_deselected_closure);
-  g_closure_sink (window->menu_item_deselected_closure);
-
   /* restore window settings */
   mousepad_window_restore (window);
 
@@ -1061,10 +1047,6 @@ mousepad_window_finalize (GObject *object)
   if (G_UNLIKELY (window->update_go_menu_id != 0))
     g_source_remove (window->update_go_menu_id);
 
-  /* drop our references on the menu_item_selected()/menu_item_deselected() closures */
-  g_closure_unref (window->menu_item_deselected_closure);
-  g_closure_unref (window->menu_item_selected_closure);
-
   /* release the ui manager */
   g_signal_handlers_disconnect_matched (G_OBJECT (window->ui_manager), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, window);
   g_object_unref (G_OBJECT (window->ui_manager));
@@ -1130,9 +1112,8 @@ mousepad_window_connect_proxy (GtkUIManager   *manager,
 
   if (GTK_IS_MENU_ITEM (proxy))
     {
-      /* we want to get informed when the user hovers a menu item */
-      g_signal_connect_closure (G_OBJECT (proxy), "select", window->menu_item_selected_closure, FALSE);
-      g_signal_connect_closure (G_OBJECT (proxy), "deselect", window->menu_item_deselected_closure, FALSE);
+      g_signal_connect_object (proxy, "select", G_CALLBACK (mousepad_window_menu_item_selected), window, 0);
+      g_signal_connect_object (proxy, "deselect", G_CALLBACK (mousepad_window_menu_item_deselected), window, 0);
     }
 }
 
@@ -1150,9 +1131,8 @@ mousepad_window_disconnect_proxy (GtkUIManager   *manager,
 
   if (GTK_IS_MENU_ITEM (proxy))
     {
-      /* disconnect the signal from mousepad_window_connect_proxy() */
-      g_signal_handlers_disconnect_matched (G_OBJECT (proxy), G_SIGNAL_MATCH_CLOSURE, 0, 0, window->menu_item_selected_closure, NULL, NULL);
-      g_signal_handlers_disconnect_matched (G_OBJECT (proxy), G_SIGNAL_MATCH_CLOSURE, 0, 0, window->menu_item_deselected_closure, NULL, NULL);
+      g_signal_handlers_disconnect_by_func (proxy, mousepad_window_menu_item_selected, window);
+      g_signal_handlers_disconnect_by_func (proxy, mousepad_window_menu_item_deselected, window);
     }
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list