defcon icon indicating copy to clipboard operation
defcon copied to clipboard

Stop posting notifications to dead references.

Open typesupply opened this issue 11 years ago • 3 comments

When a reference is dead, the notification system skips it. It needs to be caught and removed from the system so that the looping is minimized. There is already a note about this in the code:

https://github.com/typesupply/defcon/blob/ufo3/Lib/defcon/tools/notifications.py#L190

typesupply avatar Feb 04 '14 13:02 typesupply

Is this the reason for this documentation:

https://github.com/typesupply/defcon/blob/master/documentation/source/concepts/notifications.rst#dont-forget-removeobserver

Or is there any reason why you are not trusting the weakref module?

And what held you back from just deleting the entry?

graphicore avatar Oct 15 '15 18:10 graphicore

Is this the reason for this documentation:

Yeah. At the time I thought that automatically removing dead references was too magical. I didn't want anyone to get into the habit of not removing observers under any circumstances. I've changed my mind on that. I think that bit of magic is okay.

Or is there any reason why you are not trusting the weakref module?

I'm not sure I follow. It looks like weakref is being used extensively. Early in defcon I think I didn't use weakref because some objects that I were dealing with couldn't be weakly referenced. (PyObjC wrapper objects, probably.) So, strong references were used. The PyObjC issue went away with better coding practice so I started using weakref. (Wow. This was around ten years ago!)

And what held you back from just deleting the entry?

Overthinking and being too strict. :)

typesupply avatar Oct 15 '15 23:10 typesupply

Or is there any reason why you are not trusting the weakref module?

I'm not sure I follow. It looks like weakref is being used extensively.

I think weakref is fine; I was just speculating.

graphicore avatar Oct 15 '15 23:10 graphicore