[gnome-builder/wip/commands] commands: add warning



commit 7569ecfa51f8d155d2d68abbb7b80413cf993f46
Author: Christian Hergert <christian hergert me>
Date:   Tue Oct 7 11:16:44 2014 -0700

    commands: add warning

 src/commands/gb-command-manager.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/commands/gb-command-manager.c b/src/commands/gb-command-manager.c
index e05d9bc..26d9538 100644
--- a/src/commands/gb-command-manager.c
+++ b/src/commands/gb-command-manager.c
@@ -16,6 +16,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#define G_LOG_DOMAIN "command-manager"
+
 #include <string.h>
 
 #include "gb-command-manager.h"
@@ -24,14 +26,14 @@
  * SECTION:gb-command-manager:
  * @title: GbCommandManager
  * @short_description: command management
- * 
+ *
  * This class is responsible for storing available commands in the process.
  * It is also responsible for looking them up to dispatch an operation to the
  * right command instance.
- * 
+ *
  * Typically, you want to use the default #GbCommandManager instance which
  * can be fetched with gb_command_manager_get_default().
- * 
+ *
  * Note that GbCommandManager is NOT thread safe. It should only be used
  * from the main thread. However, Some commands may asynchronously perform
  * their work in a background thread.
@@ -72,6 +74,12 @@ gb_command_manager_register (GbCommandManager *manager,
 
   name = g_strdup (gb_command_get_name (command));
 
+  if (!name)
+    {
+      g_warning ("Attempt to register command without a name.");
+      return;
+    }
+
   if (g_hash_table_lookup (manager->priv->commands, name))
     g_warning ("A command named \"%s\" has already been registered.", name);
 


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