aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests/QtCore
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-04-26 08:03:54 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-04-26 08:04:41 +0200
commit9b01aae7777c7ccde9eed1a8c55aead1524e00e5 (patch)
treec62834ca412f290485dd96d2a7522809b8fce6e1 /sources/pyside2/tests/QtCore
parent2156651b39fbb6717ed936c94dcd28295436e0a4 (diff)
parent0b842db3a95a44fbda3379d2093cb52f8ae2a1ff (diff)
Merge remote-tracking branch 'origin/5.9' into 5.11
Diffstat (limited to 'sources/pyside2/tests/QtCore')
-rw-r--r--sources/pyside2/tests/QtCore/qobject_inherits_test.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/sources/pyside2/tests/QtCore/qobject_inherits_test.py b/sources/pyside2/tests/QtCore/qobject_inherits_test.py
index 8c4c797a4..1d089776b 100644
--- a/sources/pyside2/tests/QtCore/qobject_inherits_test.py
+++ b/sources/pyside2/tests/QtCore/qobject_inherits_test.py
@@ -29,8 +29,12 @@
'''Test cases for QObject methods'''
import unittest
+import sys
-from PySide2.QtCore import QObject
+from PySide2.QtCore import QObject, QTimer
+from PySide2.QtWidgets import QApplication, QLabel, QVBoxLayout
+
+is_alive = None
class InheritsCase(unittest.TestCase):
'''Test case for QObject.inherits'''
@@ -87,5 +91,36 @@ class InheritsCase(unittest.TestCase):
self.assertRaises(TypeError, declareClass)
+ # PYSIDE-11:
+ # The takeOwnership() method was relying that the SbkObject
+ # had a converter, which it's not the case when multiple
+ # inheritance is used.
+ # The deleteLater() method uses the takeOwnership() to give
+ # control of the object to C++, so it can be remove once
+ # the destructor is called.
+ # The solution was to add a default case when the object
+ # is null under the pythonTypeIsValueType() method in shiboken.
+ def testDeleteMultipleInheritance(self):
+ app = QApplication(sys.argv)
+ class DerivedLabel(QLabel, QObject):
+ def __del__(self):
+ global is_alive
+ is_alive = False
+
+ global is_alive
+ child = DerivedLabel('Hello')
+ is_alive = True
+ parent = QVBoxLayout()
+ parent.addWidget(child)
+ parent.removeWidget(child)
+ child.deleteLater()
+ self.assertTrue(is_alive)
+ del child
+ self.assertTrue(is_alive)
+ QTimer.singleShot(100, app.quit)
+ app.exec_()
+ self.assertFalse(is_alive)
+
+
if __name__ == '__main__':
unittest.main()