From 6ed6b740e1ea9cfa64990bb2805d37197f4da45e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 20 Jul 2009 19:22:50 +1000 Subject: Prevent expression evaluation data from overlapping --- src/declarative/fx/qfxkeyactions.cpp | 1 + src/declarative/qml/qmlexpression.cpp | 12 ++++++++---- src/declarative/qml/qpodvector_p.h | 11 +++++++++++ 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 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 &properties) { + //clearGuards(); Q_Q(QmlExpression); static int notifyIdx = -1; @@ -499,7 +504,7 @@ void QmlExpressionPrivate::updateGuards(const QPODVectorexpression(); } /*! 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 &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 &operator<<(const T &v) { append(v); return *this; } private: QPODVector(const QPODVector &); -- cgit v0.12