Created DestroyListener class.
This class is used to keep the Python object live until the signal destroyed emission. With this is possible to use the QObject on destruction signal. Fixes bug #505. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
05431cbfc0
commit
959aa385f5
7 changed files with 137 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ PYSIDE_TEST(classinfo_test.py)
|
|||
PYSIDE_TEST(child_event_test.py)
|
||||
PYSIDE_TEST(deepcopy_test.py)
|
||||
PYSIDE_TEST(deletelater_test.py)
|
||||
PYSIDE_TEST(destroysignal_test.py)
|
||||
PYSIDE_TEST(duck_punching_test.py)
|
||||
PYSIDE_TEST(hash_test.py)
|
||||
PYSIDE_TEST(max_signals.py)
|
||||
|
|
|
|||
27
tests/QtCore/destroysignal_test.py
Normal file
27
tests/QtCore/destroysignal_test.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from PySide.QtCore import QTimer, QObject
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
class TestDestroySignal(unittest.TestCase):
|
||||
def onObjectDestroyed(self, timer):
|
||||
self.assert_(isinstance(timer, QTimer))
|
||||
self._destroyed = True
|
||||
|
||||
def testSignal(self):
|
||||
self._destroyed = False
|
||||
t = QTimer()
|
||||
t.destroyed[QObject].connect(self.onObjectDestroyed)
|
||||
del t
|
||||
self.assert_(self._destroyed)
|
||||
|
||||
def testWithParent(self):
|
||||
self._destroyed = False
|
||||
p = QTimer()
|
||||
t = QTimer(p)
|
||||
t.destroyed[QObject].connect(self.onObjectDestroyed)
|
||||
del p
|
||||
self.assert_(self._destroyed)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
|
@ -8,6 +8,7 @@ import unittest
|
|||
class Bug576(unittest.TestCase):
|
||||
def onButtonDestroyed(self, button):
|
||||
self._destroyed = True
|
||||
self.assert_(isinstance(button, QtGui.QPushButton))
|
||||
|
||||
def testWidgetParent(self):
|
||||
self._destroyed = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue