2014-04-03 17:37:07 +00:00
|
|
|
"""
|
|
|
|
Test for unwanted reference cycles
|
|
|
|
|
|
|
|
"""
|
|
|
|
import pyqtgraph as pg
|
|
|
|
import numpy as np
|
2014-04-14 02:51:54 +00:00
|
|
|
import gc, weakref
|
2014-04-03 17:37:07 +00:00
|
|
|
app = pg.mkQApp()
|
|
|
|
|
|
|
|
def processEvents():
|
|
|
|
for i in range(3):
|
|
|
|
gc.collect()
|
|
|
|
app.processEvents()
|
|
|
|
# processEvents ignored DeferredDelete events; we must process these
|
|
|
|
# manually.
|
|
|
|
app.sendPostedEvents(None, pg.QtCore.QEvent.DeferredDelete)
|
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
#def test_PlotItem():
|
|
|
|
#for i in range(10):
|
|
|
|
#plt = pg.PlotItem()
|
|
|
|
#plt.plot(np.random.normal(size=10000))
|
|
|
|
#processEvents()
|
|
|
|
|
|
|
|
#ot = pg.debug.ObjTracker()
|
|
|
|
|
|
|
|
#plots = []
|
|
|
|
#for i in range(10):
|
|
|
|
#plt = pg.PlotItem()
|
|
|
|
#plt.plot(np.random.normal(size=10000))
|
|
|
|
#plots.append(plt)
|
|
|
|
#processEvents()
|
2014-04-03 17:37:07 +00:00
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
#ot.diff()
|
2014-04-03 17:37:07 +00:00
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
#del plots
|
|
|
|
#processEvents()
|
2014-04-03 17:37:07 +00:00
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
#ot.diff()
|
2014-04-03 17:37:07 +00:00
|
|
|
|
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
#return ot
|
2014-04-03 17:37:07 +00:00
|
|
|
|
2014-04-14 02:51:54 +00:00
|
|
|
def test_PlotWidget():
|
|
|
|
def mkref(*args, **kwds):
|
|
|
|
iv = pg.PlotWidget(*args, **kwds)
|
|
|
|
return weakref.ref(iv)
|
|
|
|
|
|
|
|
for i in range(100):
|
|
|
|
assert mkref()() is None
|
|
|
|
|
|
|
|
def test_ImageView():
|
|
|
|
def mkref(*args, **kwds):
|
|
|
|
iv = pg.ImageView(*args, **kwds)
|
|
|
|
return weakref.ref(iv)
|
|
|
|
|
|
|
|
for i in range(100):
|
|
|
|
assert mkref()() is None
|
2014-04-03 17:37:07 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
ot = test_PlotItem()
|