[gimp] Bug 646371 - The wrong file gets saved when exporting with overwrite
- From: Martin Nordholts <martinn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 646371 - The wrong file gets saved when exporting with overwrite
- Date: Sun, 3 Apr 2011 14:57:38 +0000 (UTC)
commit a8f552da2fb3887f75aa0c7502a54ddcd003e292
Author: Martin Nordholts <martinn src gnome org>
Date: Sun Apr 3 16:54:34 2011 +0200
Bug 646371 - The wrong file gets saved when exporting with overwrite
An image can not be considered both exported and imported at the same
time, so stop consider it as imported after we consider it exported.
Also add an automatic regression test.
app/file/file-save.c | 6 +++
app/tests/test-save-and-export.c | 67 ++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/app/file/file-save.c b/app/file/file-save.c
index 356cc81..3a5b990 100644
--- a/app/file/file-save.c
+++ b/app/file/file-save.c
@@ -177,6 +177,12 @@ file_save (Gimp *gimp,
*/
gimp_image_set_exported_uri (image, uri);
+ /* An image can not be considered both exported and imported
+ * at the same time, so stop consider it as imported now
+ * that we consider it exported.
+ */
+ gimp_image_set_imported_uri (image, NULL);
+
gimp_image_export_clean_all (image);
}
diff --git a/app/tests/test-save-and-export.c b/app/tests/test-save-and-export.c
index 821e872..5c2aba6 100644
--- a/app/tests/test-save-and-export.c
+++ b/app/tests/test-save-and-export.c
@@ -291,6 +291,72 @@ exported_file_uris (GimpTestFixture *fixture,
g_unlink (save_filename);
}
+/**
+ * clear_import_uri_after_export:
+ * @fixture:
+ * @data:
+ *
+ * Tests that after a XCF file that was imported has been exported,
+ * the import URI is cleared. An image can not be considered both
+ * imported and exported at the same time.
+ **/
+static void
+clear_import_uri_after_export (GimpTestFixture *fixture,
+ gconstpointer data)
+{
+ Gimp *gimp = GIMP (data);
+ GimpImage *image;
+ gchar *uri;
+ gchar *filename;
+ gchar *save_uri;
+ gchar *save_filename;
+ GimpPlugInProcedure *proc;
+ GimpPDBStatusType status;
+
+ filename = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
+ "desktop/64x64/gimp.png",
+ NULL);
+ uri = g_filename_to_uri (filename, NULL, NULL);
+
+ image = file_open_image (gimp,
+ gimp_get_user_context (gimp),
+ NULL /*progress*/,
+ uri,
+ filename,
+ FALSE /*as_new*/,
+ NULL /*file_proc*/,
+ GIMP_RUN_NONINTERACTIVE,
+ &status,
+ NULL /*mime_type*/,
+ NULL /*error*/);
+
+ g_assert (gimp_image_get_uri (image) == NULL);
+ g_assert_cmpstr (gimp_image_get_imported_uri (image), ==, uri);
+ g_assert (gimp_image_get_exported_uri (image) == NULL);
+
+ save_filename = g_build_filename (g_get_tmp_dir (), "gimp-test.png", NULL);
+ save_uri = g_filename_to_uri (save_filename, NULL, NULL);
+
+ proc = file_procedure_find (image->gimp->plug_in_manager->export_procs,
+ save_uri,
+ NULL /*error*/);
+ file_save (gimp,
+ image,
+ NULL /*progress*/,
+ save_uri,
+ proc,
+ GIMP_RUN_NONINTERACTIVE,
+ FALSE /*change_saved_state*/,
+ TRUE /*export*/,
+ NULL /*error*/);
+
+ g_assert (gimp_image_get_uri (image) == NULL);
+ g_assert (gimp_image_get_imported_uri (image) == NULL);
+ g_assert_cmpstr (gimp_image_get_exported_uri (image), ==, save_uri);
+
+ g_unlink (save_filename);
+}
+
int main(int argc, char **argv)
{
Gimp *gimp = NULL;
@@ -312,6 +378,7 @@ int main(int argc, char **argv)
ADD_TEST (imported_file_uris);
ADD_TEST (saved_imported_file_uris);
ADD_TEST (exported_file_uris);
+ ADD_TEST (clear_import_uri_after_export);
/* Run the tests and return status */
result = g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]