diff options
Diffstat (limited to 'sources/pyside2/libpyside')
-rw-r--r-- | sources/pyside2/libpyside/pyside.cpp | 15 | ||||
-rw-r--r-- | sources/pyside2/libpyside/pyside_p.h | 60 | ||||
-rw-r--r-- | sources/pyside2/libpyside/pysideclassinfo.cpp | 7 | ||||
-rw-r--r-- | sources/pyside2/libpyside/signalmanager.cpp | 5 |
4 files changed, 73 insertions, 14 deletions
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp index 367a1adc2..fbfad4185 100644 --- a/sources/pyside2/libpyside/pyside.cpp +++ b/sources/pyside2/libpyside/pyside.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "pyside.h" +#include "pyside_p.h" #include "signalmanager.h" #include "pysideclassinfo_p.h" #include "pysideproperty_p.h" @@ -188,13 +189,6 @@ void destroyQCoreApplication() MakeSingletonQAppWrapper(NULL); } -struct TypeUserData { - explicit TypeUserData(PyTypeObject* type, const QMetaObject* metaobject, std::size_t size) : - mo(type, metaobject), cppObjSize(size) {} - DynamicQMetaObject mo; - std::size_t cppObjSize; -}; - std::size_t getSizeOfQObject(SbkObjectType* type) { using namespace Shiboken::ObjectType; @@ -231,15 +225,16 @@ void initQObjectSubType(SbkObjectType *type, PyObject *args, PyObject * /* kwds PyObject* bases = PyTuple_GET_ITEM(args, 1); int numBases = PyTuple_GET_SIZE(bases); - QMetaObject* baseMo = 0; + DynamicQMetaObject *baseMo = nullptr; SbkObjectType* qobjBase = 0; for (int i = 0; i < numBases; ++i) { PyTypeObject* base = reinterpret_cast<PyTypeObject*>(PyTuple_GET_ITEM(bases, i)); if (PyType_IsSubtype(base, qObjType)) { - baseMo = reinterpret_cast<QMetaObject*>(Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(base))); + void *typeUserData = Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(base)); + baseMo = &(reinterpret_cast<TypeUserData *>(typeUserData)->mo); qobjBase = reinterpret_cast<SbkObjectType*>(base); - reinterpret_cast<DynamicQMetaObject*>(baseMo)->update(); + baseMo->update(); break; } } diff --git a/sources/pyside2/libpyside/pyside_p.h b/sources/pyside2/libpyside/pyside_p.h new file mode 100644 index 000000000..e3039ed0b --- /dev/null +++ b/sources/pyside2/libpyside/pyside_p.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Python. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PYSIDE_P_H +#define PYSIDE_P_H + +#include <dynamicqmetaobject.h> + +namespace PySide +{ + +// Struct associated with QObject's via Shiboken::Object::getTypeUserData() +struct TypeUserData +{ + explicit TypeUserData(PyTypeObject* type, const QMetaObject* metaobject, std::size_t size) : + mo(type, metaobject), cppObjSize(size) {} + + DynamicQMetaObject mo; + std::size_t cppObjSize; +}; + +} //namespace PySide + +#endif // PYSIDE_P_H diff --git a/sources/pyside2/libpyside/pysideclassinfo.cpp b/sources/pyside2/libpyside/pysideclassinfo.cpp index 645c03011..64b882673 100644 --- a/sources/pyside2/libpyside/pysideclassinfo.cpp +++ b/sources/pyside2/libpyside/pysideclassinfo.cpp @@ -39,6 +39,7 @@ #include <sbkpython.h> #include "pysideclassinfo.h" +#include "pyside_p.h" #include "pysideclassinfo_p.h" #include "dynamicqmetaobject.h" @@ -107,9 +108,9 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */) } if (Shiboken::ObjectType::checkType(reinterpret_cast<PyTypeObject*>(klass))) { - PySide::DynamicQMetaObject* mo = reinterpret_cast<PySide::DynamicQMetaObject*>(Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(klass))); - if (mo) { - mo->addInfo(PySide::ClassInfo::getMap(data)); + if (void *userData = Shiboken::ObjectType::getTypeUserData(reinterpret_cast<SbkObjectType*>(klass))) { + PySide::DynamicQMetaObject &mo = reinterpret_cast<PySide::TypeUserData *>(userData)->mo; + mo.addInfo(PySide::ClassInfo::getMap(data)); pData->m_alreadyWrapped = true; validClass = true; } diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp index 4119c8171..19779be5b 100644 --- a/sources/pyside2/libpyside/signalmanager.cpp +++ b/sources/pyside2/libpyside/signalmanager.cpp @@ -43,6 +43,7 @@ #include "pysideproperty.h" #include "pysideproperty_p.h" #include "pyside.h" +#include "pyside_p.h" #include "dynamicqmetaobject.h" #include "pysidemetafunction_p.h" @@ -643,7 +644,9 @@ const QMetaObject* SignalManager::retrieveMetaObject(PyObject *self) mo = reinterpret_cast<DynamicQMetaObject*>(PyCObject_AsVoidPtr(pyMo)); #endif } else { - mo = reinterpret_cast<DynamicQMetaObject*>(Shiboken::Object::getTypeUserData(reinterpret_cast<SbkObject*>(self))); + void *userData = Shiboken::Object::getTypeUserData(reinterpret_cast<SbkObject*>(self)); + Q_ASSERT(userData); + mo = &(reinterpret_cast<TypeUserData *>(userData)->mo); } mo->update(); |