diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-06-10 13:32:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-06-18 14:41:13 +0000 |
commit | 1d76a5d3eab1a071fa35b2668bb09c4adfc41e01 (patch) | |
tree | 2a766457bdbb61975b8d98f213b59648bacd69c6 /src/qml/qml/qqmljavascriptexpression_p.h | |
parent | 329f9ad18e7dd55b72f6611f321c18538f753ea8 (diff) |
Simplify property capturing code
No need to inherit from a base class defined in QQmlEnginePrivate.
The capture handling can be a simple value based class without
virtual methods that is allocated on the stack.
Change-Id: Ib0ddf4afcaf154b3f953d8c9322f5bec196d7abf
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/qml/qqmljavascriptexpression_p.h')
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index ce490ee170..24e9878aa2 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -145,35 +145,16 @@ public: private: friend class QQmlContextData; - typedef QQmlJavaScriptExpressionGuard Guard; + friend class QQmlPropertyCapture; friend void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **); - struct GuardCapture : public QQmlEnginePrivate::PropertyCapture { - GuardCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, DeleteWatcher *w) - : engine(engine), expression(e), watcher(w), errorString(0) { } - - ~GuardCapture() { - Q_ASSERT(guards.isEmpty()); - Q_ASSERT(errorString == 0); - } - - virtual void captureProperty(QQmlNotifier *); - virtual void captureProperty(QObject *, int, int); - - QQmlEngine *engine; - QQmlJavaScriptExpression *expression; - DeleteWatcher *watcher; - QFieldList<Guard, &Guard::next> guards; - QStringList *errorString; - }; - QQmlDelayedError *m_error; // We store some flag bits in the following flag pointers. // activeGuards:flag1 - notifyOnValueChanged // activeGuards:flag2 - useSharedContext QBiPointer<QObject, DeleteWatcher> m_scopeObject; - QForwardFieldList<Guard, &Guard::next> activeGuards; + QForwardFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> activeGuards; QQmlContextData *m_context; QQmlJavaScriptExpression **m_prevExpression; @@ -183,6 +164,27 @@ protected: QV4::PersistentValue m_function; }; +class QQmlPropertyCapture +{ +public: + QQmlPropertyCapture(QQmlEngine *engine, QQmlJavaScriptExpression *e, QQmlJavaScriptExpression::DeleteWatcher *w) + : engine(engine), expression(e), watcher(w), errorString(0) { } + + ~QQmlPropertyCapture() { + Q_ASSERT(guards.isEmpty()); + Q_ASSERT(errorString == 0); + } + + void captureProperty(QQmlNotifier *); + void captureProperty(QObject *, int, int); + + QQmlEngine *engine; + QQmlJavaScriptExpression *expression; + QQmlJavaScriptExpression::DeleteWatcher *watcher; + QFieldList<QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next> guards; + QStringList *errorString; +}; + QQmlJavaScriptExpression::DeleteWatcher::DeleteWatcher(QQmlJavaScriptExpression *e) : _c(0), _w(0), _s(e) { |