From 199eecfb6691c7c81d4a28f934c41197975eb6da Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 7 Jul 2025 22:55:44 +0200 Subject: [PATCH] app: use g_set_str() in some places, it's hell yeah! --- app/config/gimpcoreconfig.c | 144 ++++++++++++++++----------------- app/config/gimpdialogconfig.c | 36 ++++----- app/config/gimpdisplayconfig.c | 12 +-- app/config/gimpearlyrc.c | 28 ++++--- app/config/gimpgeglconfig.c | 28 ++++--- app/config/gimpguiconfig.c | 38 ++++----- app/config/gimppluginconfig.c | 30 +++---- app/core/gimpcontext.c | 51 ++++++------ app/display/gimptoolgui.c | 12 +-- 9 files changed, 190 insertions(+), 189 deletions(-) diff --git a/app/config/gimpcoreconfig.c b/app/config/gimpcoreconfig.c index 5565f15460..35971f995b 100644 --- a/app/config/gimpcoreconfig.c +++ b/app/config/gimpcoreconfig.c @@ -909,9 +909,9 @@ gimp_core_config_finalize (GObject *object) g_free (core_config->plug_in_rc_path); g_free (core_config->import_raw_plug_in); - g_clear_pointer (&core_config->last_known_release, g_free); + g_clear_pointer (&core_config->last_known_release, g_free); g_clear_pointer (&core_config->last_release_comment, g_free); - g_clear_pointer (&core_config->config_version, g_free); + g_clear_pointer (&core_config->config_version, g_free); g_clear_object (&core_config->default_image); g_clear_object (&core_config->default_grid); @@ -932,12 +932,12 @@ gimp_core_config_set_property (GObject *object, switch (property_id) { case PROP_LANGUAGE: - g_free (core_config->language); - core_config->language = g_value_dup_string (value); + g_set_str (&core_config->language, + g_value_get_string (value)); break; case PROP_PREV_LANGUAGE: - g_free (core_config->prev_language); - core_config->prev_language = g_value_dup_string (value); + g_set_str (&core_config->prev_language, + g_value_get_string (value)); break; case PROP_INTERPOLATION_TYPE: core_config->interpolation_type = g_value_get_enum (value); @@ -946,116 +946,116 @@ gimp_core_config_set_property (GObject *object, core_config->default_threshold = g_value_get_int (value); break; case PROP_PLUG_IN_PATH: - g_free (core_config->plug_in_path); - core_config->plug_in_path = g_value_dup_string (value); + g_set_str (&core_config->plug_in_path, + g_value_get_string (value)); break; case PROP_MODULE_PATH: - g_free (core_config->module_path); - core_config->module_path = g_value_dup_string (value); + g_set_str (&core_config->module_path, + g_value_get_string (value)); break; case PROP_INTERPRETER_PATH: - g_free (core_config->interpreter_path); - core_config->interpreter_path = g_value_dup_string (value); + g_set_str (&core_config->interpreter_path, + g_value_get_string (value)); break; case PROP_ENVIRON_PATH: - g_free (core_config->environ_path); - core_config->environ_path = g_value_dup_string (value); + g_set_str (&core_config->environ_path, + g_value_get_string (value)); break; case PROP_BRUSH_PATH: - g_free (core_config->brush_path); - core_config->brush_path = g_value_dup_string (value); + g_set_str (&core_config->brush_path, + g_value_get_string (value)); break; case PROP_BRUSH_PATH_WRITABLE: - g_free (core_config->brush_path_writable); - core_config->brush_path_writable = g_value_dup_string (value); + g_set_str (&core_config->brush_path_writable, + g_value_get_string (value)); break; case PROP_DYNAMICS_PATH: - g_free (core_config->dynamics_path); - core_config->dynamics_path = g_value_dup_string (value); + g_set_str (&core_config->dynamics_path, + g_value_get_string (value)); break; case PROP_DYNAMICS_PATH_WRITABLE: - g_free (core_config->dynamics_path_writable); - core_config->dynamics_path_writable = g_value_dup_string (value); + g_set_str (&core_config->dynamics_path_writable, + g_value_get_string (value)); break; case PROP_MYPAINT_BRUSH_PATH: - g_free (core_config->mypaint_brush_path); - core_config->mypaint_brush_path = g_value_dup_string (value); + g_set_str (&core_config->mypaint_brush_path, + g_value_get_string (value)); break; case PROP_MYPAINT_BRUSH_PATH_WRITABLE: - g_free (core_config->mypaint_brush_path_writable); - core_config->mypaint_brush_path_writable = g_value_dup_string (value); + g_set_str (&core_config->mypaint_brush_path_writable, + g_value_get_string (value)); break; case PROP_PATTERN_PATH: - g_free (core_config->pattern_path); - core_config->pattern_path = g_value_dup_string (value); + g_set_str (&core_config->pattern_path, + g_value_get_string (value)); break; case PROP_PATTERN_PATH_WRITABLE: - g_free (core_config->pattern_path_writable); - core_config->pattern_path_writable = g_value_dup_string (value); + g_set_str (&core_config->pattern_path_writable, + g_value_get_string (value)); break; case PROP_PALETTE_PATH: - g_free (core_config->palette_path); - core_config->palette_path = g_value_dup_string (value); + g_set_str (&core_config->palette_path, + g_value_get_string (value)); break; case PROP_PALETTE_PATH_WRITABLE: - g_free (core_config->palette_path_writable); - core_config->palette_path_writable = g_value_dup_string (value); + g_set_str (&core_config->palette_path_writable, + g_value_get_string (value)); break; case PROP_GRADIENT_PATH: - g_free (core_config->gradient_path); - core_config->gradient_path = g_value_dup_string (value); + g_set_str (&core_config->gradient_path, + g_value_get_string (value)); break; case PROP_GRADIENT_PATH_WRITABLE: - g_free (core_config->gradient_path_writable); - core_config->gradient_path_writable = g_value_dup_string (value); + g_set_str (&core_config->gradient_path_writable, + g_value_get_string (value)); break; case PROP_TOOL_PRESET_PATH: - g_free (core_config->tool_preset_path); - core_config->tool_preset_path = g_value_dup_string (value); + g_set_str (&core_config->tool_preset_path, + g_value_get_string (value)); break; case PROP_TOOL_PRESET_PATH_WRITABLE: - g_free (core_config->tool_preset_path_writable); - core_config->tool_preset_path_writable = g_value_dup_string (value); + g_set_str (&core_config->tool_preset_path_writable, + g_value_get_string (value)); break; case PROP_FONT_PATH: - g_free (core_config->font_path); - core_config->font_path = g_value_dup_string (value); + g_set_str (&core_config->font_path, + g_value_get_string (value)); break; case PROP_FONT_PATH_WRITABLE: - g_free (core_config->font_path_writable); - core_config->font_path_writable = g_value_dup_string (value); + g_set_str (&core_config->font_path_writable, + g_value_get_string (value)); break; case PROP_DEFAULT_BRUSH: - g_free (core_config->default_brush); - core_config->default_brush = g_value_dup_string (value); + g_set_str (&core_config->default_brush, + g_value_get_string (value)); break; case PROP_DEFAULT_DYNAMICS: - g_free (core_config->default_dynamics); - core_config->default_dynamics = g_value_dup_string (value); + g_set_str (&core_config->default_dynamics, + g_value_get_string (value)); break; case PROP_DEFAULT_MYPAINT_BRUSH: - g_free (core_config->default_mypaint_brush); - core_config->default_mypaint_brush = g_value_dup_string (value); + g_set_str (&core_config->default_mypaint_brush, + g_value_get_string (value)); break; case PROP_DEFAULT_PATTERN: - g_free (core_config->default_pattern); - core_config->default_pattern = g_value_dup_string (value); + g_set_str (&core_config->default_pattern, + g_value_get_string (value)); break; case PROP_DEFAULT_PALETTE: - g_free (core_config->default_palette); - core_config->default_palette = g_value_dup_string (value); + g_set_str (&core_config->default_palette, + g_value_get_string (value)); break; case PROP_DEFAULT_GRADIENT: - g_free (core_config->default_gradient); - core_config->default_gradient = g_value_dup_string (value); + g_set_str (&core_config->default_gradient, + g_value_get_string (value)); break; case PROP_DEFAULT_TOOL_PRESET: - g_free (core_config->default_tool_preset); - core_config->default_tool_preset = g_value_dup_string (value); + g_set_str (&core_config->default_tool_preset, + g_value_get_string (value)); break; case PROP_DEFAULT_FONT: - g_free (core_config->default_font); - core_config->default_font = g_value_dup_string (value); + g_set_str (&core_config->default_font, + g_value_get_string (value)); break; case PROP_GLOBAL_BRUSH: core_config->global_brush = g_value_get_boolean (value); @@ -1101,8 +1101,8 @@ gimp_core_config_set_property (GObject *object, core_config->undo_preview_size = g_value_get_enum (value); break; case PROP_PLUGINRC_PATH: - g_free (core_config->plug_in_rc_path); - core_config->plug_in_rc_path = g_value_dup_string (value); + g_set_str (&core_config->plug_in_rc_path, + g_value_get_string (value)); break; case PROP_LAYER_PREVIEWS: core_config->layer_previews = g_value_get_boolean (value); @@ -1134,8 +1134,8 @@ gimp_core_config_set_property (GObject *object, core_config->last_release_timestamp = g_value_get_int64 (value); break; case PROP_LAST_RELEASE_COMMENT: - g_clear_pointer (&core_config->last_release_comment, g_free); - core_config->last_release_comment = g_value_dup_string (value); + g_set_str (&core_config->last_release_comment, + g_value_get_string (value)); break; case PROP_LAST_REVISION: core_config->last_revision = g_value_get_int (value); @@ -1143,13 +1143,13 @@ gimp_core_config_set_property (GObject *object, case PROP_LAST_KNOWN_RELEASE: if (core_config->last_known_release != g_value_get_string (value)) { - g_clear_pointer (&core_config->last_known_release, g_free); - core_config->last_known_release = g_value_dup_string (value); + g_set_str (&core_config->last_known_release, + g_value_get_string (value)); } break; case PROP_CONFIG_VERSION: - g_clear_pointer (&core_config->config_version, g_free); - core_config->config_version = g_value_dup_string (value); + g_set_str (&core_config->config_version, + g_value_get_string (value)); break; case PROP_SAVE_DOCUMENT_HISTORY: core_config->save_document_history = g_value_get_boolean (value); @@ -1168,8 +1168,8 @@ gimp_core_config_set_property (GObject *object, core_config->import_add_alpha = g_value_get_boolean (value); break; case PROP_IMPORT_RAW_PLUG_IN: - g_free (core_config->import_raw_plug_in); - core_config->import_raw_plug_in = g_value_dup_string (value); + g_set_str (&core_config->import_raw_plug_in, + g_value_get_string (value)); break; case PROP_EXPORT_FILE_TYPE: core_config->export_file_type = g_value_get_enum (value); diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c index d823f784d2..89b934b087 100644 --- a/app/config/gimpdialogconfig.c +++ b/app/config/gimpdialogconfig.c @@ -598,9 +598,9 @@ gimp_dialog_config_finalize (GObject *object) g_clear_pointer (&config->color_profile_path, g_free); g_clear_pointer (&config->layer_new_name, g_free); g_clear_pointer (&config->channel_new_name, g_free); - g_clear_pointer (&config->path_new_name, g_free); - g_clear_pointer (&config->path_export_path, g_free); - g_clear_pointer (&config->path_import_path, g_free); + g_clear_pointer (&config->path_new_name, g_free); + g_clear_pointer (&config->path_export_path, g_free); + g_clear_pointer (&config->path_import_path, g_free); g_clear_object (&config->fill_options); g_clear_object (&config->stroke_options); @@ -632,9 +632,8 @@ gimp_dialog_config_set_property (GObject *object, break; case PROP_COLOR_PROFILE_PATH: - if (config->color_profile_path) - g_free (config->color_profile_path); - config->color_profile_path = g_value_dup_string (value); + g_set_str (&config->color_profile_path, + g_value_get_string (value)); break; case PROP_IMAGE_CONVERT_PROFILE_INTENT: @@ -687,9 +686,8 @@ gimp_dialog_config_set_property (GObject *object, break; case PROP_LAYER_NEW_NAME: - if (config->layer_new_name) - g_free (config->layer_new_name); - config->layer_new_name = g_value_dup_string (value); + g_set_str (&config->layer_new_name, + g_value_get_string (value)); break; case PROP_LAYER_NEW_MODE: config->layer_new_mode = g_value_get_enum (value); @@ -732,9 +730,8 @@ gimp_dialog_config_set_property (GObject *object, break; case PROP_CHANNEL_NEW_NAME: - if (config->channel_new_name) - g_free (config->channel_new_name); - config->channel_new_name = g_value_dup_string (value); + g_set_str (&config->channel_new_name, + g_value_get_string (value)); break; case PROP_CHANNEL_NEW_COLOR: g_clear_object (&config->channel_new_color); @@ -742,24 +739,21 @@ gimp_dialog_config_set_property (GObject *object, break; case PROP_PATH_NEW_NAME: - if (config->path_new_name) - g_free (config->path_new_name); - config->path_new_name = g_value_dup_string (value); + g_set_str (&config->path_new_name, + g_value_get_string (value)); break; case PROP_PATH_EXPORT_PATH: - if (config->path_export_path) - g_free (config->path_export_path); - config->path_export_path = g_value_dup_string (value); + g_set_str (&config->path_export_path, + g_value_get_string (value)); break; case PROP_PATH_EXPORT_ACTIVE_ONLY: config->path_export_active_only = g_value_get_boolean (value); break; case PROP_PATH_IMPORT_PATH: - if (config->path_import_path) - g_free (config->path_import_path); - config->path_import_path = g_value_dup_string (value); + g_set_str (&config->path_import_path, + g_value_get_string (value)); break; case PROP_PATH_IMPORT_MERGE: config->path_import_merge = g_value_get_boolean (value); diff --git a/app/config/gimpdisplayconfig.c b/app/config/gimpdisplayconfig.c index f3cd13be37..f003bfcfe4 100644 --- a/app/config/gimpdisplayconfig.c +++ b/app/config/gimpdisplayconfig.c @@ -439,8 +439,8 @@ gimp_display_config_finalize (GObject *object) { GimpDisplayConfig *display_config = GIMP_DISPLAY_CONFIG (object); - g_free (display_config->image_title_format); - g_free (display_config->image_status_format); + g_clear_pointer (&display_config->image_title_format, g_free); + g_clear_pointer (&display_config->image_status_format, g_free); g_clear_object (&display_config->default_view); g_clear_object (&display_config->default_fullscreen_view); @@ -518,12 +518,12 @@ gimp_display_config_set_property (GObject *object, display_config->show_paint_tool_cursor = g_value_get_boolean (value); break; case PROP_IMAGE_TITLE_FORMAT: - g_free (display_config->image_title_format); - display_config->image_title_format = g_value_dup_string (value); + g_set_str (&display_config->image_title_format, + g_value_get_string (value)); break; case PROP_IMAGE_STATUS_FORMAT: - g_free (display_config->image_status_format); - display_config->image_status_format = g_value_dup_string (value); + g_set_str (&display_config->image_status_format, + g_value_get_string (value)); break; case PROP_MONITOR_XRESOLUTION: display_config->monitor_xres = g_value_get_double (value); diff --git a/app/config/gimpearlyrc.c b/app/config/gimpearlyrc.c index 16f6281fbe..e428280c28 100644 --- a/app/config/gimpearlyrc.c +++ b/app/config/gimpearlyrc.c @@ -47,16 +47,16 @@ enum }; -static void gimp_early_rc_constructed (GObject *object); -static void gimp_early_rc_finalize (GObject *object); -static void gimp_early_rc_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_early_rc_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +static void gimp_early_rc_constructed (GObject *object); +static void gimp_early_rc_finalize (GObject *object); +static void gimp_early_rc_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_early_rc_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); /* Just use GimpConfig interface's default implementation which will @@ -206,9 +206,8 @@ gimp_early_rc_set_property (GObject *object, break; case PROP_LANGUAGE: - if (rc->language) - g_free (rc->language); - rc->language = g_value_dup_string (value); + g_set_str (&rc->language, + g_value_get_string (value)); break; #ifdef G_OS_WIN32 @@ -255,12 +254,15 @@ gimp_early_rc_get_property (GObject *object, case PROP_VERBOSE: g_value_set_boolean (value, rc->verbose); break; + case PROP_SYSTEM_GIMPRC: g_value_set_object (value, rc->system_gimprc); break; + case PROP_USER_GIMPRC: g_value_set_object (value, rc->user_gimprc); break; + case PROP_LANGUAGE: g_value_set_string (value, rc->language); break; diff --git a/app/config/gimpgeglconfig.c b/app/config/gimpgeglconfig.c index 1994c4477f..cb9af0f36d 100644 --- a/app/config/gimpgeglconfig.c +++ b/app/config/gimpgeglconfig.c @@ -182,9 +182,9 @@ gimp_gegl_config_finalize (GObject *object) { GimpGeglConfig *gegl_config = GIMP_GEGL_CONFIG (object); - g_free (gegl_config->temp_path); - g_free (gegl_config->swap_path); - g_free (gegl_config->swap_compression); + g_clear_pointer (&gegl_config->temp_path, g_free); + g_clear_pointer (&gegl_config->swap_path, g_free); + g_clear_pointer (&gegl_config->swap_compression, g_free); gimp_debug_remove_instance (object); @@ -202,23 +202,28 @@ gimp_gegl_config_set_property (GObject *object, switch (property_id) { case PROP_TEMP_PATH: - g_free (gegl_config->temp_path); - gegl_config->temp_path = g_value_dup_string (value); + g_set_str (&gegl_config->temp_path, + g_value_get_string (value)); break; + case PROP_SWAP_PATH: - g_free (gegl_config->swap_path); - gegl_config->swap_path = g_value_dup_string (value); + g_set_str (&gegl_config->swap_path, + g_value_get_string (value)); break; + case PROP_SWAP_COMPRESSION: - g_free (gegl_config->swap_compression); - gegl_config->swap_compression = g_value_dup_string (value); + g_set_str (&gegl_config->swap_compression, + g_value_get_string (value)); break; + case PROP_NUM_PROCESSORS: gegl_config->num_processors = g_value_get_int (value); break; + case PROP_TILE_CACHE_SIZE: gegl_config->tile_cache_size = g_value_get_uint64 (value); break; + case PROP_USE_OPENCL: gegl_config->use_opencl = g_value_get_boolean (value); break; @@ -246,18 +251,23 @@ gimp_gegl_config_get_property (GObject *object, case PROP_TEMP_PATH: g_value_set_string (value, gegl_config->temp_path); break; + case PROP_SWAP_PATH: g_value_set_string (value, gegl_config->swap_path); break; + case PROP_SWAP_COMPRESSION: g_value_set_string (value, gegl_config->swap_compression); break; + case PROP_NUM_PROCESSORS: g_value_set_int (value, gegl_config->num_processors); break; + case PROP_TILE_CACHE_SIZE: g_value_set_uint64 (value, gegl_config->tile_cache_size); break; + case PROP_USE_OPENCL: g_value_set_boolean (value, gegl_config->use_opencl); break; diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index 7a4063d432..c2cddbcffb 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -599,12 +599,12 @@ gimp_gui_config_finalize (GObject *object) { GimpGuiConfig *gui_config = GIMP_GUI_CONFIG (object); - g_free (gui_config->theme_path); - g_free (gui_config->theme); - g_free (gui_config->icon_theme_path); - g_free (gui_config->icon_theme); - g_free (gui_config->help_locales); - g_free (gui_config->user_manual_online_uri); + g_clear_pointer (&gui_config->theme_path, g_free); + g_clear_pointer (&gui_config->theme, g_free); + g_clear_pointer (&gui_config->icon_theme_path, g_free); + g_clear_pointer (&gui_config->icon_theme, g_free); + g_clear_pointer (&gui_config->help_locales, g_free); + g_clear_pointer (&gui_config->user_manual_online_uri, g_free); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -683,13 +683,13 @@ gimp_gui_config_set_property (GObject *object, case PROP_TOOLBOX_GROUPS: gui_config->toolbox_groups = g_value_get_boolean (value); break; - case PROP_THEME_PATH: - g_free (gui_config->theme_path); - gui_config->theme_path = g_value_dup_string (value); + case PROP_THEME_PATH: + g_set_str (&gui_config->theme_path, + g_value_get_string (value)); break; case PROP_THEME: - g_free (gui_config->theme); - gui_config->theme = g_value_dup_string (value); + g_set_str (&gui_config->theme, + g_value_get_string (value)); break; case PROP_THEME_SCHEME: gui_config->theme_scheme = g_value_get_enum (value); @@ -704,12 +704,12 @@ gimp_gui_config_set_property (GObject *object, gui_config->viewables_follow_theme = g_value_get_boolean (value); break; case PROP_ICON_THEME_PATH: - g_free (gui_config->icon_theme_path); - gui_config->icon_theme_path = g_value_dup_string (value); + g_set_str (&gui_config->icon_theme_path, + g_value_get_string (value)); break; case PROP_ICON_THEME: - g_free (gui_config->icon_theme); - gui_config->icon_theme = g_value_dup_string (value); + g_set_str (&gui_config->icon_theme, + g_value_get_string (value)); break; case PROP_PREFER_SYMBOLIC_ICONS: gui_config->prefer_symbolic_icons = g_value_get_boolean (value); @@ -724,8 +724,8 @@ gimp_gui_config_set_property (GObject *object, gui_config->show_help_button = g_value_get_boolean (value); break; case PROP_HELP_LOCALES: - g_free (gui_config->help_locales); - gui_config->help_locales = g_value_dup_string (value); + g_set_str (&gui_config->help_locales, + g_value_get_string (value)); break; case PROP_HELP_BROWSER: gui_config->help_browser = g_value_get_enum (value); @@ -734,8 +734,8 @@ gimp_gui_config_set_property (GObject *object, gui_config->user_manual_online = g_value_get_boolean (value); break; case PROP_USER_MANUAL_ONLINE_URI: - g_free (gui_config->user_manual_online_uri); - gui_config->user_manual_online_uri = g_value_dup_string (value); + g_set_str (&gui_config->user_manual_online_uri, + g_value_get_string (value)); break; case PROP_ACTION_HISTORY_SIZE: gui_config->action_history_size = g_value_get_int (value); diff --git a/app/config/gimppluginconfig.c b/app/config/gimppluginconfig.c index 5fb4fe2fa7..37e80eb3ab 100644 --- a/app/config/gimppluginconfig.c +++ b/app/config/gimppluginconfig.c @@ -130,11 +130,11 @@ gimp_plugin_config_finalize (GObject *object) { GimpPluginConfig *plugin_config = GIMP_PLUGIN_CONFIG (object); - g_free (plugin_config->fractalexplorer_path); - g_free (plugin_config->gfig_path); - g_free (plugin_config->gflare_path); - g_free (plugin_config->gimpressionist_path); - g_free (plugin_config->script_fu_path); + g_clear_pointer (&plugin_config->fractalexplorer_path, g_free); + g_clear_pointer (&plugin_config->gfig_path, g_free); + g_clear_pointer (&plugin_config->gflare_path, g_free); + g_clear_pointer (&plugin_config->gimpressionist_path, g_free); + g_clear_pointer (&plugin_config->script_fu_path, g_free); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -150,28 +150,28 @@ gimp_plugin_config_set_property (GObject *object, switch (property_id) { case PROP_FRACTALEXPLORER_PATH: - g_free (plugin_config->fractalexplorer_path); - plugin_config->fractalexplorer_path = g_value_dup_string (value); + g_set_str (&plugin_config->fractalexplorer_path, + g_value_get_string (value)); break; case PROP_GFIG_PATH: - g_free (plugin_config->gfig_path); - plugin_config->gfig_path = g_value_dup_string (value); + g_set_str (&plugin_config->gfig_path, + g_value_get_string (value)); break; case PROP_GFLARE_PATH: - g_free (plugin_config->gflare_path); - plugin_config->gflare_path = g_value_dup_string (value); + g_set_str (&plugin_config->gflare_path, + g_value_get_string (value)); break; case PROP_GIMPRESSIONIST_PATH: - g_free (plugin_config->gimpressionist_path); - plugin_config->gimpressionist_path = g_value_dup_string (value); + g_set_str (&plugin_config->gimpressionist_path, + g_value_get_string (value)); break; case PROP_SCRIPT_FU_PATH: - g_free (plugin_config->script_fu_path); - plugin_config->script_fu_path = g_value_dup_string (value); + g_set_str (&plugin_config->script_fu_path, + g_value_get_string (value)); break; default: diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index c5fba7601d..8de71fd4f1 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -2296,8 +2296,8 @@ static void gimp_context_paint_info_dirty (GimpPaintInfo *paint_info, GimpContext *context) { - g_free (context->paint_name); - context->paint_name = g_strdup (gimp_object_get_name (paint_info)); + g_set_str (&context->paint_name, + gimp_object_get_name (paint_info)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_PAINT_INFO); @@ -2646,8 +2646,8 @@ static void gimp_context_brush_dirty (GimpBrush *brush, GimpContext *context) { - g_free (context->brush_name); - context->brush_name = g_strdup (gimp_object_get_name (brush)); + g_set_str (&context->brush_name, + gimp_object_get_name (brush)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_BRUSH); @@ -2760,8 +2760,8 @@ static void gimp_context_dynamics_dirty (GimpDynamics *dynamics, GimpContext *context) { - g_free (context->dynamics_name); - context->dynamics_name = g_strdup (gimp_object_get_name (dynamics)); + g_set_str (&context->dynamics_name, + gimp_object_get_name (dynamics)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_DYNAMICS); @@ -2873,8 +2873,8 @@ static void gimp_context_mybrush_dirty (GimpMybrush *brush, GimpContext *context) { - g_free (context->mybrush_name); - context->mybrush_name = g_strdup (gimp_object_get_name (brush)); + g_set_str (&context->mybrush_name, + gimp_object_get_name (brush)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_MYBRUSH); @@ -2986,8 +2986,8 @@ static void gimp_context_pattern_dirty (GimpPattern *pattern, GimpContext *context) { - g_free (context->pattern_name); - context->pattern_name = g_strdup (gimp_object_get_name (pattern)); + g_set_str (&context->pattern_name, + gimp_object_get_name (pattern)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_PATTERN); @@ -3099,8 +3099,8 @@ static void gimp_context_gradient_dirty (GimpGradient *gradient, GimpContext *context) { - g_free (context->gradient_name); - context->gradient_name = g_strdup (gimp_object_get_name (gradient)); + g_set_str (&context->gradient_name, + gimp_object_get_name (gradient)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_GRADIENT); @@ -3212,8 +3212,8 @@ static void gimp_context_palette_dirty (GimpPalette *palette, GimpContext *context) { - g_free (context->palette_name); - context->palette_name = g_strdup (gimp_object_get_name (palette)); + g_set_str (&context->palette_name, + gimp_object_get_name (palette)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_PALETTE); @@ -3344,8 +3344,7 @@ gimp_context_set_font_name (GimpContext *context, */ gimp_context_set_font (context, GIMP_FONT (gimp_font_get_standard ())); - g_free (context->font_name); - context->font_name = g_strdup (name); + g_set_str (&context->font_name, name); } } @@ -3363,8 +3362,8 @@ static void gimp_context_font_dirty (GimpFont *font, GimpContext *context) { - g_free (context->font_name); - context->font_name = g_strdup (gimp_object_get_name (font)); + g_set_str (&context->font_name, + gimp_object_get_name (font)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_FONT); @@ -3476,8 +3475,8 @@ static void gimp_context_tool_preset_dirty (GimpToolPreset *tool_preset, GimpContext *context) { - g_free (context->tool_preset_name); - context->tool_preset_name = g_strdup (gimp_object_get_name (tool_preset)); + g_set_str (&context->tool_preset_name, + gimp_object_get_name (tool_preset)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_TOOL_PRESET); @@ -3584,8 +3583,8 @@ static void gimp_context_buffer_dirty (GimpBuffer *buffer, GimpContext *context) { - g_free (context->buffer_name); - context->buffer_name = g_strdup (gimp_object_get_name (buffer)); + g_set_str (&context->buffer_name, + gimp_object_get_name (buffer)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_BUFFER); @@ -3700,8 +3699,8 @@ static void gimp_context_imagefile_dirty (GimpImagefile *imagefile, GimpContext *context) { - g_free (context->imagefile_name); - context->imagefile_name = g_strdup (gimp_object_get_name (imagefile)); + g_set_str (&context->imagefile_name, + gimp_object_get_name (imagefile)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_IMAGEFILE); @@ -3816,8 +3815,8 @@ static void gimp_context_template_dirty (GimpTemplate *template, GimpContext *context) { - g_free (context->template_name); - context->template_name = g_strdup (gimp_object_get_name (template)); + g_set_str (&context->template_name, + gimp_object_get_name (template)); g_signal_emit (context, gimp_context_signals[PROP_NAME_CHANGED], 0, GIMP_CONTEXT_PROP_TEMPLATE); diff --git a/app/display/gimptoolgui.c b/app/display/gimptoolgui.c index 02b1a53ae1..eb7d36fb42 100644 --- a/app/display/gimptoolgui.c +++ b/app/display/gimptoolgui.c @@ -273,8 +273,7 @@ gimp_tool_gui_set_title (GimpToolGui *gui, if (title == private->title) return; - g_free (private->title); - private->title = g_strdup (title); + g_set_str (&private->title, title); if (! title) title = private->tool_info->label; @@ -295,8 +294,7 @@ gimp_tool_gui_set_description (GimpToolGui *gui, if (description == private->description) return; - g_free (private->description); - private->description = g_strdup (description); + g_set_str (&private->description, description); if (! description) description = private->tool_info->tooltip; @@ -324,8 +322,7 @@ gimp_tool_gui_set_icon_name (GimpToolGui *gui, if (icon_name == private->icon_name) return; - g_free (private->icon_name); - private->icon_name = g_strdup (icon_name); + g_set_str (&private->icon_name, icon_name); if (! icon_name) icon_name = gimp_viewable_get_icon_name (GIMP_VIEWABLE (private->tool_info)); @@ -346,8 +343,7 @@ gimp_tool_gui_set_help_id (GimpToolGui *gui, if (help_id == private->help_id) return; - g_free (private->help_id); - private->help_id = g_strdup (help_id); + g_set_str (&private->help_id, help_id); if (! help_id) help_id = private->tool_info->help_id;