From 3372dbaf38f2b8afaaca9049958c82dc137d6035 Mon Sep 17 00:00:00 2001 From: Axel Viala Date: Tue, 29 Mar 2022 17:04:32 +0200 Subject: [PATCH] Fix -Wdiscarded-qualifiers in gimp_tool_button_update. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [2207/2321] Compiling C object app/widgets/libappwidgets.a.p/gimptoolbutton.c.o ../app/widgets/gimptoolbutton.c: In function ‘gimp_tool_button_update’: ../app/widgets/gimptoolbutton.c:905:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 905 | gchar *id = gimp_object_get_name (tool_info); | ^~~~~~~~~~~~~~~~~~~~ --- app/widgets/gimptoolbutton.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/widgets/gimptoolbutton.c b/app/widgets/gimptoolbutton.c index c6e7b20d6e..a539c899f7 100644 --- a/app/widgets/gimptoolbutton.c +++ b/app/widgets/gimptoolbutton.c @@ -902,10 +902,11 @@ gimp_tool_button_update (GimpToolButton *tool_button) if (tool_info) { - gchar *id = gimp_object_get_name (tool_info); + const gchar *tool_name = gimp_object_get_name (tool_info); + gchar *identifier; - if (g_str_has_prefix (id, "gimp-") && - g_str_has_suffix (id, "-tool")) + if (g_str_has_prefix (tool_name, "gimp-") && + g_str_has_suffix (tool_name, "-tool")) { /* The GimpToolInfo names are of the form "gimp-pencil-tool", * and action names are of the form "tools-pencil". @@ -914,16 +915,17 @@ gimp_tool_button_update (GimpToolButton *tool_button) */ gchar *suffix; - id = g_strdup_printf ("tools-%s", id + 5); - suffix = g_strrstr (id, "-tool"); + identifier = g_strdup_printf ("tools-%s", tool_name + 5); + suffix = g_strrstr (identifier, "-tool"); suffix[0] = '\0'; } else { - id = g_strdup (id); + identifier = g_strdup (tool_name); } - gimp_widget_set_identifier (tool_button, id); + gimp_widget_set_identifier (GTK_WIDGET (tool_button), identifier); + g_free (identifier); } gimp_tool_button_update_toggled (tool_button);