diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-12 00:27:33 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-12 00:27:33 (GMT) |
commit | c0c2352a287348469617811985d773ec4c3d1875 (patch) | |
tree | c5c2dd49a062a8ea2a04c8eb9815ed83185b0055 | |
parent | 20b9cfdfa2147627dc3ca5cf514402d08ff8d832 (diff) | |
download | Qt-c0c2352a287348469617811985d773ec4c3d1875.zip Qt-c0c2352a287348469617811985d773ec4c3d1875.tar.gz Qt-c0c2352a287348469617811985d773ec4c3d1875.tar.bz2 |
Cached programs and closures must be destroyed at shutdown
-rw-r--r-- | src/declarative/qml/qmlcompileddata.cpp | 15 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 8 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 2 |
4 files changed, 21 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp index de9bf96..48a0893 100644 --- a/src/declarative/qml/qmlcompileddata.cpp +++ b/src/declarative/qml/qmlcompileddata.cpp @@ -161,8 +161,8 @@ int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l) return rv; } -QmlCompiledData::QmlCompiledData() -: importCache(0), root(0), rootPropertyCache(0) +QmlCompiledData::QmlCompiledData(QmlEngine *engine) +: QmlCleanup(engine), importCache(0), root(0), rootPropertyCache(0) { } @@ -189,6 +189,17 @@ QmlCompiledData::~QmlCompiledData() qDeleteAll(cachedClosures); } +void QmlCompiledData::clear() +{ + qDeleteAll(cachedPrograms); + qDeleteAll(cachedClosures); + for (int ii = 0; ii < cachedClosures.count(); ++ii) + cachedClosures[ii] = 0; + for (int ii = 0; ii < cachedPrograms.count(); ++ii) + cachedPrograms[ii] = 0; +} + + QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt, const QBitField &bindings) const { if (type) { diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index c0e50e4..732fbad 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -74,10 +74,10 @@ class QmlComponent; class QmlContext; class QScriptProgram; -class Q_AUTOTEST_EXPORT QmlCompiledData : public QmlRefCount +class Q_AUTOTEST_EXPORT QmlCompiledData : public QmlRefCount, public QmlCleanup { public: - QmlCompiledData(); + QmlCompiledData(QmlEngine *engine); virtual ~QmlCompiledData(); QString name; @@ -123,6 +123,10 @@ public: QList<QUrl> urls; void dumpInstructions(); + +protected: + virtual void clear(); // From QmlCleanup + private: void dump(QmlInstruction *, int idx = -1); QmlCompiledData(const QmlCompiledData &other); diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index ff786cf..1613051 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -119,7 +119,7 @@ QmlCompositeTypeData::toCompiledComponent(QmlEngine *engine) { if (status == Complete && !compiledComponent) { - compiledComponent = new QmlCompiledData; + compiledComponent = new QmlCompiledData(engine); compiledComponent->url = imports.baseUrl(); compiledComponent->name = compiledComponent->url.toString(); diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index e46ea96..52530db 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -145,7 +145,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl d->errors.clear(); d->imports.clear(); - QmlCompiledData *component = new QmlCompiledData; + QmlCompiledData *component = new QmlCompiledData(engine); QmlCompiler compiler; QmlCompositeTypeData *td = ((QmlEnginePrivate *)QmlEnginePrivate::get(engine))->typeManager.getImmediate(data, url); |