Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-09 08:24:21 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-23 12:26:07 +0200
commit91bf9aa10faad14de557136664f58005c935d11c (patch)
treed5ff6278aca875c89ffad46cc36d68ba74a366c9 /sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
parent624e52a0114a966bd852aeb66b8a1b928d80343b (diff)
QML registration code: Modernize
Use QQmlPrivate::RegisterTypeAndRevisions and information set as QMetaClassInfo as recommended by QML team. The only remaining old code path is for qmlRegisterSingletonType() for the hypothetical case of a value type. [ChangeLog][PySide6] QML type registration has been ported to use RegisterTypeAndRevisions. Fixes: PYSIDE-2484 Change-Id: I7134cbfe1fad1fb543a560cc13b68327b9bd9c2b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/libpysideqml/pysideqmluncreatable.cpp')
-rw-r--r--sources/pyside6/libpysideqml/pysideqmluncreatable.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp b/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
index 43c795cb0..dad13cf5f 100644
--- a/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
@@ -2,8 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "pysideqmluncreatable.h"
-#include "pysideqmltypeinfo_p.h"
#include <pysideclassdecorator_p.h>
+#include <pysideclassinfo.h>
#include <shiboken.h>
#include <signature.h>
@@ -14,6 +14,8 @@
#include <QtCore/QtGlobal>
+using namespace Qt::StringLiterals;
+
class PySideQmlUncreatablePrivate : public PySide::ClassDecorator::StringDecoratorPrivate
{
public:
@@ -35,11 +37,9 @@ PyObject *PySideQmlUncreatablePrivate::tp_call(PyObject *self, PyObject *args, P
if (klass== nullptr)
return nullptr;
+ auto *type = reinterpret_cast<PyTypeObject *>(klass);
auto *data = DecoratorPrivate::get<PySideQmlUncreatablePrivate>(self);
-
- const auto info = PySide::Qml::ensureQmlTypeInfo(klass);
- info->flags.setFlag(PySide::Qml::QmlTypeFlag::Uncreatable);
- info->noCreationReason = data->string();
+ setUncreatableClassInfo(type, data->string());
Py_INCREF(klass);
return klass;
@@ -105,3 +105,10 @@ void initQmlUncreatable(PyObject *module)
PyModule_AddObject(module, "QmlUncreatable",
reinterpret_cast<PyObject *>(PySideQmlUncreatable_TypeF()));
}
+
+void setUncreatableClassInfo(PyTypeObject *type, const QByteArray &reason)
+{
+ PySide::ClassInfo::setClassInfo(type, {
+ {"QML.Creatable"_ba, "false"_ba},
+ {"QML.UncreatableReason"_ba, reason} });
+}