[libdazzle] shortcuts: more tracing for debugging purposes



commit fe0d8fcd47dd9c2fc29867789ce14cecd0bbf13d
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jul 19 23:07:15 2017 -0700

    shortcuts: more tracing for debugging purposes

 src/shortcuts/dzl-shortcut-closure-chain.c |   13 +++++++++++--
 src/shortcuts/dzl-shortcut-context.c       |   18 ++++++++++++++----
 2 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-closure-chain.c b/src/shortcuts/dzl-shortcut-closure-chain.c
index e31f492..4e8233d 100644
--- a/src/shortcuts/dzl-shortcut-closure-chain.c
+++ b/src/shortcuts/dzl-shortcut-closure-chain.c
@@ -406,6 +406,8 @@ command_activate (DzlShortcutClosureChain *chain,
         }
     }
 
+  g_warning ("Failed to locate controller command: %s", chain->command.name);
+
   return FALSE;
 }
 
@@ -415,11 +417,16 @@ dzl_shortcut_closure_chain_execute (DzlShortcutClosureChain *chain,
 {
   gboolean ret = FALSE;
 
+  DZL_ENTRY;
+
   g_return_val_if_fail (chain != NULL, FALSE);
   g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
 
   if (chain->executing)
-    return FALSE;
+    {
+      g_warning ("Attempt for re-entrancy in closure chain activation blocked");
+      DZL_RETURN (FALSE);
+    }
 
   chain->executing = TRUE;
 
@@ -461,5 +468,7 @@ dzl_shortcut_closure_chain_execute (DzlShortcutClosureChain *chain,
 
   chain->executing = FALSE;
 
-  return ret;
+  DZL_TRACE_MSG ("ret = %d", ret);
+
+  DZL_RETURN (ret);
 }
diff --git a/src/shortcuts/dzl-shortcut-context.c b/src/shortcuts/dzl-shortcut-context.c
index db95d9f..aae7c4c 100644
--- a/src/shortcuts/dzl-shortcut-context.c
+++ b/src/shortcuts/dzl-shortcut-context.c
@@ -21,6 +21,8 @@
 #include <gobject/gvaluecollector.h>
 #include <string.h>
 
+#include "dzl-debug.h"
+
 #include "shortcuts/dzl-shortcut-chord.h"
 #include "shortcuts/dzl-shortcut-closure-chain.h"
 #include "shortcuts/dzl-shortcut-context.h"
@@ -182,10 +184,15 @@ dzl_shortcut_context_activate (DzlShortcutContext     *self,
   DzlShortcutMatch match = DZL_SHORTCUT_MATCH_NONE;
   DzlShortcutClosureChain *chain = NULL;
 
+  DZL_ENTRY;
+
   g_return_val_if_fail (DZL_IS_SHORTCUT_CONTEXT (self), DZL_SHORTCUT_MATCH_NONE);
   g_return_val_if_fail (GTK_IS_WIDGET (widget), DZL_SHORTCUT_MATCH_NONE);
   g_return_val_if_fail (chord != NULL, DZL_SHORTCUT_MATCH_NONE);
 
+  if (priv->table == NULL)
+    DZL_RETURN (DZL_SHORTCUT_MATCH_NONE);
+
 #if 0
   g_print ("Looking up %s in table %p (of size %u)\n",
            dzl_shortcut_chord_to_string (chord),
@@ -195,21 +202,24 @@ dzl_shortcut_context_activate (DzlShortcutContext     *self,
   dzl_shortcut_chord_table_printf (priv->table);
 #endif
 
-  if (priv->table != NULL)
-    match = dzl_shortcut_chord_table_lookup (priv->table, chord, (gpointer *)&chain);
+  match = dzl_shortcut_chord_table_lookup (priv->table, chord, (gpointer *)&chain);
 
   if (match == DZL_SHORTCUT_MATCH_EQUAL)
     {
+      g_assert (chain != NULL);
+
       /*
        * If we got a full match, but it failed to activate, we could potentially
        * have another partial match. However, that lands squarely in the land of
        * undefined behavior. So instead we just assume there was no match.
        */
       if (!dzl_shortcut_closure_chain_execute (chain, widget))
-        return DZL_SHORTCUT_MATCH_NONE;
+        match = DZL_SHORTCUT_MATCH_NONE;
     }
 
-  return match;
+  DZL_TRACE_MSG ("match = %d", match);
+
+  DZL_RETURN (match);
 }
 
 static void


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