aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4engine.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-12-11 16:36:10 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-12-17 20:49:39 +0100
commitce0a16c0800fb1d5bb64783c424274b0a8bd4d43 (patch)
treec761d31445f7c11c3c9ee5411b2dd72d4d96a44f /src/qml/jsruntime/qv4engine.cpp
parentf446f31079f7ac20e6d9ac0a28abba6d44a3709b (diff)
QtQml: Generalize the global/illegal names
Instead of passing them around everywhere, use the ones we statically know and only validate them when creating a new engine. Task-number: QTBUG-131721 Change-Id: I7fb93d15eb6e4194c46249727bcf7a48f5dce730 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 4b7572f1c2..76a1ecc7bf 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -2293,6 +2293,25 @@ void ExecutionEngine::initQmlGlobalObject()
lockObject(*globalObject);
}
+static bool globalNamesAreStaticallyKnown(QV4::Object *globalObject)
+{
+ const Heap::InternalClass *ic = globalObject->internalClass();
+ const SharedInternalClassData<PropertyKey> &nameMap = ic->nameMap;
+ bool clean = true;
+ for (uint i = 0, end = ic->size; i < end; ++i) {
+ const QV4::PropertyKey id = nameMap.at(i);
+ if (id.isString()) {
+ if (!Compiler::Codegen::isNameGlobal(id.toQString())) {
+ qCritical() << id.toQString()
+ << "is part of the JavaScript global object "
+ "but not statically known to be global";
+ clean = false;
+ }
+ }
+ }
+ return clean;
+}
+
void ExecutionEngine::initializeGlobal()
{
createQtObject();
@@ -2312,14 +2331,7 @@ void ExecutionEngine::initializeGlobal()
qt_add_sqlexceptions(this);
- {
- for (uint i = 0; i < globalObject->internalClass()->size; ++i) {
- if (globalObject->internalClass()->nameMap.at(i).isString()) {
- QV4::PropertyKey id = globalObject->internalClass()->nameMap.at(i);
- m_illegalNames.insert(id.toQString());
- }
- }
- }
+ Q_ASSERT(globalNamesAreStaticallyKnown(globalObject));
}
void ExecutionEngine::createQtObject()
@@ -2341,11 +2353,6 @@ void ExecutionEngine::createQtObject()
globalObject->defineDefaultProperty(QStringLiteral("Qt"), qtObjectWrapper);
}
-const QSet<QString> &ExecutionEngine::illegalNames() const
-{
- return m_illegalNames;
-}
-
void ExecutionEngine::setQmlEngine(QQmlEngine *engine)
{
// Second stage of initialization. We're updating some more prototypes here.