diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-05-13 08:43:53 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-05-14 09:31:35 +0200 |
commit | e3d72705b217460a989482b0452d54e9d48e851b (patch) | |
tree | 895c8a62897916beb39b20d71c844e5ccd54e163 | |
parent | ffd12d6450aa501302d1920949cf06c7907740f1 (diff) |
Also check the downcast for types found by dependency graph lookup
Try to be on the safe side. This should trigger only in very rare
cases (polymorphic ids used for hierarchies with non-virtual
desctructors spanning multiple inheritance or when manually calling
newObjectWithHeuristicsHelper() without type name).
Amends 28d04cae204881392ddc0826a570d05ba82c5ee0.
Task-number: PYSIDE-868
Change-Id: I25189b33ec7e3c6da2ca55d0560f97f1d6227f00
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index c11fbbfb2..ef20ea9cf 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -1466,7 +1466,8 @@ static PyObject *newObjectWithHeuristicsHelper(PyTypeObject *instanceType, // Try type discovery in these cases. if (exactType == nullptr || exactType == instanceType) { auto resolved = BindingManager::instance().findDerivedType(cptr, instanceType); - if (resolved.first != nullptr) { + if (resolved.first != nullptr + && Shiboken::ObjectType::canDowncastTo(instanceType, resolved.first)) { exactType = resolved.first; cptr = resolved.second; } |