diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-22 16:24:33 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-23 11:24:22 +0100 |
commit | a34622f8098d67c706148eac506460fc65a6401f (patch) | |
tree | 806d6edc53e8c86191c5c9905e5965e55398d51e /sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp | |
parent | 5b6e13653509b821a36b473bb3a399304fe571a9 (diff) |
libpyside6: Add a convenience function to convert a PyObject * to a QObject *
Pick-to: 6.2
Task-number: PYSIDE-1709
Change-Id: I137d7fd3ac84f50bb6a799e27e07b7523d943812
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp')
-rw-r--r-- | sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp index b769a1eb9..f7f1b2375 100644 --- a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp +++ b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp @@ -295,15 +295,10 @@ int PySide::qmlRegisterSingletonInstance(PyObject *pyObj, const char *uri, int v if (!isQObjectDerived(pyObjType, true)) return -1; - // Check if the instance object derives from QObject - PyTypeObject *typeInstanceObject = instanceObject->ob_type; - - if (!isQObjectDerived(typeInstanceObject, true)) - return -1; - // Convert the instanceObject (PyObject) into a QObject - QObject *instanceQObject = reinterpret_cast<QObject*>( - Object::cppPointer(reinterpret_cast<SbkObject*>(instanceObject), qObjectType())); + QObject *instanceQObject = PySide::convertToQObject(instanceObject, true); + if (instanceQObject == nullptr) + return -1; // Create Singleton Functor to pass the QObject to the Type registration step // similarly to the case when we have a callback |