QtQml: Have QtQml.Base formally import QML

This way we don't have to register QtObject and Component twice.

The QML_NAMED_ELEMENT etc. will return when we make the builtins a
proper module. The imperative registration is a stop gap measure.

Task-number: QTBUG-101143
Change-Id: I726aa77156b31aa624ac44d30e180ace6cb9d790
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Ulf Hermann 2023-11-13 10:54:32 +01:00
parent ec9612768f
commit 364abd8817
22 changed files with 79 additions and 23 deletions

View File

@ -42,7 +42,7 @@ Module {
}
Component {
file: "private/qqmlengine_p.h"
file: "qobject.h"
name: "QObject"
extension: "Object"
extensionIsJavaScript: true

View File

@ -39,6 +39,8 @@ qt_internal_add_qml_module(Qml
PLUGIN_TARGET qmlplugin
CLASS_NAME QtQmlPlugin
PLUGIN_TYPES qmltooling
IMPORTS
QML/1.0
SOURCES
../3rdparty/masm/assembler/ARM64Assembler.h
../3rdparty/masm/assembler/ARMv7Assembler.cpp ../3rdparty/masm/assembler/ARMv7Assembler.h

View File

@ -37,10 +37,6 @@ class Q_QML_EXPORT QQmlComponent : public QObject
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(QUrl url READ url CONSTANT)
QML_NAMED_ELEMENT(Component)
QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQmlComponentAttached)
Q_CLASSINFO("QML.OmitFromQmlTypes", "true")
public:
enum CompilationMode { PreferSynchronous, Asynchronous };

View File

@ -16,6 +16,7 @@
//
#include <QtQml/qqml.h>
#include <QtQml/qqmlcomponent.h>
#include <private/qtqmlglobal_p.h>
#include <QtCore/QObject>
@ -26,13 +27,6 @@ QT_BEGIN_NAMESPACE
class Q_QML_PRIVATE_EXPORT QQmlComponentAttached : public QObject
{
Q_OBJECT
// Used as attached object for QQmlComponent. We want qqmlcomponentattached_p.h to be #include'd
// when registering QQmlComponent, but we cannot #include it from qqmlcomponent.h. Therefore we
// force an anonymous type registration here.
QML_ANONYMOUS
QML_ADDED_IN_VERSION(2, 0)
Q_CLASSINFO("QML.OmitFromQmlTypes", "true")
public:
QQmlComponentAttached(QObject *parent = nullptr);
~QQmlComponentAttached();
@ -68,4 +62,7 @@ private:
QT_END_NAMESPACE
// TODO: Remove this once the builtins become a proper module.
QML_DECLARE_TYPEINFO(QQmlComponent, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQMLCOMPONENTATTACHED_P_H

View File

@ -556,6 +556,11 @@ void QQmlEnginePrivate::init()
qmlRegisterAnonymousType<QByteArray>("QML", 1);
qmlRegisterAnonymousSequentialContainer<QList<QByteArray>>("QML", 1);
qmlRegisterType<QObject>("QML", 1, 0, "QtObject");
qmlRegisterAnonymousType<QQmlComponentAttached>("QML", 1);
qmlRegisterType<QQmlComponent>("QML", 1, 0, "Component");
// No need to specifically register those.
static_assert(std::is_same_v<QStringList, QList<QString>>);
static_assert(std::is_same_v<QVariantList, QList<QVariant>>);
@ -565,6 +570,9 @@ void QQmlEnginePrivate::init()
qRegisterMetaType<QList<QObject*> >();
qRegisterMetaType<QQmlBinding*>();
// Protect the module: We don't want any URL interceptor to mess with the builtins.
qmlProtectModule("QML", 1);
QQmlData::init();
baseModulesUninitialized = false;
}
@ -2221,7 +2229,4 @@ bool LoadHelper::couldFindModule() const
QT_END_NAMESPACE
#include "moc_qqmlengine_p.cpp"
#include "moc_qqmlengine.cpp"

View File

@ -58,14 +58,6 @@ class QQmlObjectCreator;
class QQmlProfiler;
class QQmlPropertyCapture;
struct QObjectForeign {
Q_GADGET
QML_FOREIGN(QObject)
QML_NAMED_ELEMENT(QtObject)
QML_ADDED_IN_VERSION(2, 0)
Q_CLASSINFO("QML.OmitFromQmlTypes", "true")
};
// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate.
// The inline method definitions are in qqmljavascriptexpression_p.h
class QQmlJavaScriptExpressionGuard : public QQmlNotifierEndpoint

View File

@ -53,5 +53,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -43,5 +43,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -53,5 +53,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -38,5 +38,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -53,5 +53,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -54,5 +54,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -48,5 +48,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -48,5 +48,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -53,5 +53,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -54,5 +54,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -42,5 +42,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -54,5 +54,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -48,5 +48,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -54,5 +54,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -38,5 +38,9 @@
"relativePath": "QtQml/WorkerScript",
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
}
]

View File

@ -49,6 +49,10 @@
"type": "module",
"prefer": ":/qt-project.org/imports/QtQml/WorkerScript/"
},
{
"name": "QML",
"type": "module"
},
{
"name": "QTBUG-45916.js",
"type": "javascript"