plug-ins: get rid of various gimp_image_set_file() calls.

- This is unneeded in all import procedures. See previous commit. Note though
  that this is not because of a change in previous commit. This was already
  useless previously. The file set with this PDB function was overridden by the
  core anyway (i.e. even before the previous commits).
  In app/file/file-import.c:file_import_image(), the imported file is correctly
  set (so there is no need to set it from plug-in, which anyway libgimp's
  gimp_image_set_file() was not doing) and the XCF file is reset to NULL
  (rendering the call to gimp_image_set_file() in a GimpLoadProcedure useless).
- Similarly, this is a useless call in export procedures because
  app/file/file-save.c:file_save() overrides such call too. I could only see one
  such case for JPEG export, which was quite useless.
- Finally in other types of plug-ins, setting a non-XCF file extension was
  interfering with the save feature (similarly to commit e6e73e14c7). I only
  fixed the screenshot implementations doing such a thing.
- I left a few usages which will have to be looked at more in details later.
This commit is contained in:
Jehan 2023-02-13 22:33:35 +01:00
parent fc2925def0
commit 4f1d0fb53b
42 changed files with 4 additions and 169 deletions

View File

@ -491,8 +491,6 @@ load_image (GFile *file,
return NULL; return NULL;
} }
gimp_image_set_file (image, file);
/* Create an indexed-alpha layer to hold the image... */ /* Create an indexed-alpha layer to hold the image... */
if (bpp == 32) if (bpp == 32)
layer = gimp_layer_new (image, _("Background"), width, height, layer = gimp_layer_new (image, _("Background"), width, height,

View File

@ -741,7 +741,6 @@ load_image (GFile *file,
image = gimp_image_new (dicominfo->width, dicominfo->height, image = gimp_image_new (dicominfo->width, dicominfo->height,
(dicominfo->samples_per_pixel >= 3 ? (dicominfo->samples_per_pixel >= 3 ?
GIMP_RGB : GIMP_GRAY)); GIMP_RGB : GIMP_GRAY));
gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
dicominfo->width, dicominfo->height, dicominfo->width, dicominfo->height,

View File

@ -462,8 +462,6 @@ load_image (GFile *file,
image = gimp_image_new_with_precision (width, height, image = gimp_image_new_with_precision (width, height,
base_type, precision); base_type, precision);
gimp_image_set_file (image, file);
layer = gimp_layer_new (image, layer = gimp_layer_new (image,
_("Background"), _("Background"),
width, height, width, height,

View File

@ -1021,7 +1021,6 @@ ReadImage (FILE *fd,
screenheight = height; screenheight = height;
*image = gimp_image_new (screenwidth, screenheight, GIMP_INDEXED); *image = gimp_image_new (screenwidth, screenheight, GIMP_INDEXED);
gimp_image_set_file (*image, file);
for (i = 0, j = 0; i < ncols; i++) for (i = 0, j = 0; i < ncols; i++)
{ {

View File

@ -1164,7 +1164,6 @@ load_image (GFile *file,
} }
image = gimp_image_new_with_precision (width, height, GIMP_RGB, precision); image = gimp_image_new_with_precision (width, height, GIMP_RGB, precision);
gimp_image_set_file (image, file);
if (profile) if (profile)
{ {

View File

@ -1304,8 +1304,6 @@ load_image (GFile *file,
gimp_image = gimp_image_new_with_precision (width, height, gimp_image = gimp_image_new_with_precision (width, height,
base_type, image_precision); base_type, image_precision);
gimp_image_set_file (gimp_image, file);
if (profile) if (profile)
gimp_image_set_color_profile (gimp_image, profile); gimp_image_set_color_profile (gimp_image, profile);

View File

@ -491,7 +491,6 @@ load_image (GFile *file,
gimp_image_get_default_new_layer_mode (image)); gimp_image_get_default_new_layer_mode (image));
} }
gimp_image_set_file (image, file);
gimp_image_set_resolution (image, resolution_x, resolution_y); gimp_image_set_resolution (image, resolution_x, resolution_y);
gimp_image_insert_layer (image, layer, NULL, 0); gimp_image_insert_layer (image, layer, NULL, 0);

View File

@ -844,30 +844,9 @@ load_image (PopplerDocument *doc,
if (! image) if (! image)
{ {
GFile *new_file;
gchar *uri;
gchar *new_uri;
image = gimp_image_new (width, height, GIMP_RGB); image = gimp_image_new (width, height, GIMP_RGB);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
uri = g_file_get_uri (file);
if (target == GIMP_PAGE_SELECTOR_TARGET_IMAGES)
new_uri = g_strdup_printf (_("%s-%s"), uri, page_label);
else
new_uri = g_strdup_printf (_("%s-pages"), uri);
g_free (uri);
new_file = g_file_new_for_uri (new_uri);
g_free (new_uri);
gimp_image_set_file (image, new_file);
g_object_unref (new_file);
gimp_image_set_resolution (image, resolution, resolution); gimp_image_set_resolution (image, resolution, resolution);
} }

View File

@ -419,8 +419,6 @@ load_image (GFile *file,
} }
image = gimp_image_new (width, height, imgtype); image = gimp_image_new (width, height, imgtype);
gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
width, height, width, height,
gdtype, gdtype,

View File

@ -1031,8 +1031,6 @@ load_image (GFile *file,
} }
gimp_image_set_file ((GimpImage *) image, file);
/* /*
* Load the colormap as necessary... * Load the colormap as necessary...
*/ */

View File

@ -837,8 +837,6 @@ load_image (GFile *file,
(pnminfo->np >= 3) ? GIMP_RGB : GIMP_GRAY, (pnminfo->np >= 3) ? GIMP_RGB : GIMP_GRAY,
precision); precision);
gimp_image_set_file (image, file);
switch (pnminfo->np) switch (pnminfo->np)
{ {
case 0: case 0:
@ -2246,4 +2244,4 @@ pnmscanner_getheaderline (PNMScanner *s,
} }
pnmscanner_gettoken (s, buf, bufsize); pnmscanner_gettoken (s, buf, bufsize);
} }

View File

@ -1239,8 +1239,6 @@ load_image (GFile *file,
image = gimp_image_new (urx, ury, GIMP_RGB); image = gimp_image_new (urx, ury, GIMP_RGB);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
gimp_image_set_file (image, file);
gimp_image_set_resolution (image, gimp_image_set_resolution (image,
plvals.resolution, plvals.resolution,
plvals.resolution); plvals.resolution);
@ -2044,9 +2042,6 @@ create_new_image (GFile *file,
{ {
GimpImage *image; GimpImage *image;
GimpImageType gdtype; GimpImageType gdtype;
GFile *new_file;
gchar *uri;
gchar *new_uri;
gchar *tmp; gchar *tmp;
switch (type) switch (type)
@ -2066,17 +2061,6 @@ create_new_image (GFile *file,
GIMP_PRECISION_U8_NON_LINEAR); GIMP_PRECISION_U8_NON_LINEAR);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
uri = g_file_get_uri (file);
new_uri = g_strdup_printf ("%s-%d", uri, pagenum);
g_free (uri);
new_file = g_file_new_for_uri (new_uri);
g_free (new_uri);
gimp_image_set_file (image, new_file);
g_object_unref (new_file);
tmp = g_strdup_printf (_("Page %d"), pagenum); tmp = g_strdup_printf (_("Page %d"), pagenum);
*layer = gimp_layer_new (image, tmp, width, height, *layer = gimp_layer_new (image, tmp, width, height,
gdtype, gdtype,

View File

@ -2461,8 +2461,6 @@ load_image (GFile *file,
goto error; goto error;
} }
gimp_image_set_file (image, file);
gimp_image_set_resolution (image, ia.resolution, ia.resolution); gimp_image_set_resolution (image, ia.resolution, ia.resolution);
} }
else else

View File

@ -1833,7 +1833,6 @@ load_image (GFile *file,
data->image = gimp_image_new_with_precision (width, height, itype, precision); data->image = gimp_image_new_with_precision (width, height, itype, precision);
gimp_image_set_file (data->image, file);
layer = gimp_layer_new (data->image, _("Background"), layer = gimp_layer_new (data->image, _("Background"),
width, height, ltype, 100, width, height, ltype, 100,
gimp_image_get_default_new_layer_mode (data->image)); gimp_image_get_default_new_layer_mode (data->image));

View File

@ -1076,7 +1076,6 @@ create_new_image (GFile *file,
} }
image = gimp_image_new (width, height, type); image = gimp_image_new (width, height, type);
gimp_image_set_file (image, file);
*layer = gimp_layer_new (image, _("Background"), width, height, *layer = gimp_layer_new (image, _("Background"), width, height,
gdtype, gdtype,

View File

@ -378,7 +378,6 @@ load_image (GFile *file,
image = gimp_image_new (width, height, GIMP_RGB); image = gimp_image_new (width, height, GIMP_RGB);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
gimp_image_set_file (image, file);
gimp_image_set_resolution (image, gimp_image_set_resolution (image,
load_vals.resolution, load_vals.resolution); load_vals.resolution, load_vals.resolution);

View File

@ -1101,7 +1101,6 @@ ReadImage (FILE *fp,
} }
image = gimp_image_new (info->width, info->height, itype); image = gimp_image_new (info->width, info->height, itype);
gimp_image_set_file (image, file);
if (gimp_cmap) if (gimp_cmap)
gimp_image_set_colormap (image, gimp_cmap, info->colorMapLength); gimp_image_set_colormap (image, gimp_cmap, info->colorMapLength);

View File

@ -271,7 +271,6 @@ read_image (FILE *fd,
GIMP_INDEXED_IMAGE, 100, GIMP_INDEXED_IMAGE, 100,
gimp_image_get_default_new_layer_mode (image)); gimp_image_get_default_new_layer_mode (image));
gimp_image_set_file (image, file);
gimp_image_set_colormap (image, mono, 2); gimp_image_set_colormap (image, mono, 2);
gimp_image_insert_layer (image, layer, NULL, 0); gimp_image_insert_layer (image, layer, NULL, 0);

View File

@ -1032,7 +1032,6 @@ load_image (GFile *file,
return NULL; return NULL;
image = gimp_image_new (width, height, GIMP_RGB); image = gimp_image_new (width, height, GIMP_RGB);
gimp_image_set_file (image, file);
gimp_image_set_resolution (image, gimp_image_set_resolution (image,
load_vals.resolution, load_vals.resolution); load_vals.resolution, load_vals.resolution);

View File

@ -871,7 +871,6 @@ load_image (GFile *file,
} }
image = gimp_image_new (width, height, GIMP_INDEXED); image = gimp_image_new (width, height, GIMP_INDEXED);
gimp_image_set_file (image, file);
if (comment) if (comment)
{ {

View File

@ -699,8 +699,6 @@ load_image (GFile *file,
image = gimp_image_new (img_width, img_height, GIMP_RGB); image = gimp_image_new (img_width, img_height, GIMP_RGB);
gimp_image_set_file (image, file);
if (! set_hotspot_to_parasite (image, hot_spot_x, hot_spot_y)) if (! set_hotspot_to_parasite (image, hot_spot_x, hot_spot_y))
{ {
fclose (fp); fclose (fp);

View File

@ -409,8 +409,6 @@ load_image (GFile *file,
xpm_image.height, xpm_image.height,
GIMP_RGB); GIMP_RGB);
gimp_image_set_file (image, file);
/* fill it */ /* fill it */
parse_image (image, &xpm_image, cmap); parse_image (image, &xpm_image, cmap);

View File

@ -1300,7 +1300,6 @@ create_new_image (GFile *file,
GimpImage *image; GimpImage *image;
image = gimp_image_new (width, height, type); image = gimp_image_new (width, height, type);
gimp_image_set_file (image, file);
*layer = gimp_layer_new (image, "Background", width, height, *layer = gimp_layer_new (image, "Background", width, height,
gdtype, gdtype,

View File

@ -738,9 +738,6 @@ ReadImage (FILE *fd,
width, height, width, height,
image_type, 100, image_type, 100,
gimp_image_get_default_new_layer_mode (image)); gimp_image_get_default_new_layer_mode (image));
gimp_image_set_file (image, file);
gimp_image_insert_layer (image, layer, NULL, 0); gimp_image_insert_layer (image, layer, NULL, 0);
/* use g_malloc0 to initialize the dest buffer so that unspecified /* use g_malloc0 to initialize the dest buffer so that unspecified

View File

@ -368,8 +368,6 @@ read_dds (GFile *file,
return GIMP_PDB_EXECUTION_ERROR; return GIMP_PDB_EXECUTION_ERROR;
} }
gimp_image_set_file (image, file);
if (hdr.pixelfmt.flags & DDPF_PALETTEINDEXED8) if (hdr.pixelfmt.flags & DDPF_PALETTEINDEXED8)
{ {
d.palette = g_malloc (256 * 4); d.palette = g_malloc (256 * 4);

View File

@ -257,8 +257,6 @@ load_image (GFile *file,
goto out; goto out;
} }
gimp_image_set_file (image, file);
/* try to load an icc profile, it will be generated on the fly if /* try to load an icc profile, it will be generated on the fly if
* chromaticities are given * chromaticities are given
*/ */

View File

@ -570,7 +570,6 @@ emitgimp (gint hcol,
_("Could not create image.")); _("Could not create image."));
return NULL; return NULL;
} }
gimp_image_set_file (image, file);
layer = gimp_layer_new (image, _("Background"), layer = gimp_layer_new (image, _("Background"),
hcol, hcol,

View File

@ -535,23 +535,9 @@ create_new_image (GFile *file,
GeglBuffer **buffer) GeglBuffer **buffer)
{ {
GimpImage *image; GimpImage *image;
GFile *new_file;
gchar *uri;
gchar *new_uri;
image = gimp_image_new_with_precision (width, height, itype, iprecision); image = gimp_image_new_with_precision (width, height, itype, iprecision);
uri = g_file_get_uri (file);
new_uri = g_strdup_printf ("%s-img%d", uri, pagenum);
g_free (uri);
new_file = g_file_new_for_uri (new_uri);
g_free (new_uri);
gimp_image_set_file (image, new_file);
g_object_unref (new_file);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
*layer = gimp_layer_new (image, _("Background"), width, height, *layer = gimp_layer_new (image, _("Background"), width, height,
dtype, 100, dtype, 100,

View File

@ -559,7 +559,6 @@ load_image (GFile *file,
} }
image = gimp_image_new (fli_header.width, fli_header.height, GIMP_INDEXED); image = gimp_image_new (fli_header.width, fli_header.height, GIMP_INDEXED);
gimp_image_set_file (image, file);
fb = g_malloc (fli_header.width * fli_header.height); fb = g_malloc (fli_header.width * fli_header.height);
ofb = g_malloc (fli_header.width * fli_header.height); ofb = g_malloc (fli_header.width * fli_header.height);

View File

@ -170,7 +170,6 @@ icns_load (IcnsResource *icns,
/* Largest .icns icon is 1024 x 1024 */ /* Largest .icns icon is 1024 x 1024 */
image = gimp_image_new (1024, 1024, GIMP_RGB); image = gimp_image_new (1024, 1024, GIMP_RGB);
gimp_image_set_file (image, file);
nResources = 0; nResources = 0;
while (resource_get_next (icns, &resources[nResources++])) {} while (resource_get_next (icns, &resources[nResources++])) {}

View File

@ -721,8 +721,6 @@ ico_load_image (GFile *file,
D(("image size: %ix%i\n", max_width, max_height)); D(("image size: %ix%i\n", max_width, max_height));
image = gimp_image_new (max_width, max_height, GIMP_RGB); image = gimp_image_new (max_width, max_height, GIMP_RGB);
if (! file_offset)
gimp_image_set_file (image, file);
maxsize = max_width * max_height * 4; maxsize = max_width * max_height * 4;
buf = g_new (guchar, max_width * max_height * 4); buf = g_new (guchar, max_width * max_height * 4);
@ -923,7 +921,6 @@ ani_load_image (GFile *file,
gimp_parasite_free (parasite); gimp_parasite_free (parasite);
} }
gimp_image_set_file (image, file);
gimp_progress_update (1.0); gimp_progress_update (1.0);
return image; return image;

View File

@ -230,7 +230,6 @@ load_image (GFile *file,
GIMP_PRECISION_U8_NON_LINEAR); GIMP_PRECISION_U8_NON_LINEAR);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
gimp_image_set_file (image, file);
/* Step 5.0: save the original JPEG settings in a parasite */ /* Step 5.0: save the original JPEG settings in a parasite */
jpeg_detect_original_settings (&cinfo, image); jpeg_detect_original_settings (&cinfo, image);

View File

@ -464,20 +464,8 @@ jpeg_save (GimpProcedure *procedure,
switch (export) switch (export)
{ {
case GIMP_EXPORT_EXPORT: case GIMP_EXPORT_EXPORT:
{ display = NULL;
gchar *tmp = g_filename_from_utf8 (_("Export Preview"), -1, separate_display = TRUE;
NULL, NULL, NULL);
if (tmp)
{
GFile *file = g_file_new_for_path (tmp);
gimp_image_set_file (image, file);
g_object_unref (file);
g_free (tmp);
}
display = NULL;
separate_display = TRUE;
}
break; break;
case GIMP_EXPORT_IGNORE: case GIMP_EXPORT_IGNORE:

View File

@ -1339,7 +1339,6 @@ create_gimp_image (PSDimage *img_a,
IFDBG(2) g_debug ("Create image"); IFDBG(2) g_debug ("Create image");
image = gimp_image_new_with_precision (img_a->columns, img_a->rows, image = gimp_image_new_with_precision (img_a->columns, img_a->rows,
img_a->base_type, precision); img_a->base_type, precision);
gimp_image_set_file (image, file);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
return image; return image;

View File

@ -273,7 +273,6 @@ create_gimp_image (PSDimage *img_a,
IFDBG(2) g_debug ("Create image"); IFDBG(2) g_debug ("Create image");
image = gimp_image_new (img_a->columns, img_a->rows, img_a->base_type); image = gimp_image_new (img_a->columns, img_a->rows, img_a->base_type);
gimp_image_set_file (image, file);
gimp_image_undo_disable (image); gimp_image_undo_disable (image);
return image; return image;

View File

@ -443,8 +443,6 @@ load_image (GFile *file,
error)) error))
{ {
image = gimp_file_load (run_mode, file_out); image = gimp_file_load (run_mode, file_out);
if (image)
gimp_image_set_file (image, file);
} }
if (debug_prints) if (debug_prints)
@ -542,9 +540,6 @@ load_thumbnail_image (GFile *file,
"[dt4gimp]"); "[dt4gimp]");
if (start_of_size) if (start_of_size)
sscanf (start_of_size, "[dt4gimp] %d %d", width, height); sscanf (start_of_size, "[dt4gimp] %d %d", width, height);
/* is this needed for thumbnails? */
gimp_image_set_file (image, file);
} }
} }

View File

@ -355,8 +355,6 @@ load_image (GFile *file,
error)) error))
{ {
image = gimp_file_load (run_mode, file_out); image = gimp_file_load (run_mode, file_out);
if (image)
gimp_image_set_file (image, file);
} }
/*if (rawtherapee_stdout) printf ("%s\n", rawtherapee_stdout);*/ /*if (rawtherapee_stdout) printf ("%s\n", rawtherapee_stdout);*/
@ -473,11 +471,6 @@ load_thumbnail_image (GFile *file,
gimp_progress_update (0.5); gimp_progress_update (0.5);
image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file_out); image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file_out);
if (image)
{
/* is this needed for thumbnails? */
gimp_image_set_file (image, file);
}
} }
gimp_progress_update (1.0); gimp_progress_update (1.0);

View File

@ -465,8 +465,6 @@ load_image (GFile *file,
return NULL; return NULL;
} }
gimp_image_set_file (image, file);
/* /*
* Create the "background" layer to hold the image... * Create the "background" layer to hold the image...
*/ */

View File

@ -1162,45 +1162,7 @@ load_image (GFile *file,
gimp_image_undo_disable (*image); gimp_image_undo_disable (*image);
if (pages.target == GIMP_PAGE_SELECTOR_TARGET_IMAGES) if (pages.target == GIMP_PAGE_SELECTOR_TARGET_IMAGES)
{ images_list = g_list_prepend (images_list, *image);
gchar *uri;
gchar *fname;
GFile *new_file;
uri = g_file_get_uri (file);
fname = g_strdup_printf ("%s-%d", uri, ilayer);
new_file = g_file_new_for_uri (fname);
gimp_image_set_file (*image, new_file);
g_free (uri);
g_free (fname);
g_object_unref (new_file);
images_list = g_list_prepend (images_list, *image);
}
else if (pages.o_pages != pages.n_pages)
{
gchar *uri;
gchar *fname;
GFile *new_file;
uri = g_file_get_uri (file);
fname = g_strdup_printf (_("%s-%d-of-%d-pages"),
uri,
pages.n_pages, pages.o_pages);
new_file = g_file_new_for_uri (fname);
gimp_image_set_file (*image, new_file);
g_free (uri);
g_free (fname);
g_object_unref (new_file);
}
else
{
gimp_image_set_file (*image, file);
}
} }
/* attach CMYK profile to GimpImage if applicable */ /* attach CMYK profile to GimpImage if applicable */

View File

@ -282,8 +282,6 @@ load_image (GFile *file,
WebPMuxDelete (mux); WebPMuxDelete (mux);
gimp_image_set_file (image, file);
if (profile) if (profile)
g_object_unref (profile); g_object_unref (profile);

View File

@ -107,7 +107,6 @@ screenshot_freedesktop_dbus_signal (GDBusProxy *proxy,
GFile *file = g_file_new_for_uri (uri); GFile *file = g_file_new_for_uri (uri);
*image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file); *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, file);
gimp_image_set_file (*image, g_file_new_for_path ("screenshot.png"));
/* Delete the actual file. */ /* Delete the actual file. */
g_file_delete (file, NULL, NULL); g_file_delete (file, NULL, NULL);

View File

@ -141,7 +141,6 @@ screenshot_osx_shoot (ScreenshotValues *shootvals,
*image = gimp_file_load (GIMP_RUN_NONINTERACTIVE, *image = gimp_file_load (GIMP_RUN_NONINTERACTIVE,
tmpfile); tmpfile);
gimp_image_set_file (*image, g_file_new_for_uri ("screenshot.png"));
g_file_delete (tmpfile, NULL, NULL); g_file_delete (tmpfile, NULL, NULL);
g_free (command); g_free (command);