aboutsummaryrefslogtreecommitdiffstats
path: root/tests/signals
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-02-19 17:10:24 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-02-23 16:35:40 -0300
commit75b7afbd63be9b27d3bd964891720e8c16079280 (patch)
treef56e9d83a73bff0119333649521663f5c45aad20 /tests/signals
parentab738e07d2cffc0fc9692ecc3a5f830847b853bb (diff)
Fixed memory leak on callbacks used on signal connection.
Now using the 'destroyed()' signal the reference is cleaned after source object destroyed.
Diffstat (limited to 'tests/signals')
-rw-r--r--tests/signals/multiple_connections_test.py4
-rw-r--r--tests/signals/pysignal_test.py12
-rw-r--r--tests/signals/qobject_receivers_test.py4
3 files changed, 16 insertions, 4 deletions
diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py
index d2a207673..9f45f4da4 100644
--- a/tests/signals/multiple_connections_test.py
+++ b/tests/signals/multiple_connections_test.py
@@ -10,7 +10,7 @@ from helper import BasicPySlotCase, UsesQCoreApplication
from helper.decorators import requires
-def random_gen(count=100, largest=99, lowest=0):
+def random_gen(count=50, largest=49, lowest=0):
for i in range(count):
yield random.randint(lowest, largest)
@@ -50,7 +50,7 @@ class PythonMultipleSlots(UsesQCoreApplication, MultipleSignalConnections):
class Dummy(QObject):
pass
- for test in random_gen(30):
+ for test in random_gen(20):
sender = Dummy()
receivers = [BasicPySlotCase() for x in range(10)]
self.run_many(sender, 'foobar', partial(sender.emit,
diff --git a/tests/signals/pysignal_test.py b/tests/signals/pysignal_test.py
index 3d741dcca..639a7dee2 100644
--- a/tests/signals/pysignal_test.py
+++ b/tests/signals/pysignal_test.py
@@ -50,6 +50,18 @@ class PythonSigSlot(unittest.TestCase):
self.assert_(self.called)
+ def testDisconnect(self):
+ obj1 = Dummy()
+
+ QObject.connect(obj1, SIGNAL('foo(int)'), self.callback)
+ QObject.disconnect(obj1, SIGNAL('foo(int)'), self.callback)
+
+ self.args = (42, )
+ obj1.emit(SIGNAL('foo(int)'), *self.args)
+
+ self.assert_(not self.called)
+
+
@requires('PySide.QtGui')
class SpinBoxPySignal(UsesQApplication):
"""Tests the connection of python signals to QSpinBox qt slots."""
diff --git a/tests/signals/qobject_receivers_test.py b/tests/signals/qobject_receivers_test.py
index e1d429ec6..cb4c9ced8 100644
--- a/tests/signals/qobject_receivers_test.py
+++ b/tests/signals/qobject_receivers_test.py
@@ -30,9 +30,9 @@ class TestQObjectReceivers(unittest.TestCase):
sender = QObject()
receiver = QObject()
sender.connect(sender, SIGNAL("destroyed()"), cute_slot)
- self.assertEqual(sender.receivers(SIGNAL("destroyed( )")), 1)
+ self.assertEqual(sender.receivers(SIGNAL("destroyed( )")), 0)
sender.connect(sender, SIGNAL("destroyed()"), receiver, SLOT("deleteLater()"))
- self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 2)
+ self.assertEqual(sender.receivers(SIGNAL("destroyed()")), 1)
del sender
del receiver