[Gimp-user] Undo a Step in Python-Fu



From your message, it seems like you've tried a lot the existing
possibilities, and probably this trick won't help you at all - but,
that is only what exists on GIMP.

Yes. While I haven't *tried* the possibilities, I've already thought about
various half-solutions including:
-The program exits, only allowing a single execution while the settings are
saved to the gimp shelf for the next time it launches (what GIMP plugins
normally do).
-The program exits, only allowing a single execution but having a 'Preview
Effect' button that runs the main function without saving to the undo group.
This would mean you'd always have to run the effect an extra time to finalize
it, even if the preview is perfect.

Your solution would work, but that'd involve re-constructing the entire image
upon plugin launch. The whole point of not putting everything into a single
large undo group is to avoid huge operations and hammering the RAM usage. It'd
be fine for touching up an image, but bad for a large project consisting of like
20 layers.
However, your solution really inspired me...
What *doesn't* take a lot of resources is copying a single layer or two. I could
freeze the undo memory for the entire duration the program's up, then at the
very end I should be able to cut and re-add the layer into an undo group. In
fact, this could allow for potentially faster performance when frequently
undoing and redoing steps, as it'd just be a paste or two in the undo group
instead of the long process to get there. It should be easy to do since I
already have to save all the important layers as a class field so I can check
for their existence and manipulate them in other parts of the program.
I'll try modifying the code to be as follows and report back if it works:

Class __init__: freeze undo before anything else.
Main window's on_destroy: copy and remove (cut if the layer object has it) the
final layer(s). Thaw undo. Paste final layer(s).


-Even when I scale things to crazy resolutions in Waifu2x and use a
developmental GIMP build, duplicating layers is still typically fast enough to
be considered negligible. So, this *should* work absolutely perfectly.

-- 
FierySwordswoman (via www.gimpusers.com/forums)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]