}
}
-void QQmlAbstractBoundSignal::addToObject()
+void QQmlAbstractBoundSignal::addToObject(QObject *obj)
{
Q_ASSERT(!m_prevSignal);
- QObject *obj = object();
Q_ASSERT(obj);
QQmlData *data = QQmlData::get(obj, true);
QQmlBoundSignal::QQmlBoundSignal(QObject *scope, const QMetaMethod &signal,
QObject *owner)
-: m_expression(0), m_signal(signal), m_paramsValid(false), m_isEvaluating(false), m_params(0), m_owner(owner)
+: m_expression(0), m_params(0), m_scope(scope), m_signal(signal), m_paramsValid(false), m_isEvaluating(false)
{
// This is thread safe. Although it may be updated by two threads, they
// will both set it to the same value - so the worst thing that can happen
// is that they both do the work to figure it out. Boo hoo.
if (evaluateIdx == -1) evaluateIdx = metaObject()->methodCount();
+ addToObject(owner);
+
QQmlPropertyPrivate::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
}
if (scope == "Qt")
meta = &QObject::staticQtMetaObject;
else
- meta = static_cast<QQmlBoundSignal*>(parent)->object()->metaObject();
+ meta = static_cast<QQmlBoundSignal*>(parent)->scope()->metaObject();
for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
QMetaEnum m = meta->enumerator(i);
if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope))) {
}
}
-////////////////////////////////////////////////////////////////////////
-
-QQmlBoundSignalNoParams::QQmlBoundSignalNoParams(QObject *scope, const QMetaMethod &signal,
- QObject *owner)
-: m_expression(0), m_owner(owner), m_index(signal.methodIndex()), m_isEvaluating(false)
-{
- callback = &subscriptionCallback;
- QQmlNotifierEndpoint::connect(scope, m_index);
-}
-
-QQmlBoundSignalNoParams::~QQmlBoundSignalNoParams()
-{
- delete m_expression;
- m_expression = 0;
-}
-
-int QQmlBoundSignalNoParams::index() const
-{
- return m_index;
-}
-
-/*!
- Returns the signal expression.
-*/
-QQmlBoundSignalExpression *QQmlBoundSignalNoParams::expression() const
-{
- return m_expression;
-}
-
-/*!
- Sets the signal expression to \a e. Returns the current signal expression,
- or null if there is no signal expression.
-
- The QQmlBoundSignalNoParams instance takes ownership of \a e. The caller is
- assumes ownership of the returned QQmlExpression.
-*/
-QQmlBoundSignalExpression *QQmlBoundSignalNoParams::setExpression(QQmlBoundSignalExpression *e)
-{
- QQmlBoundSignalExpression *rv = m_expression;
- m_expression = e;
- if (m_expression) m_expression->setNotifyOnValueChanged(false);
- return rv;
-}
-
-void QQmlBoundSignalNoParams::subscriptionCallback(QQmlNotifierEndpoint *e)
-{
- QQmlBoundSignalNoParams *s = static_cast<QQmlBoundSignalNoParams*>(e);
- if (!s->m_expression)
- return;
-
- if (QQmlDebugService::isDebuggingEnabled())
- QV8DebugService::instance()->signalEmitted(QString::fromAscii(s->m_owner->metaObject()->method(s->m_index).signature()));
-
- QQmlHandlingSignalProfiler prof(s->m_owner, s->m_index, s->m_expression);
-
- s->m_isEvaluating = true;
- if (s->m_expression && s->m_expression->engine()) {
- s->m_expression->evaluate(); // evaluate signal expression.
- if (s->m_expression && s->m_expression->hasError())
- QQmlEnginePrivate::warning(s->m_expression->engine(), s->m_expression->error());
- }
- s->m_isEvaluating = false;
-}
-
QT_END_NAMESPACE
#include <qqmlboundsignal.moc>