summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-08-06 03:11:21 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-08-06 03:11:21 (GMT)
commitd4ebb04b8f0db7821f5059fc31020362f85c7c30 (patch)
tree67f03f55aa77c14bd1017e00f1c67f7dd914340e
parenta19afebf6acee64aa4a5c804a87846c91650a474 (diff)
downloadQt-d4ebb04b8f0db7821f5059fc31020362f85c7c30.zip
Qt-d4ebb04b8f0db7821f5059fc31020362f85c7c30.tar.gz
Qt-d4ebb04b8f0db7821f5059fc31020362f85c7c30.tar.bz2
Don't leak bindings.
Make sure we clean up bindings for a cancelled state change.
-rw-r--r--src/declarative/util/qmlsetproperties.cpp1
-rw-r--r--src/declarative/util/qmlstate.cpp11
-rw-r--r--src/declarative/util/qmlstate.h1
-rw-r--r--src/declarative/util/qmltransitionmanager.cpp16
4 files changed, 20 insertions, 9 deletions
diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp
index bbbc6a9..1cd4a79 100644
--- a/src/declarative/util/qmlsetproperties.cpp
+++ b/src/declarative/util/qmlsetproperties.cpp
@@ -335,6 +335,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions()
a.toValue = d->expressions.at(ii).second->value();
} else {
a.toBinding = new QmlBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this));
+ a.deletableToBinding = true;
a.toBinding->setTarget(prop);
}
diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp
index b5ba909..9967486 100644
--- a/src/declarative/util/qmlstate.cpp
+++ b/src/declarative/util/qmlstate.cpp
@@ -54,14 +54,14 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
Action::Action()
-: restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0),
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0),
specifiedObject(0)
{
}
Action::Action(QObject *target, const QString &propertyName,
const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0),
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), toValue(value), fromBinding(0),
toBinding(0), event(0), specifiedObject(target),
specifiedProperty(propertyName)
{
@@ -413,11 +413,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever
SimpleAction r(action);
additionalReverts << r;
}
- } else {
-
- if (!found || d->revertList.at(jj).binding != action.fromBinding) {
- action.deleteFromBinding();
- }
+ } else if (d->revertList.at(jj).binding != action.fromBinding) {
+ action.deleteFromBinding();
}
}
diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h
index 7c62768..9eb7aee 100644
--- a/src/declarative/util/qmlstate.h
+++ b/src/declarative/util/qmlstate.h
@@ -64,6 +64,7 @@ public:
bool restore:1;
bool actionDone:1;
bool reverseEvent:1;
+ bool deletableToBinding:1;
QmlMetaProperty property;
QVariant fromValue;
diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp
index b2d9414..be082f8 100644
--- a/src/declarative/util/qmltransitionmanager.cpp
+++ b/src/declarative/util/qmltransitionmanager.cpp
@@ -239,10 +239,10 @@ void QmlTransitionManager::transition(const QList<Action> &list,
}
}
if (!transition)
- d->applyBindings(); //### merge into above foreach?
+ d->applyBindings();
}
-
+#include <QDebug>
void QmlTransitionManager::cancel()
{
if (d->transition) {
@@ -251,6 +251,18 @@ void QmlTransitionManager::cancel()
d->transition = 0;
}
+ for(int i = 0; i < d->bindingsList.count(); ++i) {
+ Action action = d->bindingsList[i];
+ if (action.toBinding && action.deletableToBinding) {
+ action.property.setBinding(0);
+ delete action.toBinding;
+ action.toBinding = 0;
+ action.deletableToBinding = false;
+ } else if (action.event) {
+ //### what do we do here?
+ }
+
+ }
d->bindingsList.clear();
d->completeList.clear();