From 1bd279b01d06eba0abbbb5fea0c12a6de2600cdd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 Jan 2019 09:02:04 +0100 Subject: libpyside: Use helper function for accessing the meta object in quick type registration Fix an oversight of bbd32e9e52bda460dd1cb75d128dd1165d1fd152. Task-number: PYSIDE-784 Change-Id: Ic48fbed24bc86a848accda46602fd3f5cb27d411 Reviewed-by: Qt CI Bot Reviewed-by: Christian Tismer --- sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp index 93a8f281e..e50b1dfc7 100644 --- a/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp +++ b/sources/pyside2/PySide2/QtQuick/pysidequickregistertype.cpp @@ -40,6 +40,7 @@ #include "pysidequickregistertype.h" #include +#include #include // Auto generated headers. @@ -122,7 +123,7 @@ void registerTypeIfInheritsFromClass( PyTypeObject *typeToRegister, const QByteArray &typePointerName, const QByteArray &typeListName, - QMetaObject *typeMetaObject, + const QMetaObject *typeMetaObject, QQmlPrivate::RegisterType *type, bool ®istered) { @@ -199,9 +200,7 @@ bool quickRegisterType(PyObject *pyObj, const char *uri, int versionMajor, int v return false; // Used inside macros to register the type. - QMetaObject *metaObject = - reinterpret_cast( - ObjectType::getTypeUserData(reinterpret_cast(pyObj))); + const QMetaObject *metaObject = PySide::retrieveMetaObject(pyObj); Q_ASSERT(metaObject); -- cgit v1.2.3 From c8970b29d76415d41fa383cbe5eb77eefb191fa1 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 7 Jan 2019 12:46:13 +0100 Subject: [reg] Remove createIndex method that uses PyObject* Even though we have support for Void*, having to import it as an additional class to be able to call a separate function, is adding too much complexity so something that should be easy to do, like creating an index for an itemmodel. The regression is a change that replaced the way of doing: QAbstractItemModel.createIndex(0, 0, PyObject*) to QAbstractItemModel.createIndex(0, 0, VoidPtr(PyObject*)) which is not really intuitive, and is generating other issues. Included modification in the registries too. Change-Id: Ie6112c6baeb4fc3b22fc78e7edeb66aa4a17c22b Fixes: PYSIDE-883 Reviewed-by: Christian Tismer Reviewed-by: Qt CI Bot --- .../PySide2/QtCore/typesystem_core_common.xml | 36 ++++++++++++++++++++++ sources/pyside2/PySide2/templates/core_common.xml | 7 +++++ .../QtCore/qmodelindex_internalpointer_test.py | 12 +++----- .../tests/registry/exists_darwin_5_12_0_ci.py | 4 +-- .../tests/registry/exists_opensuse423_5_12_0_ci.py | 4 +-- ...redhatenterpriselinuxworkstation74_5_12_0_ci.py | 4 +-- .../tests/registry/exists_win32_5_12_0_ci.py | 4 +-- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index c70049d8e..7531b33b8 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -1210,6 +1210,11 @@ + + + + + @@ -1460,12 +1465,38 @@ + + + + + + + + + + + + + + + Creates a model index for the given row and column with the internal pointer ptr. + When using a QSortFilterProxyModel, its indexes have their own internal pointer. + It is not advisable to access this internal pointer outside of the model. + Use the data() function instead. + This function provides a consistent interface that model subclasses must use to create model indexes. + + .. warning:: Because of some Qt/Python itegration rules, the ptr argument do not get the reference + incremented during the QModelIndex life time. So it is necessary to keep the object used + on ptr argument alive during the whole process. + Do not destroy the object if you are not sure about that. + + @@ -2774,6 +2805,11 @@ + + + + + diff --git a/sources/pyside2/PySide2/templates/core_common.xml b/sources/pyside2/PySide2/templates/core_common.xml index 0fe19273b..4f715ee1f 100644 --- a/sources/pyside2/PySide2/templates/core_common.xml +++ b/sources/pyside2/PySide2/templates/core_common.xml @@ -260,6 +260,13 @@ %PYARG_0 = Shiboken::String::fromCString(qPrintable(format)); + +