aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlboundsignal.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-31 16:49:14 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-02 14:04:11 +0200
commit4e012093462f07e7ffd42d4061539c54b4f43ace (patch)
tree5a90968cf1a57860af3a870d5a0d2c0619629bb6 /src/qml/qml/qqmlboundsignal.cpp
parent010e3e4f8d4045d3e807d612289886f3d709773c (diff)
Avoid recompiling of signal handlers defined in QtQuick state changes and Connection objects
We can re-use the expression we've compiled at QML type compilation time, as long as we "inject" the signal parameters in the dynamic qml lookup chain. Change-Id: Icc417531c41dea06ff5d033011179af49b03f542 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlboundsignal.cpp')
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index b0834d7f21..876f367097 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -52,6 +52,7 @@
#include "qqmlglobal_p.h"
#include <private/qqmlprofiler_p.h>
#include <private/qv4debugservice_p.h>
+#include <private/qqmlcompiler_p.h>
#include "qqmlinfo.h"
#include <private/qv4value_inl_p.h>
@@ -59,6 +60,7 @@
#include <QtCore/qstringbuilder.h>
#include <QtCore/qdebug.h>
+
QT_BEGIN_NAMESPACE
static QQmlJavaScriptExpression::VTable QQmlBoundSignalExpression_jsvtable = {
@@ -105,6 +107,28 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index,
init(ctxt, scope);
}
+QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction)
+ : QQmlJavaScriptExpression(&QQmlBoundSignalExpression_jsvtable),
+ m_target(target),
+ m_index(index),
+ m_extra(0)
+{
+ setExpressionFunctionValid(true);
+ setInvalidParameterName(false);
+
+ // It's important to call init first, because m_index gets remapped in case of cloned signals.
+ init(ctxt, scope);
+
+ QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index);
+ QString error;
+ m_v8function = QV4::QmlBindingWrapper::createQmlCallableForFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error);
+ if (!error.isEmpty()) {
+ qmlInfo(scopeObject()) << error;
+ setInvalidParameterName(true);
+ } else
+ setInvalidParameterName(false);
+}
+
void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope)
{
setNotifyOnValueChanged(false);