From f9dc375fbd329e80bda8ceb6e3a425917bb1f4fd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 23 Jan 2018 14:05:42 +0100 Subject: Fix compilation unit memory leak when using qml caching from resources The unit created via the factory function has a refcount of 1, so we need to adopt it. Change-Id: Ia7aadf02c9fc133919f97ea07fc3f3546a7e2680 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4script.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 369ec7d67e..caddf0a3e0 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -225,7 +225,8 @@ QQmlRefPointer Script::precompile(QV4::Compi Script *Script::createFromFileOrCache(ExecutionEngine *engine, QmlContext *qmlContext, const QString &fileName, const QUrl &originalUrl) { if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(originalUrl)) { - QV4::CompiledData::CompilationUnit *jsUnit = cachedUnit->createCompilationUnit(); + QQmlRefPointer jsUnit; + jsUnit.adopt(cachedUnit->createCompilationUnit()); return new QV4::Script(engine, qmlContext, jsUnit); } -- cgit v1.2.3