I was planning to use a global parasite to store my Gimp 3 plugin’s data, but I can’t get Gimp.attach_parasite() to work. In my little python demo, Gimp.get_parasite_list() always returns an empty list, right after I invoked Gimp.attach_parasite() with a new parasite:
def _assert_parasite_found(parasite_name: str):
all_paras = Gimp.get_parasite_list()
if all_paras is None:
raise ValueError("No global parasites, Gimp.get_parasite_list() returned None")
if len(all_paras) == 0:
raise ValueError("No global parasites, Gimp.get_parasite_list() returned []")
global_para = Gimp.get_parasite(parasite_name)
if global_para is None:
message = "Gimp.get_parasite(\"%s\") returned %s" % (parasite_name, str(global_para))
raise ValueError(message)
def demo_parasite_issue():
name = "DEMONSTRATION_GLOBAL_PARASITE"
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et"
encoded_ut8 = text.encode('utf-8')
data_bytes = bytes(encoded_ut8)
fresh_parasite = Gimp.Parasite.new(name=name, flags=0, data=data_bytes)
Gimp.attach_parasite(parasite=fresh_parasite)
_assert_parasite_found(parasite_name=name) # ValueError is raised by _assert_parasite_found
I get screen-fulls of errors like this:
LibGimp-CRITICAL **: 17:25:20.361: _gimp_pdb_new: assertion 'GIMP_IS_PLUG_IN (plug_in)' failed
. These are logged on calls to either attach_parasite() or get_parasite_list(). My test plug-in is minimal, it just creates an empty procedure. I’ve made other 3.0 plug-ins without Global parasites, and they don’t generate the above error.
I have not found any open bugs about attach_parasite() or get_parasite_list() on GIMP ISSUES, so I guess I’m doing something wrong. I have not found any docs on what I might need to setup beforehand. I have tried this code with no image open and after a creating a new one, same result.