After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 139989 - copy-visible should not be undoable
copy-visible should not be undoable
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Script-Fu
2.0.x
Other All
: Low minor
: 2.0
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-04-14 00:21 UTC by weskaggs
Modified: 2004-04-15 08:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
New version of copy-visible.scm (2.53 KB, text/plain)
2004-04-14 12:56 UTC, Raphaël Quinet
Details
Correct version of copy-visible.scm (hopefully) (2.52 KB, text/plain)
2004-04-14 13:50 UTC, Raphaël Quinet
Details

Description weskaggs 2004-04-14 00:21:09 UTC
The copy-visible script produces an entry in the undo history, and there is no
reason for this, because it leaves the image unchanged.
Comment 1 Sven Neumann 2004-04-14 00:35:34 UTC
Probably a trivial change. Should be considered for 2.0.2 if it's really trivial.
Comment 2 Raphaël Quinet 2004-04-14 07:37:35 UTC
This does not look like a trivial change, unfortunately.  When you invoke
Edit->Copy Visible, the script copy-visible.scm duplicates the visible layers,
merges them (gimp-image-merge-visible-layers), copies the result and then
deletes that temporary layer.  It is necessary to push an undo group in order
to be able to perform all these operations.  The image is in the same state
before and after the invocation of the script, but an undo group is pushed on
the stack so the image is marked as being modified (dirty).

I did not find an easy workaround: replacing gimp-image-undo-group-{start,end}
by gimp-image-undo-{freeze,thaw} or gimp-image-undo-{disable,enable} do not
help: the dirty flag is always set on the image and using undo-{disable,enable}
only makes the problem worse by showing an empty undo history but still a dirty
image.

The only solution that I can think about right now would be to make
gimp_image_undo() and gimp_image_redo() available through the PDB.  This would
be useful anyway for a future macro recorder.  And then the script could call
gimp-image-undo after calling gimp-image-undo-group-end.  This is a hack, but
I cannot find a better solution.  Also, this would probably be the only way to
ensure that the image is exactly in the same state as it was before even if the
script is not perfect (e.g., if a layer mask, channel or path was active before
the script was invoked).  If the solution requires some additions to the PDB, do
we keep the milestone to 2.0.2 or bump it to 2.2?  These are additions, not
changes, but I am not sure about what is best here.
Comment 3 Pedro Gimeno 2004-04-14 07:53:10 UTC
I think it's worth noting the relation between bug #116145 and this one.
Comment 4 Simon Budig 2004-04-14 09:58:47 UTC
Trivial workaround: Duplicate the image before messing with the layers. It even
might make the script a lot easier.
Comment 5 Sven Neumann 2004-04-14 12:04:19 UTC
Yes, we should duplicate the image or if that's not feasible, close this report
as WONTFIX.
Comment 6 Raphaël Quinet 2004-04-14 12:56:06 UTC
Created attachment 26650 [details]
New version of copy-visible.scm

This new version of the script is shorter and copies the image first.
Please test.
Comment 7 Joao S. O. Bueno 2004-04-14 13:22:06 UTC
The attached script just crashed here. 
ERROR wta(non-symbol) to setvar (see errobj) 
 
 
It worked with a single layer. Crashed with 2 layers. 
 
Comment 8 Raphaël Quinet 2004-04-14 13:42:25 UTC
Strange...  Could you describe the steps to reproduce this problem?  I tried the
script with 1, 2, 3 and many layers and it worked for me (with or without hidden
layers, with or without an active selection, etc.)  
Comment 9 Raphaël Quinet 2004-04-14 13:47:20 UTC
Oh, shoot!  Sorry, I see now that I had attached the wrong version of the script
to this bug report.  Of course, it worked for me and it could not work for you...
Comment 10 Raphaël Quinet 2004-04-14 13:50:22 UTC
Created attachment 26655 [details]
Correct version of copy-visible.scm (hopefully)

Let's see if it works better this time...
Comment 11 Joao S. O. Bueno 2004-04-14 14:20:07 UTC
Just worked fine. :-) 
There we go.... 
Comment 12 Raphaël Quinet 2004-04-14 14:27:50 UTC
If there are no objections, I will commit this later today.  By the way, I was not
sure about what to do with the copyright and the date.  I re-wrote most of the
code, but I kept the same API as before so I left the original authors there.
Comment 13 Joao S. O. Bueno 2004-04-14 17:39:34 UTC
I think it is more than fair that you add your name in there. 
Or add a comment that reads  
"Heavily rewritten by Raphaël Quinet"  
 
Comment 14 Raphaël Quinet 2004-04-14 21:47:37 UTC
Well, I had already mentioned in a comment that I had rewritten most of the code
from scratch (mentioning these significant changes would be required by the GPL
anyway).  In fact, I only kept the API for registering, but the code itself
is new.  I was wondering about whether I should keep the original authors in the
call to script-fu-register since the code is new, but in the end I left
everybody there.

2004-04-14  Raphaël Quinet  <quinet@gamers.org>

  * plug-ins/script-fu/scripts/copy-visible.scm: New version of the
  script that works on a temporary copy of the image instead of
  copying the visible layers.  Fixes bug #139989.

Main advantages of the new code: it fixes this bug and it is smaller and easier
to understand.  Disadvantage: without copy-on-write, it wastes memory if the
original image has many hidden layers.  Should I merge this to the new gimp-2-0
branch?
Comment 15 Michael Natterer 2004-04-15 08:08:50 UTC
Yes, please commit to gimp-2-0 as well.