[gimp] app: s/g_warning/g_printerr/ to warn about duplicate actions.



commit 420f1f53325d3a34e9e6e7e17b57bde63df2d3f1
Author: Jehan <jehan girinstud io>
Date:   Sat Jul 2 16:38:19 2022 +0200

    app: s/g_warning/g_printerr/ to warn about duplicate actions.
    
    g_warning() (as well as g_critical() and g_return_*()) are reserved for
    core code bugs, and therefore triggers a debug dialog with a backtrace
    to report.
    
    Here I encountered such duplicate because ts-helloworld.scm was moved
    around from scripts/ to plug-ins/ since commit d5a83429b4 and I hadn't
    done a clean uninstall (so of course someone with package installation
    should not have such a debug dialog). Yet it could actually happen for
    various reasons, such as third-party plug-ins actually registering
    identically named actions. Such reasons are not core code bugs and we
    don't want to trigger a debug dialog (and have people report bugs to us
    which are not actual bugs and which we have no power to fix) each time a
    plug-in developer uses a too generic action name.
    
    So instead let's just print to stderr for now. I also add the
    information on which plug-in was discarded (otherwise if you actually
    have 2 different plug-ins doing different things, you wouldn't know
    which one is the visible one and which one can't be called).
    
    Note that I hesitated with a g_message() which would pop-up a
    user-facing error and would help them better handle their plug-in
    conflict. But I'm not sure it's ideal in current state of things either.
    It might be much better handled when we will have moved to recommending
    extensions wrapping plug-ins.

 app/widgets/gimpactiongroup.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/app/widgets/gimpactiongroup.c b/app/widgets/gimpactiongroup.c
index 637d20bd82..1cb485b5fd 100644
--- a/app/widgets/gimpactiongroup.c
+++ b/app/widgets/gimpactiongroup.c
@@ -32,6 +32,8 @@
 #include "core/gimpcontext.h"
 #include "core/gimpviewable.h"
 
+#include "plug-in/gimppluginprocedure.h"
+
 #include "gimpaction.h"
 #include "gimpactiongroup.h"
 #include "gimpactionimpl.h"
@@ -253,9 +255,8 @@ gimp_action_group_check_unique_action (GimpActionGroup *group,
 {
   if (G_UNLIKELY (gimp_action_group_get_action (group, action_name)))
     {
-      g_warning ("Refusing to add non-unique action '%s' to action group '%s'",
-                 action_name,
-                 gimp_action_group_get_name (group));
+      g_printerr ("Refusing to add non-unique action '%s' to action group '%s'\n",
+                  action_name, gimp_action_group_get_name (group));
       return FALSE;
     }
 
@@ -667,7 +668,19 @@ gimp_action_group_add_procedure_actions (GimpActionGroup                *group,
       GimpProcedureAction *action;
 
       if (! gimp_action_group_check_unique_action (group, entries[i].name))
-        continue;
+        {
+          if (entries[i].procedure != NULL &&
+              GIMP_IS_PLUG_IN_PROCEDURE (entries[i].procedure))
+            {
+              GFile *file;
+
+              file = gimp_plug_in_procedure_get_file (GIMP_PLUG_IN_PROCEDURE (entries[i].procedure));
+
+              g_printerr ("Discarded action '%s' was registered in plug-in: '%s'\n",
+                          entries[i].name, g_file_peek_path (file));
+            }
+          continue;
+        }
 
       action = gimp_procedure_action_new (entries[i].name,
                                           entries[i].label,


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