Commit 27f24d1a authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Expand ref cycle check to include all child QObjects

parent 0479507d
......@@ -11,8 +11,27 @@ def assert_alldead(refs):
for ref in refs:
assert ref() is None
def qObjectTree(root):
"""Return root and its entire tree of qobject children"""
childs = [root]
for ch in pg.QtCore.QObject.children(root):
childs += qObjectTree(ch)
return childs
def mkrefs(*objs):
return map(weakref.ref, objs)
"""Return a list of weakrefs to each object in *objs.
QObject instances are expanded to include all child objects.
allObjs = {}
for obj in objs:
if isinstance(obj, pg.QtCore.QObject):
obj = qObjectTree(obj)
obj = [obj]
for o in obj:
allObjs[id(o)] = o
return map(weakref.ref, allObjs.values())
def test_PlotWidget():
def mkobjs(*args, **kwds):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment