g_printerr() library usage (Re: GtkUIManager comment)



On Fri, 12 Nov 2004, Sven Neumann wrote:

Hi,

Alexander Larsson <alexl redhat com> writes:

I just wasted some time tracking down a bug due to the misstyping of a
GtkUIManager path. Any chance something like this could be applied to
avoid such problems in the future:

diff -u -p -r1.62 gtkuimanager.c
--- gtk/gtkuimanager.c  28 Oct 2004 15:00:05 -0000      1.62
+++ gtk/gtkuimanager.c  12 Nov 2004 07:55:17 -0000
@@ -1581,7 +1581,10 @@ gtk_ui_manager_add_ui (GtkUIManager
   node = get_node (self, path, NODE_TYPE_UNDECIDED, FALSE);

   if (node == NULL)
-    return;
+    {
+      g_warning ("Trying to add UI to non-existing path '%s'", path);
+      return;
+    }

Is this truly a programming error? Otherwise, g_printerr() would
probably be a better choice than g_warning().

g_printerr() is almost always the wrong thing to use. for "sort of debugging
messages" that you still mean to put out but don't warrant a g_warning(),
use g_message() which at least can be caught and silenced via the g_log() API.


Sven

---
ciaoTJ



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