diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-19 09:32:42 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-20 14:27:39 +0200 |
commit | 57f7545f67d517d1c6cdbbf972db85cabe5ef8cf (patch) | |
tree | 1f1ad352bfeb18e0c895891013cd4d47ed9a15f8 /src/qml/compiler/qv4compileddata.cpp | |
parent | 064c2f8f0d97b97895ebc3ec2b5e2b1ff4c9f2b4 (diff) |
Fix destruction of QV4::CompiledData::CompilationUnit objects
Now that we store them per QML file, they live in the type cache and
can outlive the engine. Therefore the engine needs to free to unlink
any remaining units upon destruction. This needs to be done after the
"death" of the memory manager, which is likely to sweep away any
function objects that also hold a reference to the compilation units.
Change-Id: I3968d5995289e8d2bc1e3abbb1f8be88a0ab4e03
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compileddata.cpp')
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 990cf195c0..991fc922c3 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -65,15 +65,7 @@ namespace { CompilationUnit::~CompilationUnit() { - if (engine) - engine->compilationUnits.erase(engine->compilationUnits.find(this)); - if (ownsData) - free(data); - free(runtimeStrings); - delete [] runtimeLookups; - delete [] runtimeRegularExpressions; - free(runtimeClasses); - qDeleteAll(runtimeFunctions); + unlink(); } QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) @@ -147,6 +139,26 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine) return runtimeFunctions[data->indexOfRootFunction]; } +void CompilationUnit::unlink() +{ + if (engine) + engine->compilationUnits.erase(engine->compilationUnits.find(this)); + engine = 0; + if (ownsData) + free(data); + data = 0; + free(runtimeStrings); + runtimeStrings = 0; + delete [] runtimeLookups; + runtimeLookups = 0; + delete [] runtimeRegularExpressions; + runtimeRegularExpressions = 0; + free(runtimeClasses); + runtimeClasses = 0; + qDeleteAll(runtimeFunctions); + runtimeFunctions.clear(); +} + void CompilationUnit::markObjects() { for (int i = 0; i < data->stringTableSize; ++i) |