app, libgimp, pdb: also mark images returned by a GimpLoadProcedure as clean…
… and reset their undo stack. This is a followup to #14463 as I realized that images opened directly by a load procedure may still be dirty, first if the plug-in developers didn't think of cleaning themselves the image at the end, but even as we add some metadata which adds an undo step too. So even if the plug-in developer made a perfect job, the image would still end up dirty if it has metadata! Let's just make so that GimpLoadProcedure clean the image explicitly. Note that other types of plug-ins creating images won't have such code as we cannot anticipate every case. In fact, in some use case, maybe someone may want a plug-in to return a dirty image with undo steps! At least for load procedures, we can consider these pretty standardized, knowing we want them clean upon loading.
This commit is contained in:
parent
313445b4cf
commit
81795bfb9f
4 changed files with 16 additions and 7 deletions
|
|
@ -4660,7 +4660,7 @@ register_image_procs (GimpPDB *pdb)
|
|||
"Checks if the image has unsaved changes.",
|
||||
"This procedure checks the specified image's dirty count to see if it needs to be saved. Note that saving the image does not automatically set the dirty count to 0, you need to call [method@Gimp.Image.clean_all] after calling a save procedure to make the image clean.\n"
|
||||
"\n"
|
||||
"When loading an image using e.g. [func@Gimp.file_load] the image will be marked as clean, but loading an image calling directly the accurate file format procedure may return a dirty image.",
|
||||
"When loading an image using e.g. [func@Gimp.file_load], or when created by a [class@Gimp.LoadProcedure], the image will be marked as clean. In other cases, it may sometimes be useful to clean programmatically created image yourself.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
|
|
|
|||
|
|
@ -2086,9 +2086,10 @@ gimp_image_clean_all (GimpImage *image)
|
|||
* [method@Gimp.Image.clean_all] after calling a save procedure to make
|
||||
* the image clean.
|
||||
*
|
||||
* When loading an image using e.g. [func@Gimp.file_load] the image
|
||||
* will be marked as clean, but loading an image calling directly the
|
||||
* accurate file format procedure may return a dirty image.
|
||||
* When loading an image using e.g. [func@Gimp.file_load], or when
|
||||
* created by a [class@Gimp.LoadProcedure], the image will be marked as
|
||||
* clean. In other cases, it may sometimes be useful to clean
|
||||
* programmatically created image yourself.
|
||||
*
|
||||
* Returns: TRUE if the image has unsaved changes.
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -284,6 +284,13 @@ gimp_load_procedure_run (GimpProcedure *procedure,
|
|||
if (image != NULL && metadata != NULL && flags != GIMP_METADATA_LOAD_NONE)
|
||||
_gimp_image_metadata_load_finish (image, NULL, metadata, flags);
|
||||
|
||||
if (image)
|
||||
{
|
||||
gimp_image_clean_all (image);
|
||||
gimp_image_undo_disable (image);
|
||||
gimp_image_undo_enable (image);
|
||||
}
|
||||
|
||||
/* This is debug printing to help plug-in developers figure out best
|
||||
* practices.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1799,9 +1799,10 @@ set the dirty count to 0, you need to call [method@Gimp.Image.clean_all] after
|
|||
calling a save procedure to make the image clean.
|
||||
|
||||
|
||||
When loading an image using e.g. [func@Gimp.file_load] the image will be
|
||||
marked as clean, but loading an image calling directly the accurate file
|
||||
format procedure may return a dirty image.
|
||||
When loading an image using e.g. [func@Gimp.file_load], or when created
|
||||
by a [class@Gimp.LoadProcedure], the image will be marked as clean.
|
||||
In other cases, it may sometimes be useful to clean programmatically
|
||||
created image yourself.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue