diff options
author | Qt by Nokia <qt-info@nokia.com> | 2011-04-27 14:13:26 +0200 |
---|---|---|
committer | axis <qt-info@nokia.com> | 2011-04-27 14:40:44 +0200 |
commit | a129444bb0156c936900dbd2f12bd9f427ff366c (patch) | |
tree | e2e8e77f185d5a5ac32ea0a96cd9945c742e8663 /src/declarative/qml/qdeclarativebinding.cpp | |
parent | 885735d011472bcfbb96e688d9e64553d7fe9d4b (diff) |
Initial import from qtquick2.
Branched from the monolithic repo, Qt qtquick2 branch, at commit
a4a585d2ee907746682846ae6e8a48e19deef469
Diffstat (limited to 'src/declarative/qml/qdeclarativebinding.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativebinding.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index a5bd604c53..3e93ce7266 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -357,13 +357,17 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } else { QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine); + ep->referenceScarceResources(); // "hold" scarce resources in memory during evaluation. bool isUndefined = false; QVariant value; QScriptValue scriptValue = d->scriptValue(0, &isUndefined); - if (wasDeleted) + + if (wasDeleted) { + ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. return; + } if (d->property.propertyTypeCategory() == QDeclarativeProperty::List) { value = ep->scriptValueToVariant(scriptValue, qMetaTypeId<QList<QObject *> >()); @@ -420,8 +424,10 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) } else if (d->property.object() && !QDeclarativePropertyPrivate::write(d->property, value, flags)) { - if (wasDeleted) + if (wasDeleted) { + ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. return; + } QUrl url = QUrl(d->url); int line = d->line; @@ -440,14 +446,21 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) QLatin1String(QMetaType::typeName(d->property.propertyType()))); } - if (wasDeleted) + if (wasDeleted) { + ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. return; + } if (d->error.isValid()) { if (!d->addError(ep)) ep->warning(this->error()); } else { d->removeError(); } + + // at this point, the binding has been evaluated. If any scarce + // resources were copied during the evaluation of the binding, + // we need to release those copies. + ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } d->updating = false; |