Commit ef7949a3 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Fixed ref cycle in SignalProxy

parent 82bd5ef5
......@@ -2,6 +2,7 @@
from .Qt import QtCore
from .ptime import time
from . import ThreadsafeTimer
import weakref
__all__ = ['SignalProxy']
......@@ -34,7 +35,7 @@ class SignalProxy(QtCore.QObject):
self.timer = ThreadsafeTimer.ThreadsafeTimer()
self.timer.timeout.connect(self.flush)
self.block = False
self.slot = slot
self.slot = weakref.ref(slot)
self.lastFlushTime = None
if slot is not None:
self.sigDelayed.connect(slot)
......@@ -80,7 +81,7 @@ class SignalProxy(QtCore.QObject):
except:
pass
try:
self.sigDelayed.disconnect(self.slot)
self.sigDelayed.disconnect(self.slot())
except:
pass
......
......@@ -45,7 +45,7 @@ def test_PlotWidget():
iv = pg.PlotWidget(*args, **kwds)
return weakref.ref(iv)
for i in range(100):
for i in range(5):
assert mkref()() is None
def test_ImageView():
......@@ -53,7 +53,7 @@ def test_ImageView():
iv = pg.ImageView(*args, **kwds)
return weakref.ref(iv)
for i in range(100):
for i in range(5):
assert mkref()() is None
if __name__ == '__main__':
......
......@@ -41,11 +41,11 @@ def test_stability():
try:
gc.disable()
actions = [
createWidget,
#setParent,
forgetWidget,
showWidget,
processEvents,
createWidget,
#setParent,
forgetWidget,
showWidget,
#processEvents,
#raiseException,
#addReference,
]
......
Markdown is supported
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