Commit 9fa112f6 authored by Jehan's avatar Jehan

Bug 690728: file-gif-save plug-in crops the actual image the user is working on.

Destructive behavior fixed by duplicating the image first, then deleting
the duplicate at the end.
parent 5d07d805
......@@ -104,7 +104,7 @@ static gboolean save_image (const gchar *filename,
GError **error);
static GimpPDBStatusType sanity_check (const gchar *filename,
gint32 image_ID,
gint32 *image_ID,
GError **error);
static gboolean bad_bounds_dialog (void);
......@@ -210,7 +210,7 @@ run (const gchar *name,
if (strcmp (name, SAVE_PROC) == 0)
{
const gchar *filename;
gint32 image_ID;
gint32 image_ID, sanitized_image_ID = 0;
gint32 drawable_ID;
gint32 orig_image_ID;
......@@ -222,11 +222,15 @@ run (const gchar *name,
run_mode == GIMP_RUN_WITH_LAST_VALS)
gimp_ui_init (PLUG_IN_BINARY, FALSE);
status = sanity_check (filename, image_ID, &error);
status = sanity_check (filename, &image_ID, &error);
/* Get the export options */
if (status == GIMP_PDB_SUCCESS)
{
/* If the sanity check succeeded, the image_ID will point to
* a duplicate image to delete later. */
sanitized_image_ID = image_ID;
switch (run_mode)
{
case GIMP_RUN_INTERACTIVE:
......@@ -284,6 +288,8 @@ run (const gchar *name,
if (export == GIMP_EXPORT_CANCEL)
{
values[0].data.d_status = GIMP_PDB_CANCEL;
if (sanitized_image_ID)
gimp_image_delete (sanitized_image_ID);
return;
}
}
......@@ -306,6 +312,8 @@ run (const gchar *name,
{
status = GIMP_PDB_EXECUTION_ERROR;
}
gimp_image_delete (sanitized_image_ID);
}
if (export == GIMP_EXPORT_EXPORT)
......@@ -566,7 +574,7 @@ parse_disposal_tag (const gchar *str)
static GimpPDBStatusType
sanity_check (const gchar *filename,
gint32 image_ID,
gint32 *image_ID,
GError **error)
{
gint32 *layers;
......@@ -575,8 +583,8 @@ sanity_check (const gchar *filename,
gint image_height;
gint i;
image_width = gimp_image_width (image_ID);
image_height = gimp_image_height (image_ID);
image_width = gimp_image_width (*image_ID);
image_height = gimp_image_height (*image_ID);
if (image_width > G_MAXUSHORT || image_height > G_MAXUSHORT)
{
......@@ -592,7 +600,8 @@ sanity_check (const gchar *filename,
/*** Iterate through the layers to make sure they're all ***/
/*** within the bounds of the image ***/
layers = gimp_image_get_layers (image_ID, &nlayers);
*image_ID = gimp_image_duplicate (*image_ID);
layers = gimp_image_get_layers (*image_ID, &nlayers);
for (i = 0; i < nlayers; i++)
{
......@@ -615,11 +624,12 @@ sanity_check (const gchar *filename,
*/
if ((run_mode == GIMP_RUN_NONINTERACTIVE) || bad_bounds_dialog ())
{
gimp_image_crop (image_ID, image_width, image_height, 0, 0);
gimp_image_crop (*image_ID, image_width, image_height, 0, 0);
return GIMP_PDB_SUCCESS;
}
else
{
gimp_image_delete (*image_ID);
return GIMP_PDB_CANCEL;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment