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.
This commit is contained in:
Jehan 2022-07-02 16:38:19 +02:00
parent 0d7fed93ae
commit 420f1f5332
1 changed files with 17 additions and 4 deletions

View File

@ -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,