aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-12-14 13:23:32 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2021-12-17 12:43:14 +0100
commit687609f2f3a98ade4b8e074615c3d1db1228fce0 (patch)
tree4d5ed39c9ea5087cb4868315e826ea9869c32dee /src/qml
parentb9dba49d57338df0335912f9c6db627404af149d (diff)
Move QObject and QQmlComponent into builtins
Previously we had two versions of QObject and QQmlComponent: a hand-written version in bultins and one that is generated from QtQml. We now move the QtQml version into builtins in order to allow for representing the JavaScript extensions that are present in these types. We also add some logic so that unused types will still react properly despite the fact that those components are no longer in QtQml. This is done by introducing the concept of static modules. These are modules that have side effects beyond simply provinding components. This applies both to when some components are in builtins instead of QtQml or when the global object is modified in some way (i.e. by adding an image provider). This is a tooling-only concept and does not affect how these modules are handled at runtime. Fixes: QTBUG-99025 Change-Id: Ifacaa836e4d2eef0521494f5a41363e053c90007 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/CMakeLists.txt1
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake2
-rw-r--r--src/qml/Qt6QmlMacros.cmake17
-rw-r--r--src/qml/qml/qqmlcomponent.h1
-rw-r--r--src/qml/qml/qqmlengine_p.h2
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp10
-rw-r--r--src/qml/qmldirparser/qqmldirparser_p.h4
7 files changed, 36 insertions, 1 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt
index 046e29fdcd..3c08c6f9c5 100644
--- a/src/qml/CMakeLists.txt
+++ b/src/qml/CMakeLists.txt
@@ -32,6 +32,7 @@ qt_internal_add_qml_module(Qml
URI "QtQml"
VERSION "${PROJECT_VERSION}"
DESIGNER_SUPPORTED
+ __QT_INTERNAL_SYSTEM_MODULE
PLUGIN_TARGET qmlplugin
CLASS_NAME QtQmlPlugin
IMPORTS ${module_dynamic_qml_imports}
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index 4b6a144b0e..13cc64cad7 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -18,6 +18,8 @@ macro(qt_internal_get_internal_add_qml_module_keywords
NO_GENERATE_QMLDIR
NO_LINT
NO_CACHEGEN
+ __QT_INTERNAL_STATIC_MODULE
+ __QT_INTERNAL_SYSTEM_MODULE
)
set(${single_args}
URI
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index e2bef207d3..d3e9ac0e03 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -32,6 +32,11 @@ function(qt6_add_qml_module target)
# Used only by _qt_internal_qml_type_registration()
# TODO: Remove this once qt6_extract_metatypes does not install by default.
__QT_INTERNAL_INSTALL_METATYPES_JSON
+
+ # Used to mark modules as having static side effects (i.e. if they install an image provider)
+ __QT_INTERNAL_STATIC_MODULE
+ # Used to mark modules as being a system module that provides all builtins
+ __QT_INTERNAL_SYSTEM_MODULE
)
set(args_single
@@ -453,6 +458,8 @@ function(qt6_add_qml_module target)
_qt_qml_module_installed_plugin_target "${arg_INSTALLED_PLUGIN_TARGET}"
QT_QML_MODULE_DESIGNER_SUPPORTED "${arg_DESIGNER_SUPPORTED}"
+ QT_QML_MODULE_IS_STATIC "${arg___QT_INTERNAL_STATIC_MODULE}"
+ QT_QML_MODULE_IS_SYSTEM "${arg___QT_INTERNAL_SYSTEM_MODULE}"
QT_QML_MODULE_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
QT_QML_MODULE_RESOURCE_PREFIX "${qt_qml_module_resource_prefix}"
QT_QML_MODULE_PAST_MAJOR_VERSIONS "${arg_PAST_MAJOR_VERSIONS}"
@@ -954,6 +961,16 @@ function(_qt_internal_target_generate_qmldir target)
string(APPEND content "designersupported\n")
endif()
+ get_target_property(static_module ${target} QT_QML_MODULE_IS_STATIC)
+ if (static_module)
+ string(APPEND content "static\n")
+ endif()
+
+ get_target_property(system_module ${target} QT_QML_MODULE_IS_SYSTEM)
+ if (system_module)
+ string(APPEND content "system\n")
+ endif()
+
_qt_internal_qmldir_item(typeinfo QT_QML_MODULE_TYPEINFO)
_qt_internal_qmldir_item_list(import QT_QML_MODULE_IMPORTS)
diff --git a/src/qml/qml/qqmlcomponent.h b/src/qml/qml/qqmlcomponent.h
index d60c2cdc9f..e70dae5de8 100644
--- a/src/qml/qml/qqmlcomponent.h
+++ b/src/qml/qml/qqmlcomponent.h
@@ -73,6 +73,7 @@ class Q_QML_EXPORT QQmlComponent : public QObject
QML_NAMED_ELEMENT(Component)
QML_ADDED_IN_VERSION(2, 0)
QML_ATTACHED(QQmlComponentAttached)
+ Q_CLASSINFO("QML.OmitFromQmlTypes", "true")
public:
enum CompilationMode { PreferSynchronous, Asynchronous };
diff --git a/src/qml/qml/qqmlengine_p.h b/src/qml/qml/qqmlengine_p.h
index 630d32736b..58bc61dcf0 100644
--- a/src/qml/qml/qqmlengine_p.h
+++ b/src/qml/qml/qqmlengine_p.h
@@ -96,7 +96,7 @@ struct QObjectForeign {
QML_FOREIGN(QObject)
QML_NAMED_ELEMENT(QtObject)
QML_ADDED_IN_VERSION(2, 0)
- Q_CLASSINFO("QML.Root", "QML")
+ Q_CLASSINFO("QML.OmitFromQmlTypes", "true")
};
// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate.
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index 183fa918d2..bb9036582e 100644
--- a/src/qml/qmldirparser/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -296,6 +296,16 @@ bool QQmlDirParser::parse(const QString &source)
reportError(lineNumber, 0, QStringLiteral("designersupported does not expect any argument"));
else
_designerSupported = true;
+ } else if (sections[0] == QLatin1String("static")) {
+ if (sectionCount != 1)
+ reportError(lineNumber, 0, QStringLiteral("static does not expect any argument"));
+ else
+ _isStaticModule = true;
+ } else if (sections[0] == QLatin1String("system")) {
+ if (sectionCount != 1)
+ reportError(lineNumber, 0, QStringLiteral("system does not expect any argument"));
+ else
+ _isSystemModule = true;
} else if (sections[0] == QLatin1String("import")
|| sections[0] == QLatin1String("depends")) {
if (!readImport(sections, sectionCount, Import::Default))
diff --git a/src/qml/qmldirparser/qqmldirparser_p.h b/src/qml/qmldirparser/qqmldirparser_p.h
index fe371e6b4f..51d4d75323 100644
--- a/src/qml/qmldirparser/qqmldirparser_p.h
+++ b/src/qml/qmldirparser/qqmldirparser_p.h
@@ -157,6 +157,8 @@ public:
QList<Script> scripts() const { return _scripts; }
QList<Plugin> plugins() const { return _plugins; }
bool designerSupported() const { return _designerSupported; }
+ bool isStaticModule() const { return _isStaticModule; }
+ bool isSystemModule() const { return _isSystemModule; }
QStringList typeInfos() const { return _typeInfos; }
QStringList classNames() const { return _classNames; }
@@ -177,6 +179,8 @@ private:
QList<Script> _scripts;
QList<Plugin> _plugins;
bool _designerSupported = false;
+ bool _isStaticModule = false;
+ bool _isSystemModule = false;
QStringList _typeInfos;
QStringList _classNames;
QString _linkTarget;