[gimp] app: add GIMP_MESSAGE_BUG_WARNING + GIMP_MESSAGE_BUG_CRITICAL severity.



commit 77ed4761137da9d5fee6802303213cc3b3e9b985
Author: Jehan <jehan girinstud io>
Date:   Mon Feb 12 17:20:53 2018 +0100

    app: add GIMP_MESSAGE_BUG_WARNING + GIMP_MESSAGE_BUG_CRITICAL severity.
    
    Since a few commits, I don't generate the traces anymore in errors.c but
    delay this to gui-message.c and rely on the message severity to decide
    whether or not generating traces.
    Unfortunately none of the current severities are properly describing
    this new type of messages. Even GIMP_MESSAGE_ERROR is used everywhere in
    our code NOT for actual programming bug, but often for data errors
    (which are not bugs but proper messages and should obviously not prompt
    a debug trace).

 app/core/core-enums.c                   |    4 +++
 app/core/core-enums.h                   |    8 ++++--
 app/display/gimpdisplayshell-progress.c |    2 +
 app/errors.c                            |   32 +++++++++++++++++-------------
 app/gui/gui-message.c                   |   30 +++++++++++++++++++---------
 app/widgets/gimpwidgets-utils.c         |    4 +++
 6 files changed, 53 insertions(+), 27 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 9a74f0a..c50fc52 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -1066,6 +1066,8 @@ gimp_message_severity_get_type (void)
     { GIMP_MESSAGE_INFO, "GIMP_MESSAGE_INFO", "info" },
     { GIMP_MESSAGE_WARNING, "GIMP_MESSAGE_WARNING", "warning" },
     { GIMP_MESSAGE_ERROR, "GIMP_MESSAGE_ERROR", "error" },
+    { GIMP_MESSAGE_BUG_WARNING, "GIMP_MESSAGE_BUG_WARNING", "bug-warning" },
+    { GIMP_MESSAGE_BUG_CRITICAL, "GIMP_MESSAGE_BUG_CRITICAL", "bug-critical" },
     { 0, NULL, NULL }
   };
 
@@ -1074,6 +1076,8 @@ gimp_message_severity_get_type (void)
     { GIMP_MESSAGE_INFO, NC_("message-severity", "Message"), NULL },
     { GIMP_MESSAGE_WARNING, NC_("message-severity", "Warning"), NULL },
     { GIMP_MESSAGE_ERROR, NC_("message-severity", "Error"), NULL },
+    { GIMP_MESSAGE_BUG_WARNING, NC_("message-severity", "WARNING"), NULL },
+    { GIMP_MESSAGE_BUG_CRITICAL, NC_("message-severity", "CRITICAL"), NULL },
     { 0, NULL, NULL }
   };
 
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 1a249aa..f73d867 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -495,9 +495,11 @@ GType gimp_message_severity_get_type (void) G_GNUC_CONST;
 
 typedef enum  /*< pdb-skip >*/
 {
-  GIMP_MESSAGE_INFO,     /*< desc="Message" >*/
-  GIMP_MESSAGE_WARNING,  /*< desc="Warning" >*/
-  GIMP_MESSAGE_ERROR     /*< desc="Error"   >*/
+  GIMP_MESSAGE_INFO,        /*< desc="Message"  >*/
+  GIMP_MESSAGE_WARNING,     /*< desc="Warning"  >*/
+  GIMP_MESSAGE_ERROR,       /*< desc="Error"    >*/
+  GIMP_MESSAGE_BUG_WARNING, /*< desc="WARNING"  >*/
+  GIMP_MESSAGE_BUG_CRITICAL /*< desc="CRITICAL" >*/
 } GimpMessageSeverity;
 
 
diff --git a/app/display/gimpdisplayshell-progress.c b/app/display/gimpdisplayshell-progress.c
index 14d70d9..deb8737 100644
--- a/app/display/gimpdisplayshell-progress.c
+++ b/app/display/gimpdisplayshell-progress.c
@@ -123,6 +123,8 @@ gimp_display_shell_progress_message (GimpProgress        *progress,
   switch (severity)
     {
     case GIMP_MESSAGE_ERROR:
+    case GIMP_MESSAGE_BUG_WARNING:
+    case GIMP_MESSAGE_BUG_CRITICAL:
       /* error messages are never handled here */
       break;
 
diff --git a/app/errors.c b/app/errors.c
index 5649568..e2933de 100644
--- a/app/errors.c
+++ b/app/errors.c
@@ -171,8 +171,10 @@ gimp_message_log_func (const gchar    *log_domain,
                        gpointer        data)
 {
   Gimp                *gimp       = data;
+  GimpCoreConfig      *config     = gimp->config;
   const gchar         *msg_domain = NULL;
   GimpMessageSeverity  severity   = GIMP_MESSAGE_WARNING;
+  GimpDebugPolicy      debug_policy;
 
   /* All GIMP messages are processed under the same domain, but
    * we need to keep the log domain information for third party
@@ -182,21 +184,23 @@ gimp_message_log_func (const gchar    *log_domain,
       ! g_str_has_prefix (log_domain, "LibGimp"))
     msg_domain = log_domain;
 
-  if (flags & (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING))
-    {
-      GimpCoreConfig  *config = gimp->config;
-      GimpDebugPolicy  debug_policy;
-
-      g_object_get (G_OBJECT (config),
-                    "debug-policy", &debug_policy,
-                    NULL);
+  /* If debug policy requires it, WARNING and CRITICAL errors must be
+   * routed for appropriate debugging.
+   */
+  g_object_get (G_OBJECT (config),
+                "debug-policy", &debug_policy,
+                NULL);
 
-      if ((debug_policy == GIMP_DEBUG_POLICY_CRITICAL &&
-           (flags & G_LOG_LEVEL_CRITICAL)) ||
-          debug_policy == GIMP_DEBUG_POLICY_WARNING)
-        {
-          severity = GIMP_MESSAGE_ERROR;
-        }
+  switch (flags & G_LOG_LEVEL_MASK)
+    {
+    case G_LOG_LEVEL_WARNING:
+      if (debug_policy == GIMP_DEBUG_POLICY_WARNING)
+        severity = GIMP_MESSAGE_BUG_WARNING;
+      break;
+    case G_LOG_LEVEL_CRITICAL:
+      if (debug_policy <= GIMP_DEBUG_POLICY_CRITICAL)
+        severity = GIMP_MESSAGE_BUG_CRITICAL;
+      break;
     }
 
   if (gimp)
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 1c2512a..60680c2 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -113,7 +113,7 @@ gui_message (Gimp                *gimp,
       /*  fallthru  */
 
     case GIMP_MESSAGE_BOX:
-      if (severity == GIMP_MESSAGE_ERROR)
+      if (severity >= GIMP_MESSAGE_BUG_WARNING)
         {
           g_mutex_lock (&mutex);
           /* Trace creation can be time consuming so don't block the
@@ -305,18 +305,28 @@ gui_message_error_dialog (Gimp                *gimp,
 
   switch (severity)
     {
-    case GIMP_MESSAGE_INFO:    type = GTK_MESSAGE_INFO;    break;
-    case GIMP_MESSAGE_WARNING: type = GTK_MESSAGE_WARNING; break;
-    case GIMP_MESSAGE_ERROR:   type = GTK_MESSAGE_ERROR;   break;
+    case GIMP_MESSAGE_INFO:
+      type = GTK_MESSAGE_INFO;
+      break;
+    case GIMP_MESSAGE_WARNING:
+      type = GTK_MESSAGE_WARNING;
+      break;
+    case GIMP_MESSAGE_ERROR:
+      type = GTK_MESSAGE_ERROR;
+      break;
+    case GIMP_MESSAGE_BUG_WARNING:
+    case GIMP_MESSAGE_BUG_CRITICAL:
+      type = GTK_MESSAGE_OTHER;
+      break;
     }
 
-  if (severity == GIMP_MESSAGE_ERROR)
+  if (severity >= GIMP_MESSAGE_BUG_WARNING)
     {
-      /* Process differently errors.
-       * The reason is that this will take significant place, and cannot
-       * be processed as a progress message or in the global dialog. It
-       * will require its own dedicated dialog which will encourage
-       * people to report the bug.
+      /* Process differently programming errors.
+       * The reason is that we will generate traces, which will take
+       * significant place, and cannot be processed as a progress
+       * message or in the global dialog. It will require its own
+       * dedicated dialog which will encourage people to report the bug.
        */
       gboolean gui_error = FALSE;
 
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 02d160e..90bfd58 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1154,6 +1154,10 @@ gimp_get_message_icon_name (GimpMessageSeverity severity)
 
     case GIMP_MESSAGE_ERROR:
       return GIMP_ICON_DIALOG_ERROR;
+
+    case GIMP_MESSAGE_BUG_WARNING:
+    case GIMP_MESSAGE_BUG_CRITICAL:
+      return GIMP_ICON_WILBER_EEK;
     }
 
   g_return_val_if_reached (GIMP_ICON_DIALOG_WARNING);


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