add objects to registry BEFORE activating finalizer

This commit is contained in:
Nils Nemitz 2021-06-13 03:00:28 +09:00
parent efc157f1c1
commit 9cd3067b4b

View File

@ -302,10 +302,10 @@ class StyleRegistry(QtCore.QObject):
else:
registration = next(StyleRegistry._registrationGenerator)
obj.registration = registration # patch in attribute
self.registered_objects[registration] = (weakref.ref(obj), desc)
fin = weakref.finalize(obj, self.unregister, registration)
fin.atexit = False # no need to clean up registry on program exit
# print('registering', registration, '(',str(obj),'):',str(desc))
self.registered_objects[registration] = (weakref.ref(obj), desc)
def unregister(self, registration):
"""
@ -314,6 +314,8 @@ class StyleRegistry(QtCore.QObject):
# obj, desc = self.registered_objects[registration]
# print('unregistering', registration, '(',str(obj),'):',str(desc))
# del obj, desc
#
# if registration in self.registered_objects:
del self.registered_objects[registration]
def colors(self):