summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 09:22:50 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-20 09:22:50 (GMT)
commit6ed6b740e1ea9cfa64990bb2805d37197f4da45e (patch)
treed437fd6a8d0ab74ae399a22a7fa35351d19213ed /src/declarative
parentc0a02f5c67d3de5e16fd506df83fef968e09c798 (diff)
downloadQt-6ed6b740e1ea9cfa64990bb2805d37197f4da45e.zip
Qt-6ed6b740e1ea9cfa64990bb2805d37197f4da45e.tar.gz
Qt-6ed6b740e1ea9cfa64990bb2805d37197f4da45e.tar.bz2
Prevent expression evaluation data from overlapping
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/fx/qfxkeyactions.cpp1
-rw-r--r--src/declarative/qml/qmlexpression.cpp12
-rw-r--r--src/declarative/qml/qpodvector_p.h11
3 files changed, 20 insertions, 4 deletions
diff --git a/src/declarative/fx/qfxkeyactions.cpp b/src/declarative/fx/qfxkeyactions.cpp
index 2c662a6..5de1f0b 100644
--- a/src/declarative/fx/qfxkeyactions.cpp
+++ b/src/declarative/fx/qfxkeyactions.cpp
@@ -900,6 +900,7 @@ void QFxKeyActions::keyPressEvent(QKeyEvent *event)
Qt::Key key = (Qt::Key)event->key();
if (d->enabled && d->key(key)) {
QmlExpression b(qmlContext(this), d->action(key), this);
+ b.setTrackChange(false);
b.value();
event->accept();
} else {
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp
index b4f57eb..ea0e9aa 100644
--- a/src/declarative/qml/qmlexpression.cpp
+++ b/src/declarative/qml/qmlexpression.cpp
@@ -347,7 +347,11 @@ QVariant QmlExpression::value()
QmlBasicScript::CacheState cacheState = QmlBasicScript::Reset;
QmlEnginePrivate *ep = engine()->d_func();
+
QmlExpression *lastCurrentExpression = ep->currentExpression;
+ QPODVector<QmlEnginePrivate::CapturedProperty> lastCapturedProperties;
+ ep->capturedProperties.copyAndClear(lastCapturedProperties);
+
ep->currentExpression = this;
if (d->sse.isValid()) {
@@ -364,7 +368,7 @@ QVariant QmlExpression::value()
d->updateGuards(ep->capturedProperties);
}
- ep->capturedProperties.clear();
+ lastCapturedProperties.copyAndClear(ep->capturedProperties);
return rv;
}
@@ -471,6 +475,7 @@ void QmlExpressionPrivate::clearGuards()
void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::CapturedProperty> &properties)
{
+ //clearGuards();
Q_Q(QmlExpression);
static int notifyIdx = -1;
@@ -499,7 +504,7 @@ void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::Captu
needGuard = false;
++hit;
}
- } else if(guardList[ii].data()) {
+ } else if(guardList[ii].data() && !guardList[ii].isDuplicate) {
// Cache miss
QMetaObject::disconnect(guardList[ii].data(),
guardList[ii].notifyIndex,
@@ -548,7 +553,7 @@ void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::Captu
}
for (int ii = properties.count(); ii < guardListLength; ++ii) {
- if (guardList[ii].data()) {
+ if (guardList[ii].data() && !guardList[ii].isDuplicate) {
QMetaObject::disconnect(guardList[ii].data(),
guardList[ii].notifyIndex,
q, notifyIdx);
@@ -560,7 +565,6 @@ void QmlExpressionPrivate::updateGuards(const QPODVector<QmlEnginePrivate::Captu
guardList = newGuardList;
guardListLength = properties.count();
}
- //qWarning() << hit << properties.count() << q->expression();
}
/*!
diff --git a/src/declarative/qml/qpodvector_p.h b/src/declarative/qml/qpodvector_p.h
index e74f9f6..77f7425 100644
--- a/src/declarative/qml/qpodvector_p.h
+++ b/src/declarative/qml/qpodvector_p.h
@@ -63,6 +63,7 @@ class QPODVector
public:
QPODVector()
: m_count(0), m_capacity(0), m_data(0) {}
+ ~QPODVector() { if (m_data) ::free(m_data); }
const T &at(int idx) const {
return m_data[idx];
@@ -122,6 +123,16 @@ public:
return m_count;
}
+ void copyAndClear(QPODVector<T> &other) {
+ if (other.m_data) ::free(other.m_data);
+ other.m_count = m_count;
+ other.m_capacity = m_capacity;
+ other.m_data = m_data;
+ m_count = 0;
+ m_capacity = 0;
+ m_data = 0;
+ }
+
QPODVector<T> &operator<<(const T &v) { append(v); return *this; }
private:
QPODVector(const QPODVector &);