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>
if (captureRequired) {
if (property->accessors->notifier) {
- if (n)
- ep->captureProperty(n);
+ if (n && ep->propertyCapture)
+ ep->propertyCapture->captureProperty(n);
} else {
- ep->captureProperty(object, property->coreIndex, property->notifyIndex);
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureProperty(object, property->coreIndex, property->notifyIndex);
}
}
return rv->asReturnedValue();
}
- if (captureRequired && ep && !property->isConstant())
- ep->captureProperty(object, property->coreIndex, property->notifyIndex);
+ if (captureRequired && ep && ep->propertyCapture && !property->isConstant())
+ ep->propertyCapture->captureProperty(object, property->coreIndex, property->notifyIndex);
if (property->isVarProperty()) {
QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
#include <private/qv4compileddata_p.h>
#include <private/qqmltypewrapper_p.h>
#include <private/qqmllistwrapper_p.h>
+#include <private/qqmljavascriptexpression_p.h>
#include <private/qjsvalue_p.h>
QT_BEGIN_NAMESPACE
if (propertyIdx < context->idValueCount) {
- ep->captureProperty(&context->idValues[propertyIdx].bindings);
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureProperty(&context->idValues[propertyIdx].bindings);
if (hasProperty)
*hasProperty = true;
return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]);
QQmlContextPrivate *cp = context->asQQmlContextPrivate();
- ep->captureProperty(context->asQQmlContext(), -1,
- propertyIdx + cp->notifyIndex);
+ if (ep->propertyCapture)
+ ep->propertyCapture->captureProperty(context->asQQmlContext(), -1, propertyIdx + cp->notifyIndex);
const QVariant &value = cp->propertyValues.at(propertyIdx);
if (hasProperty)
QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : 0;
if (!ep)
return;
- QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture;
+ QQmlPropertyCapture *capture = ep->propertyCapture;
if (!capture)
return;
*hasProperty = true;
QQmlEnginePrivate *ep = scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : 0;
- if (ep)
- ep->captureProperty(&context->idValues[index].bindings);
+ if (ep && ep->propertyCapture)
+ ep->propertyCapture->captureProperty(&context->idValues[index].bindings);
return QObjectWrapper::wrap(This->engine(), context->idValues[index].data());
}
class QDir;
class QQmlIncubator;
class QQmlProfiler;
+class QQmlPropertyCapture;
// This needs to be declared here so that the pool for it can live in QQmlEnginePrivate.
// The inline method definitions are in qqmljavascriptexpression_p.h
// is just qmlClearTypeRegistrations (which can't be called while an engine exists)
static bool baseModulesUninitialized;
- class PropertyCapture {
- public:
- inline virtual ~PropertyCapture() {}
- virtual void captureProperty(QQmlNotifier *) = 0;
- virtual void captureProperty(QObject *, int, int) = 0;
- };
-
- PropertyCapture *propertyCapture;
- inline void captureProperty(QQmlNotifier *);
- inline void captureProperty(QObject *, int, int);
+ QQmlPropertyCapture *propertyCapture;
QRecyclePool<QQmlJavaScriptExpressionGuard> jsExpressionGuardPool;
return get(qmlEngine);
}
-void QQmlEnginePrivate::captureProperty(QQmlNotifier *n)
-{
- if (propertyCapture)
- propertyCapture->captureProperty(n);
-}
-
-void QQmlEnginePrivate::captureProperty(QObject *o, int c, int n)
-{
- if (propertyCapture)
- propertyCapture->captureProperty(o, c, n);
-}
-
void QQmlEnginePrivate::setDebugChangesCache(const QHash<QUrl, QByteArray> &changes)
{
Locker locker(this);
DeleteWatcher watcher(this);
Q_ASSERT(notifyOnValueChanged() || activeGuards.isEmpty());
- GuardCapture capture(m_context->engine, this, &watcher);
+ QQmlPropertyCapture capture(m_context->engine, this, &watcher);
- QQmlEnginePrivate::PropertyCapture *lastPropertyCapture = ep->propertyCapture;
+ QQmlPropertyCapture *lastPropertyCapture = ep->propertyCapture;
ep->propertyCapture = notifyOnValueChanged() ? &capture : 0;
capture.errorString = 0;
}
- while (Guard *g = capture.guards.takeFirst())
+ while (QQmlJavaScriptExpressionGuard *g = capture.guards.takeFirst())
g->Delete();
ep->propertyCapture = lastPropertyCapture;
return result->asReturnedValue();
}
-void QQmlJavaScriptExpression::GuardCapture::captureProperty(QQmlNotifier *n)
+void QQmlPropertyCapture::captureProperty(QQmlNotifier *n)
{
if (watcher->wasDeleted())
return;
while (!guards.isEmpty() && !guards.first()->isConnected(n))
guards.takeFirst()->Delete();
- Guard *g = 0;
+ QQmlJavaScriptExpressionGuard *g = 0;
if (!guards.isEmpty()) {
g = guards.takeFirst();
g->cancelNotify();
Q_ASSERT(g->isConnected(n));
} else {
- g = Guard::New(expression, engine);
+ g = QQmlJavaScriptExpressionGuard::New(expression, engine);
g->connect(n);
}
\a n is in the signal index range (see QObjectPrivate::signalIndex()).
*/
-void QQmlJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
+void QQmlPropertyCapture::captureProperty(QObject *o, int c, int n)
{
if (watcher->wasDeleted())
return;
while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
guards.takeFirst()->Delete();
- Guard *g = 0;
+ QQmlJavaScriptExpressionGuard *g = 0;
if (!guards.isEmpty()) {
g = guards.takeFirst();
g->cancelNotify();
Q_ASSERT(g->isConnected(o, n));
} else {
- g = Guard::New(expression, engine);
+ g = QQmlJavaScriptExpressionGuard::New(expression, engine);
g->connect(o, n, engine);
}
void QQmlJavaScriptExpression::clearGuards()
{
- while (Guard *g = activeGuards.takeFirst())
+ while (QQmlJavaScriptExpressionGuard *g = activeGuards.takeFirst())
g->Delete();
}
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;
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)
{