Property get/set callback... the getter copy?

For property get/set callbacks such as BoolProperty(... ,get=get_prop, set=set_prop):

def get_prop(self):
	return ...

def set_prop(self, value):
	...

What causes the self of the getter to reference a copy and not the original object? Is this done for synchronized access and/or performance?

It seems like the getter references the original when used directly by a script or python console but references a copy when used by a UILayout property widget.

Is there a way to force an update of the copy seen by the getter when the setter is used? Currently I use alternate information in the copy and/or UILayout context pointers to indirectly reference the original and return the current value, thus bypassing the outdated value in the copy.

I suspect that’s the current behaviour of copy_on_write, so synchronized access would be the reason. :thinking:
I’m also experience something similar, but with the depsgraph not removing any of the copies whenever i change a property in a class.

Uh oh… so this morning I just realized that restarting Blender suddenly caused the getter to be passed the original via the UI now, and seems like all is fine. I wonder what happened. Maybe my reloading scripts too many times in one session caused something to go south.

I do now notice however that reloading scripts -appears- to not be reassigning the getter function. Maybe that was part of or related to my problem in the first place. Still not positive though.

So currently if I change the getter or setter I should restart Blender. Also noticed that reloading scripts causes the toolbar icons to shift off center to the right…:laughing:

Okay turns out my getter function was not getting updated because of a silent bug in code elsewhere showing up because of reloading scripts, thus is unrelated.

So I still suspect reloading scripts caused something to happen, due to the other interesting side effects. Too bad reloading scripts is the fastest way to test changes.

:frowning: I’m also experiencing stranginesses in ‘reloading/saving to preferences’ bugs… Don’t know the cause, but all these new changes in the API/Source seem not to be completely settled down.

I just experienced it again, while working on other stuff… again after reloading scripts many times. If I use the layout’s context_pointer_set it works, but only on the first call to the getter, seems there are 3 or 4 calls to the getter from different sources, that first one is the only one where the context pointer carries over.

There are plenty of ways around this problem all with more code than should be required, but on a few lines. It is still interesting though.