aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/libpysideqml/pysideqmluncreatable.cpp')
-rw-r--r--sources/pyside6/libpysideqml/pysideqmluncreatable.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp b/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
index 43c795cb0..7c0f6b8ff 100644
--- a/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmluncreatable.cpp
@@ -2,17 +2,17 @@
// 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>
#include <sbkcppstring.h>
-#include <string>
-#include <unordered_map>
+#include <QtCore/qbytearray.h>
+#include <private/qmetaobjectbuilder_p.h>
-#include <QtCore/QtGlobal>
+using namespace Qt::StringLiterals;
class PySideQmlUncreatablePrivate : public PySide::ClassDecorator::StringDecoratorPrivate
{
@@ -35,11 +35,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 +103,16 @@ 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} });
+}
+
+void setUncreatableClassInfo(QMetaObjectBuilder *builder, const QByteArray &reason)
+{
+ builder->addClassInfo("QML.Creatable", "false");
+ builder->addClassInfo("QML.UncreatableReason", reason);
+}