From 9cd3067b4b8f38fb9d503d72cabb93660f9ef120 Mon Sep 17 00:00:00 2001 From: Nils Nemitz Date: Sun, 13 Jun 2021 03:00:28 +0900 Subject: [PATCH] add objects to registry BEFORE activating finalizer --- pyqtgraph/styleRegistry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/styleRegistry.py b/pyqtgraph/styleRegistry.py index a204f06c..5e4c1dc9 100644 --- a/pyqtgraph/styleRegistry.py +++ b/pyqtgraph/styleRegistry.py @@ -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):