It is currently Thu Sep 24, 2026 11:06 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: deleting a gradient created (SOLVED) (thanks to JT+SG)
PostPosted: Wed May 20, 2015 12:05 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
GIMP Version: 2.8.14
Operating System: Windows
GIMP Experience: Basic Level



Hi,
I'm not sure whether I did something wrong or if the case is as such:
- if I create inside a script a gradient -just to be used for that script- I cannot delete it at the end of the script if I intend (in the same Gimp session) use again that script (Gimp abends).
Which means -if this is true- that I have to perform the deletion of all the gradients (one per run) created by that script only after a Gimp close.
Is this correct?

_________________
"Where am I ?"


Last edited by dinasset on Sun May 31, 2015 9:46 am, edited 3 times in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 12:20 am  (#2) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
Dinasset I'm not sure what you mean but by deleting the gradient with (gimp-gradient-delete name) at the end of the script
If you use the script again no worries It'll just create the gradient again

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:04 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Graechan,
that is what I tried, but I got a gimp crash when reusing (immediately after) the same script

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:03 am  (#4) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4826
Location: Bendigo Vic. Australia
can you let us know what error messages you received when Gimp crashed

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:34 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
I attach here the screenshot (sorry, the error window is in Italian)
Attachment:
Ashampoo_Snap_2015.05.20_09h33m45s_001_.png
Ashampoo_Snap_2015.05.20_09h33m45s_001_.png [ 170.21 KiB | Viewed 4134 times ]

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:37 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
addendum:
after the crash, I looked into the Gradients folder of Gimp, and none is there
(which confirms the first one created was deleted)

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 7:11 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
additional info (if somebody likes to know...)

I created a copy of my ongoing script in order to:
- reduce the code to the "essential" steps to reproduce the flow
- introduce many "gimp-message" to trace the steps

Using this test-version of the script I could assess that the crash occurs when my script (re-run after the first time, which runs correctly) calls the plug-in to create the gradient
(python-fu-palette-to-gradient-repeating 1 temp-palette)

The crash occurs ONLY if the first run of the script performs at its end the delete gradient, everything OK (even re-running my scripts ten times) if I comment out that stmt.

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 8:49 am  (#8) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
And you're hiding your code why?

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 10:32 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
are you referring to the whole script?
or to specific parts/statements I use?

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 11:45 am  (#10) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
saulgoode wrote:
And you're hiding your code why?
dinasset wrote:
are you referring to the whole script?
or to specific parts/statements I use?

@Dinasset
I think what Saul meant is: why don't you show us your test code so that we can try to reproduce the problem without having to guess what you're doing and then typing it in ourselves! And I agree.

Anyway, there doesn't seem to be a problem when invoked repeatedly from the Script-Fu Console:
> (python-fu-palette-to-gradient-repeating 1 "Default")
("Default #2")
> (gimp-gradient-delete "Default #2")
(#t)
> (python-fu-palette-to-gradient-repeating 1 "Default")
("Default #2")
> (gimp-gradient-delete "Default #2")
(#t)
> (python-fu-palette-to-gradient-repeating 1 "Gold")
("Gold")
> (gimp-gradient-delete "Gold")
(#t)
> (python-fu-palette-to-gradient-repeating 1 "Gold")
("Gold")
> (gimp-gradient-delete "Gold")
(#t)


Perhaps you could try a similar test exercise on the Script-Fu Console.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 12:32 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
OK, here is the reduced script I created for testing the specific problem (it performs the complete flow -creation of a frame with colours derived from the picture-, I just took away additional code -under test- for managing parameters flexibility- for the test are irrelevant because this version shows the problem -my problem, on my PC, maybe not common...)
Attachment:
DIEGO_Create-a-gradient.7z [2.66 KiB]
Downloaded 82 times

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 12:46 pm  (#12) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Okay, looks like a genuine problem.
I ran the script 3 times successfully on the same input image, but when I then ran it on a different image, Gimp crashed.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:06 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
On my PC it crashes even if I repeat my script on the same image...

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:28 pm  (#14) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Yes, it seems to be related to the number of layers in the images.
You can run repeatedly with single-layer images (eg. open a PNG file, run the script, open another PNG, run the script, etc), but if you then open an XCF with multiple layers and run the script, GIMP crashes.

Also, starting Gimp from a console, I get these error messages on the console:
(gimp:12701): Gimp-Core-CRITICAL **: gimp_image_undo_thaw: assertion 'private->undo_freeze_count > 0' failed

(gimp:12701): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GimpTaggedInterface'

(gimp:12701): Gimp-Core-CRITICAL **: gimp_tagged_get_tags: assertion 'GIMP_IS_TAGGED (tagged)' failed

(gimp:12701): Gimp-Core-CRITICAL **: gimp_image_undo_thaw: assertion 'private->undo_freeze_count > 0' failed

(palette-to-gradient.py:12733): LibGimpBase-WARNING **: palette-to-gradient.py: gimp_wire_read(): error

(script-fu:12716): LibGimpBase-WARNING **: script-fu: gimp_wire_read(): error
Segmentation fault (core dumped)


The gimp_image_undo_thaw error is because you're freezing the WorkImage, but then trying to Thaw the inImage:
(gimp-image-undo-freeze WorkImage) ; save time and space (wrap map is expensive)

(python-fu-wrap-map-bucket 1 WorkImage BorderLayer DuplicLayer 0)

(gimp-image-undo-thaw inImage) ; restore

But even after correcting that, Gimp still crashes with the gimp_wire_read() error.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:47 pm  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
thanks, corrected the mistake...

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:49 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
...but as you said, the Gimp crashes as well

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 1:53 pm  (#17) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
:ninja by jontait2

A couple of things that are most likely unrelated to your problem.

First, your script is modifying the user's context. The python plug-in that creates the gradient also sets the default gradient. Then when you later delete the created gradient, the default gradient gets set to the first gradient in the gradient list, "FG to BG (HSV clockwise hue)". The user's original choice of default gradient is lost. Similarly the default palette gets set to the one you create.

Second, I would recommend disabling the undo history on your work image until your script is done. Since it is a new image created by your script, performing an undo after executing your script would only "reset" the work image to an empty state, not particularly useful for anybody. This would also allow you to remove freezing and thawing statements around the 'python-fu-wrap-map-bucket' call.

It is possible that the problem lies with the freezing of the undo history, if the wrap-map-bucket call modifies the work image. It is not actually defined what happens when an image changes while undo is frozen, but you are advised against it.

Try disabling the work image undo (and eliminating the freeze/thaw) and see if you still encounter the problem. While it is not likely to be the cause, it is easy to check.

EDIT: I failed to notice that the image being frozen was different than the image being thawed. Nonetheless, I still recommend eliminating the freeze/thaw altogether.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:12 pm  (#18) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
thanks!
commented out the four statement related to the WorkImage (no undo history at all)
as you expected, Gimp crashes as well...

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:19 pm  (#19) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
WOW! the push/pop mechanism solved the problem!
thanks a lot!

_________________
"Where am I ?"


Top
 Post subject: Re: deleting a gradient created inside a script
PostPosted: Wed May 20, 2015 2:30 pm  (#20) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
one question, please:
about the WorkImage is it enough to have commented out all the four statements about undo history, or do I have to set explicitely a command to "disable" the undo history?

edit: I inserted the "disable" stmt immediately after the creation and the "enable" immediately before the disply-new

hope it's correct

_________________
"Where am I ?"


Top
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group