diff options
author | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:19:39 +0300 |
---|---|---|
committer | Simo Fält <simo.falt@qt.io> | 2023-05-25 11:19:39 +0300 |
commit | 40fdea15e6545292212ea6c4acc78c3b2975cbd8 (patch) | |
tree | a2209393036458904f52cc418c708a20abcc1fac /sources/pyside2/libpyside/pyside.cpp | |
parent | d8f02ce77a4143aa4e7e6c4f7892e6a943c46b3c (diff) | |
parent | 63d49d3651257452b9be3982cac573971995e230 (diff) |
Merge tag 'v5.15.6-lts' into tqtc/lts-5.15-opensourcev5.15.6-lts-lgpl
Qt For Python Release 5.15.6
Change-Id: I7a6874dfca79fbc46f5a6101e713b0c1dde9a640
Diffstat (limited to 'sources/pyside2/libpyside/pyside.cpp')
-rw-r--r-- | sources/pyside2/libpyside/pyside.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index 5d0859adc..7b01c5b8f 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -412,7 +412,7 @@ static const char invalidatePropertyName[] = "_PySideInvalidatePtr"; // PYSIDE-1214, when creating new wrappers for classes inheriting QObject but // not exposed to Python, try to find the best-matching (most-derived) Qt // class by walking up the meta objects. -static const char *typeName(QObject *cppSelf) +static const char *typeName(const QObject *cppSelf) { const char *typeName = typeid(*cppSelf).name(); if (!Shiboken::Conversions::getConverter(typeName)) { @@ -427,6 +427,20 @@ static const char *typeName(QObject *cppSelf) return typeName; } +PyTypeObject *getTypeForQObject(const QObject *cppSelf) +{ + // First check if there are any instances of Python implementations + // inheriting a PySide class. + auto *existing = Shiboken::BindingManager::instance().retrieveWrapper(cppSelf); + if (existing != nullptr) + return reinterpret_cast<PyObject *>(existing)->ob_type; + // Find the best match (will return a PySide type) + auto *sbkObjectType = Shiboken::ObjectType::typeForTypeName(typeName(cppSelf)); + if (sbkObjectType != nullptr) + return reinterpret_cast<PyTypeObject *>(sbkObjectType); + return nullptr; +} + PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type) { PyObject *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf)); |