aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-12-21 16:53:36 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-10 11:22:37 +0100
commitbe6d1499af75228341227d15441284e07cfe1e41 (patch)
tree99c5b1e3dc7f1b99d8c141f1b8138feacd29e020 /tools
parentcfdc612c3022b3f35545fd5e4e0bcd2661f657f1 (diff)
QtQml: Always link executable CU on creation
We don't want floating unlinked executable CUs. They should always be tied to an engine, and the engine should not change. This gives us one definite point where to register them with the engine (to be done in subsequent change). Unfortunately, due to the refcounting, we need to remove the engine from any still-referenced CUs when the engine itself is destructed. We will be able to drop the refcounting and make the engine fully own its executable CUs once we can hold base CUs in most places. Change-Id: I9a53e83d5c4746c2b2bca896b51baa4fe7fee757 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmljs/qmljs.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 2b12c4fc9d..99de7f528c 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
if (runAsModule) {
auto module = vm.loadModule(QUrl::fromLocalFile(QFileInfo(fn).absoluteFilePath()));
if (module.compiled) {
- if (module.compiled->instantiate(&vm))
+ if (module.compiled->instantiate())
module.compiled->evaluate();
} else if (module.native) {
// Nothing to do. Native modules have no global code.
@@ -120,11 +120,12 @@ int main(int argc, char *argv[])
}
QScopedPointer<QV4::Script> script;
if (useCache && QFile::exists(fn + QLatin1Char('c'))) {
- QQmlRefPointer<QV4::ExecutableCompilationUnit> unit
- = QV4::ExecutableCompilationUnit::create();
+ auto unit = QQml::makeRefPointer<QV4::CompiledData::CompilationUnit>();
QString error;
if (unit->loadFromDisk(QUrl::fromLocalFile(fn), QFileInfo(fn).lastModified(), &error)) {
- script.reset(new QV4::Script(&vm, nullptr, unit));
+ script.reset(new QV4::Script(
+ &vm, nullptr, QV4::ExecutableCompilationUnit::create(
+ std::move(unit), &vm)));
} else {
std::cout << "Error loading" << qPrintable(fn) << "from disk cache:" << qPrintable(error) << std::endl;
}
@@ -145,7 +146,8 @@ int main(int argc, char *argv[])
const_cast<QV4::CompiledData::Unit*>(unit->unitData())->sourceTimeStamp = QFileInfo(fn).lastModified().toMSecsSinceEpoch();
}
QString saveError;
- if (!unit->saveToDisk(QUrl::fromLocalFile(fn), &saveError)) {
+ if (!unit->baseCompilationUnit()->saveToDisk(
+ QUrl::fromLocalFile(fn), &saveError)) {
std::cout << "Error saving JS cache file: " << qPrintable(saveError) << std::endl;
}
}