diff --git a/app/config/gimpconfig-file.c b/app/config/gimpconfig-file.c index 20cf940de4..0d425efa02 100644 --- a/app/config/gimpconfig-file.c +++ b/app/config/gimpconfig-file.c @@ -211,20 +211,22 @@ gimp_config_file_copy (const gchar *source, } gboolean -gimp_config_file_backup_on_error (const gchar *filename, +gimp_config_file_backup_on_error (GFile *file, const gchar *name, GError **error) { + gchar *path; gchar *backup; gboolean success; - g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - backup = g_strconcat (filename, "~", NULL); + path = g_file_get_path (file); + backup = g_strconcat (path, "~", NULL); - success = gimp_config_file_copy (filename, backup, NULL, NULL, error); + success = gimp_config_file_copy (path, backup, NULL, NULL, error); if (success) g_message (_("There was an error parsing your '%s' file. " @@ -233,6 +235,7 @@ gimp_config_file_backup_on_error (const gchar *filename, name, gimp_filename_to_utf8 (backup)); g_free (backup); + g_free (path); return success; } diff --git a/app/config/gimpconfig-file.h b/app/config/gimpconfig-file.h index 2ffc73224c..80c49eaa12 100644 --- a/app/config/gimpconfig-file.h +++ b/app/config/gimpconfig-file.h @@ -26,10 +26,11 @@ gboolean gimp_config_file_copy (const gchar *source, const gchar *dest, const gchar *old_options_regexp, GRegexEvalCallback update_callback, - GError **error); -gboolean gimp_config_file_backup_on_error (const gchar *filename, - const gchar *name, - GError **error); + GError **error); + +gboolean gimp_config_file_backup_on_error (GFile *file, + const gchar *name, + GError **error); #endif /* __GIMP_CONFIG_FILE_H__ */ diff --git a/app/config/gimprc.c b/app/config/gimprc.c index 3d6253989d..c9a15a2f6f 100644 --- a/app/config/gimprc.c +++ b/app/config/gimprc.c @@ -277,9 +277,13 @@ gimp_rc_load (GimpRc *rc) { if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) { + GFile *file; + g_message ("%s", error->message); - gimp_config_file_backup_on_error (rc->user_gimprc, "gimprc", NULL); + file = g_file_new_for_path (rc->user_gimprc); + gimp_config_file_backup_on_error (file, "gimprc", NULL); + g_object_unref (file); } g_clear_error (&error); diff --git a/app/core/gimp-units.c b/app/core/gimp-units.c index 8032854211..cdb8bd887a 100644 --- a/app/core/gimp-units.c +++ b/app/core/gimp-units.c @@ -167,8 +167,6 @@ gimp_unitrc_load (Gimp *gimp) if (token != G_TOKEN_LEFT_PAREN) { - gchar *tmp; - g_scanner_get_next_token (scanner); g_scanner_unexp_token (scanner, token, NULL, NULL, NULL, _("fatal parse error"), TRUE); @@ -176,9 +174,7 @@ gimp_unitrc_load (Gimp *gimp) gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); - tmp = g_file_get_path (file); - gimp_config_file_backup_on_error (tmp, "unitrc", NULL); - g_free (tmp); + gimp_config_file_backup_on_error (file, "unitrc", NULL); } gimp_scanner_destroy (scanner); diff --git a/app/gui/session.c b/app/gui/session.c index d6349d3e01..c8e366c790 100644 --- a/app/gui/session.c +++ b/app/gui/session.c @@ -298,14 +298,10 @@ session_init (Gimp *gimp) if (error) { - gchar *tmp; - gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); - tmp = g_file_get_path (file); - gimp_config_file_backup_on_error (tmp, "sessionrc", NULL); - g_free (tmp); + gimp_config_file_backup_on_error (file, "sessionrc", NULL); } gimp_scanner_destroy (scanner);