diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-17 11:43:34 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-17 14:36:56 +0200 |
| commit | 81b487553674efc10654fc10088c132b4c4fa93a (patch) | |
| tree | 70a078a8a3822f1021b281a7c564345c490569f0 /sources/pyside2/tests | |
| parent | bdc299626e3688b631aafe8a1c71ca78ceab6dea (diff) | |
Fix crash when overriding QUiLoader::createWidget() in QUiLoader
Mark the returned objects of the create functions in native (wrapper
code) as owned by C++.
Fixes: PYSIDE-1070
Change-Id: I8774f2f0c9adafc73e0d969384e4c0357b7c896d
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/tests')
| -rw-r--r-- | sources/pyside2/tests/QtUiTools/uiloader_test.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sources/pyside2/tests/QtUiTools/uiloader_test.py b/sources/pyside2/tests/QtUiTools/uiloader_test.py index 07461ca2f..2fceb45c1 100644 --- a/sources/pyside2/tests/QtUiTools/uiloader_test.py +++ b/sources/pyside2/tests/QtUiTools/uiloader_test.py @@ -40,6 +40,15 @@ from PySide2.QtWidgets import QWidget from PySide2.QtUiTools import QUiLoader +class OverridingLoader(QUiLoader): + def createWidget(self, class_name, parent=None, name=''): + if class_name == 'QWidget': + w = QWidget(parent) + w.setObjectName(name) + return w + return QUiLoader.createWidget(self, class_name, parent, name) + + class QUiLoaderTester(UsesQApplication): def setUp(self): UsesQApplication.setUp(self) @@ -58,6 +67,13 @@ class QUiLoaderTester(UsesQApplication): self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object")) + def testLoadFileOverride(self): + # PYSIDE-1070, override QUiLoader::createWidget() with parent=None crashes + loader = OverridingLoader() + w = loader.load(self._filePath) + self.assertNotEqual(w, None) + + if __name__ == '__main__': unittest.main() |
