summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-05-11 01:07:23 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-05-11 01:07:23 (GMT)
commit129940723d9145a4380f7e44c06cbaa88ee4053b (patch)
tree7d7849879d084c667cc44c81f66464a3356e802c /src
parent35bc65ecf89ccc14f2e949f2d2881e899f7c4165 (diff)
downloadQt-129940723d9145a4380f7e44c06cbaa88ee4053b.zip
Qt-129940723d9145a4380f7e44c06cbaa88ee4053b.tar.gz
Qt-129940723d9145a4380f7e44c06cbaa88ee4053b.tar.bz2
Correct ownership of signal handlers in state changes.
When a state uses override, we may apply the same replacesignalhandler on top of itself. Make sure we update ownership accordingly. Task-number: QTBUG-10523
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 6e88259..94780c4 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -161,15 +161,22 @@ public:
QDeclarativeExpression *rewindExpression;
QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
+ virtual bool changesBindings() { return true; }
+ virtual void clearBindings() {
+ ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, 0);
+ }
+
virtual void execute(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression);
- Q_ASSERT(expression != ownedExpression);
+ QDeclarativePropertyPrivate::setSignalExpression(property, expression);
+ if (ownedExpression == expression)
+ ownedExpression = 0;
}
virtual bool isReversable() { return true; }
virtual void reverse(Reason) {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
- Q_ASSERT(reverseExpression != ownedExpression);
+ QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression);
+ if (ownedExpression == reverseExpression)
+ ownedExpression = 0;
}
virtual void saveOriginals() {
@@ -177,12 +184,26 @@ public:
reverseExpression = rewindExpression;
}
+ virtual void copyOriginals(QDeclarativeActionEvent *other)
+ {
+ QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other);
+ saveCurrentValues();
+ if (rsh == this)
+ return;
+ reverseExpression = rsh->reverseExpression;
+ if (rsh->ownedExpression == reverseExpression) {
+ ownedExpression = rsh->ownedExpression;
+ rsh->ownedExpression = 0;
+ }
+ }
+
virtual void rewind() {
- ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
- Q_ASSERT(rewindExpression != ownedExpression);
+ QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression);
+ if (ownedExpression == rewindExpression)
+ ownedExpression = 0;
}
virtual void saveCurrentValues() {
- rewindExpression = QDeclarativePropertyPrivate::signalExpression(property);
+ rewindExpression = QDeclarativePropertyPrivate::signalExpression(property);
}
virtual bool override(QDeclarativeActionEvent*other) {