[gimp/gimp-2-10] app: explicitly close output stream when saving internal data
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: explicitly close output stream when saving internal data
- Date: Mon, 2 Jul 2018 15:49:52 +0000 (UTC)
commit 4569fdd34b7397a16e09e1c314c844bb1e13407f
Author: Ell <ell_se yahoo com>
Date: Mon Jul 2 11:27:21 2018 -0400
app: explicitly close output stream when saving internal data
According to some bug reports, it seems that under some (unknown)
conditions we might save an empty custom gradient file on exit (for
equally unknown reasons). The only difference in the way we save
internal data files, such as the custom gradient, compared to
gimp_data_save(), is the fact that we currently don't explicitly
close the output stream, but rather only unref it.
The output stream should be implicitly closed (and hence flushed)
upon destruction, but maybe the unreffing is not enough to
guarantee that it's actually destroyed (maybe it spawns an extra
reference for some reason, who knows.) Anyway, let's just
explicitly close it, which also gives us a chance to catch and
report any errors occursing during flushing/closing (which,
altenatively, might be the culprit).
Additionally, a few more error-reporting improvements, to match
gimp_data_save().
(cherry picked from commit a72f7f1ace72576ce24e6790d450ac65ce0746f9)
app/core/gimp-internal-data.c | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimp-internal-data.c b/app/core/gimp-internal-data.c
index 094eeb738c..ed8ea5a139 100644
--- a/app/core/gimp-internal-data.c
+++ b/app/core/gimp-internal-data.c
@@ -258,10 +258,12 @@ gimp_internal_data_save_data_file (Gimp *gimp,
G_FILE_CREATE_NONE,
NULL, error));
- g_object_unref (file);
-
if (! output)
- return FALSE;
+ {
+ g_object_unref (file);
+
+ return FALSE;
+ }
data = data_file->get_func (gimp);
@@ -276,7 +278,31 @@ gimp_internal_data_save_data_file (Gimp *gimp,
gimp_assert (GIMP_DATA_GET_CLASS (data)->save);
success = GIMP_DATA_GET_CLASS (data)->save (data, output, error);
+ if (success)
+ {
+ if (! g_output_stream_close (output, NULL, error))
+ {
+ g_prefix_error (error,
+ _("Error saving '%s': "),
+ gimp_file_get_utf8_name (file));
+ success = FALSE;
+ }
+ }
+ else if (error && *error)
+ {
+ g_prefix_error (error,
+ _("Error saving '%s': "),
+ gimp_file_get_utf8_name (file));
+ }
+ else
+ {
+ g_set_error (error, GIMP_DATA_ERROR, GIMP_DATA_ERROR_WRITE,
+ _("Error saving '%s'"),
+ gimp_file_get_utf8_name (file));
+ }
+
g_object_unref (output);
+ g_object_unref (file);
return success;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]