[gtk+/wip/action-helper] gactionmuxer: don't unnecessarily query added actions



commit fc75201fd6aaad7dc8008486d2e63d3a29eff3ad
Author: Lars Uebernickel <lars uebernickel canonical com>
Date:   Fri Aug 10 16:28:21 2012 +0200

    gactionmuxer: don't unnecessarily query added actions
    
    g_action_group_query_action only needs to be called when there are
    observers registered for that action.

 gtk/gactionmuxer.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gactionmuxer.c b/gtk/gactionmuxer.c
index 3c996c4..eaf77fa 100644
--- a/gtk/gactionmuxer.c
+++ b/gtk/gactionmuxer.c
@@ -250,25 +250,26 @@ g_action_muxer_action_added (GActionMuxer *muxer,
   const GVariantType *parameter_type;
   gboolean enabled;
   GVariant *state;
+  Action *action;
+
+  action = g_hash_table_lookup (muxer->observed_actions, action_name);
 
-  if (g_action_group_query_action (original_group, orignal_action_name,
+  if (action && action->watchers &&
+      g_action_group_query_action (original_group, orignal_action_name,
                                    &enabled, &parameter_type, NULL, NULL, &state))
     {
-      Action *action;
       GSList *node;
 
-      action = g_hash_table_lookup (muxer->observed_actions, action_name);
-
-      for (node = action ? action->watchers : NULL; node; node = node->next)
+      for (node = action->watchers; node; node = node->next)
         g_action_observer_action_added (node->data,
                                         G_ACTION_OBSERVABLE (muxer),
                                         action_name, parameter_type, enabled, state);
 
-      g_action_group_action_added (G_ACTION_GROUP (muxer), action_name);
-
       if (state)
         g_variant_unref (state);
     }
+
+  g_action_group_action_added (G_ACTION_GROUP (muxer), action_name);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]