From 9f2249197d16cbbdcdf2d621d57c474fc1299e80 Mon Sep 17 00:00:00 2001 From: Tal Leming Date: Wed, 20 Dec 2023 12:33:12 -0500 Subject: [PATCH] Use respondsToSelector instead of hasattr in _breakCycles. This addresses #145. Closing the test window in the issue goes from taking 0.11 seconds to 0.01 seconds. --- Lib/vanilla/vanillaBase.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/vanilla/vanillaBase.py b/Lib/vanilla/vanillaBase.py index a14d15d..bf3800d 100644 --- a/Lib/vanilla/vanillaBase.py +++ b/Lib/vanilla/vanillaBase.py @@ -543,9 +543,8 @@ def _breakCycles(view): """ Break cyclic references by deleting _target attributes. """ - if hasattr(view, "vanillaWrapper"): + if view.respondsToSelector_("vanillaWrapper"): obj = view.vanillaWrapper() - if hasattr(obj, "_breakCycles"): - obj._breakCycles() + obj._breakCycles() for view in view.subviews(): _breakCycles(view)