diff options
| -rw-r--r-- | sources/pyside6/tests/QtGui/qbrush_test.py | 10 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 6 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sources/pyside6/tests/QtGui/qbrush_test.py b/sources/pyside6/tests/QtGui/qbrush_test.py index 800e6f072..69262328b 100644 --- a/sources/pyside6/tests/QtGui/qbrush_test.py +++ b/sources/pyside6/tests/QtGui/qbrush_test.py @@ -13,7 +13,7 @@ from init_paths import init_test_paths init_test_paths(False) from PySide6.QtCore import Qt -from PySide6.QtGui import QColor, QBrush +from PySide6.QtGui import QColor, QBrush, QConicalGradient from helper.usesqapplication import UsesQApplication @@ -30,6 +30,14 @@ class Constructor(UsesQApplication): obj = QBrush(Qt.blue) self.assertEqual(obj.color(), Qt.blue) + def testGradient(self): + """Test type discovery on class hierarchies with non-virtual + destructors by specifying a polymorphic-id-expression without + polymorphic-name-function.""" + gradient = QConicalGradient() + brush = QBrush(gradient) + self.assertEqual(type(brush.gradient()), type(gradient)) + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 61e824f64..823078735 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -1441,8 +1441,10 @@ static PyObject *newObjectWithHeuristicsHelper(PyTypeObject *instanceType, void *cptr, bool hasOwnership) { - // Try to find the exact type of cptr. - if (exactType == nullptr) { + // Try to find the exact type of cptr. For hierarchies with + // non-virtual destructors, typeid() will return the base name. + // Try type discovery in these cases. + if (exactType == nullptr || exactType == instanceType) { auto resolved = BindingManager::instance().findDerivedType(cptr, instanceType); if (resolved.first != nullptr) { exactType = resolved.first; |
