
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.