From f25f00210cf528f017c64d2fe6505ef15f9447f7 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 2 Dec 2009 12:49:24 +1000 Subject: Cleanup cached binding closures --- src/declarative/qml/qmlcompileddata.cpp | 4 ++-- src/declarative/qml/qmlcompiler.cpp | 13 +++++++++---- src/declarative/qml/qmlcompiler_p.h | 4 ++-- src/declarative/qml/qmlexpression.cpp | 12 ++++++------ 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/declarative/qml/qmlcompileddata.cpp b/src/declarative/qml/qmlcompileddata.cpp index 3428574..9b931c5 100644 --- a/src/declarative/qml/qmlcompileddata.cpp +++ b/src/declarative/qml/qmlcompileddata.cpp @@ -167,8 +167,8 @@ QmlCompiledData::~QmlCompiledData() if (importCache) importCache->release(); - qDeleteAll(programs); - qDeleteAll(cachedValues); + qDeleteAll(cachedPrograms); + qDeleteAll(cachedClosures); } QObject *QmlCompiledData::TypeReference::createInstance(QmlContext *ctxt, const QBitField &bindings) const diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index a0e9418..aac2e02 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -2538,12 +2538,17 @@ bool QmlCompiler::completeComponentBuild() expression = rewriteBinding(expression); quint32 length = expression.length(); - quint32 pc = output->programs.length(); - if (isSharable) + quint32 pc; + + if (isSharable) { + pc = output->cachedClosures.count(); pc |= 0x80000000; + output->cachedClosures.append(0); + } else { + pc = output->cachedPrograms.length(); + output->cachedPrograms.append(0); + } - output->programs.append(0); - output->cachedValues.append(0); binding.compiledData = QByteArray((const char *)&pc, sizeof(quint32)) + QByteArray((const char *)&length, sizeof(quint32)) + diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index ca26062..542fb48 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -113,8 +113,8 @@ public: QList datas; QList locations; QList bytecode; - QList programs; - QList cachedValues; + QList cachedPrograms; + QList cachedClosures; QList propertyCaches; QList contextCaches; QList scripts; diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 703fcf5..2239d77 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -117,22 +117,22 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, if (isShared) { - if (!dd->cachedValues.at(progIdx)) { + if (!dd->cachedClosures.at(progIdx)) { QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine); scriptContext->pushScope(ep->contextClass->newSharedContext()); - dd->cachedValues[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url.toString(), data->line)); + dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url.toString(), data->line)); scriptEngine->popContext(); } - data->expressionFunction = *dd->cachedValues.at(progIdx); + data->expressionFunction = *dd->cachedClosures.at(progIdx); data->isShared = true; data->expressionFunctionValid = true; } else { #if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work? - if (!dd->programs.at(progIdx)) { - dd->programs[progIdx] = + if (!dd->cachedPrograms.at(progIdx)) { + dd->cachedPrograms[progIdx] = new QScriptProgram(data->expression, data->url.toString(), data->line); } #endif @@ -141,7 +141,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, scriptContext->pushScope(ep->contextClass->newContext(ctxt, me)); #if !defined(Q_OS_SYMBIAN) - data->expressionFunction = scriptEngine->evaluate(*dd->programs[progIdx]); + data->expressionFunction = scriptEngine->evaluate(*dd->cachedPrograms.at(progIdx)); #else data->expressionFunction = scriptEngine->evaluate(data->expression); #endif -- cgit v0.12