diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-29 08:34:56 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-29 13:56:39 +0200 |
commit | 98aef951920641dcdf4c217a0c51626cdf82caf8 (patch) | |
tree | 285079d972d5c65e422f83454d80ec139b89e28d /sources/pyside6/libpyside/pyside.h | |
parent | ba819888cad86b0cacb2a992f01287b476b29a04 (diff) |
PySide6: Fix crashes in QObject.findChild()
For all objects encountered in findChild(), a wrapper
was created just to be able to retrieve its type object
and check against it. As there is a name lookup involved,
it happens that non-QObject wrappers are created for this
(in the specific case, an enum wrapper), which leads to
crashes later on.
Refactor the code, extracting a helper function to PySide
which finds the best-matching type object for a QObject
to check on that. Rearrange the check so that the name is
checked first.
Pick-to: 6.1 5.15
Fixes: PYSIDE-1609
Change-Id: I026854201f3f6eca9e5905105127f0a4b4588fa9
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/libpyside/pyside.h')
-rw-r--r-- | sources/pyside6/libpyside/pyside.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sources/pyside6/libpyside/pyside.h b/sources/pyside6/libpyside/pyside.h index 9bb0ab12e..1cb77b4c5 100644 --- a/sources/pyside6/libpyside/pyside.h +++ b/sources/pyside6/libpyside/pyside.h @@ -140,6 +140,11 @@ PYSIDE_API void setNextQObjectMemoryAddr(void *addr); PYSIDE_API PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type); +/// Return the best-matching type for a QObject (Helper for QObject.findType()) +/// \param cppSelf QObject instance +/// \return type object +PYSIDE_API PyTypeObject *getTypeForQObject(const QObject *cppSelf); + #ifdef PYSIDE_QML_SUPPORT // Used by QtQuick module to notify QtQml that custom QtQuick items can be registered. using QuickRegisterItemFunction = |