[gnome-builder] libide: add IDE_BUG() macro for reporting bug information



commit 1d6f19fcf8ff8990e3cc2145f2877f672ad0c3dd
Author: Christian Hergert <christian hergert me>
Date:   Wed May 13 22:29:13 2015 -0700

    libide: add IDE_BUG() macro for reporting bug information
    
    Sprinkling these macros in various places may help us get some meaningful
    bug reports. So adding this macro in hopes that we use it for specific
    cases.
    
    The first macro parameter is the component in bugzilla you'd like to use.
    
    IDE_BUG (libide, "Some helpful description")

 configure.ac          |    3 +++
 libide/ide-debug.h.in |   16 ++++++++++++++++
 libide/ide-object.c   |    4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8e6d119..0d9d5f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,6 +136,9 @@ AS_CASE(["x$enable_debug"],
         [])
 AC_SUBST(DEBUG_CFLAGS)
 
+BUGREPORT_URL=builder_bugreport_url
+AC_SUBST(BUGREPORT_URL)
+
 
 dnl ***********************************************************************
 dnl Check for Required Packages
diff --git a/libide/ide-debug.h.in b/libide/ide-debug.h.in
index 8c40bd3..eec2f4e 100644
--- a/libide/ide-debug.h.in
+++ b/libide/ide-debug.h.in
@@ -75,6 +75,22 @@ G_BEGIN_DECLS
 # define IDE_RETURN(_r) return _r
 #endif
 
+#define _IDE_BUG(Component, Description, File, Line, Func, ...)                         \
+  G_STMT_START {                                                                        \
+    g_printerr ("-----------------------------------------------------------------\n"); \
+    g_printerr ("You've found a bug in Builder or one of it's dependent libraries.\n"); \
+    g_printerr ("Please help us help you by filing a bug report at:\n");                \
+    g_printerr ("\n");                                                                  \
+    g_printerr ("@BUGREPORT_URL@&component=%s\n", Component);                           \
+    g_printerr ("\n");                                                                  \
+    g_printerr ("%s:%d in function %s()\n", File, Line, Func);                          \
+    g_printerr ("\n");                                                                  \
+    g_printerr (Description"\n", ##__VA_ARGS__);                                        \
+    g_printerr ("-----------------------------------------------------------------\n"); \
+  } G_STMT_END
+#define IDE_BUG(Component, Description, ...) \
+  _IDE_BUG(Component, Description, __FILE__, __LINE__, G_STRFUNC, ##__VA_ARGS__)
+
 G_END_DECLS
 
 #endif /* IDE_DEBUG_H */
diff --git a/libide/ide-object.c b/libide/ide-object.c
index cb41313..7c54897 100644
--- a/libide/ide-object.c
+++ b/libide/ide-object.c
@@ -385,7 +385,7 @@ ide_object_hold (IdeObject *self)
 
   if (priv->context == NULL)
     {
-      g_warning ("BUG: Cannot hold context, already disposed.");
+      IDE_BUG ("libide", "Called after context was released.");
       return;
     }
 
@@ -407,7 +407,7 @@ ide_object_release (IdeObject *self)
 
   if (priv->context == NULL)
     {
-      g_warning ("BUG: Cannot release context, already disposed.");
+      IDE_BUG ("libide", "Called after context was released.");
       return;
     }
 


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