diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-07-01 08:48:41 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-03 13:22:25 +0200 |
commit | 06eaeb0ac8d861cf3e60b11a8fbbabdeef1d6759 (patch) | |
tree | 825fb27485c376d0b83e8dfbcd20c852f2dd525c /src/qml/qml/qqmlcompiler.cpp | |
parent | b30657647a7f816a2945302b3569b882d7ac6b72 (diff) |
Get rid of the signal expression rewriter
This replaces the entire rewriter with more or less:
expressionToEval = "(function(<named params here>) { " + expr + " } )"
This also fixes crashes at run-time when the signal rewriter was
executed from the loader thread and tried to use a v4 identifier
hash with the same engine that's also in the main thread.
Change-Id: Ib1e4927d330706a593411fbff64ed3da1e23d0e0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcompiler.cpp')
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index ee0d37b6d8..a940bb256b 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -53,10 +53,11 @@ #include "qqmlcontext_p.h" #include "qqmlcomponent_p.h" #include <private/qqmljsast_p.h> +#include <private/qqmljsparser_p.h> +#include <private/qqmljsmemorypool_p.h> #include "qqmlvmemetaobject_p.h" #include "qqmlexpression_p.h" #include "qqmlproperty_p.h" -#include "qqmlrewrite_p.h" #include "qqmlscriptstring.h" #include "qqmlglobal_p.h" #include "qqmlbinding_p.h" @@ -1312,18 +1313,9 @@ void QQmlCompiler::genObjectBody(QQmlScript::Object *obj) } else if (v->type == Value::SignalExpression) { Instruction::StoreSignal store; + store.handlerName = output->indexForString(prop->name().toString()); store.signalIndex = prop->index; - - const QList<QByteArray> ¶meterNameList = obj->metatype->signalParameterNames(prop->index); - QQmlRewrite::RewriteSignalHandler rewriter(enginePrivate->v4engine()); - int count = 0; - const QString &rewrite = rewriter(v->value.asAST(), v->value.asScript(), - prop->name().toString(), - obj->metatype->signalParameterStringForJS(prop->index, &count), - parameterNameList); - store.value = output->indexForByteArray(rewrite.toUtf8()); - store.parameterCount = - (rewriter.parameterAccess() == QQmlRewrite::RewriteSignalHandler::ParametersUnaccessed) ? 0 : count; + store.value = output->indexForString(v->value.asScript()); store.context = v->signalExpressionContextStack; store.line = v->location.start.line; store.column = v->location.start.column; @@ -1684,12 +1676,6 @@ bool QQmlCompiler::buildSignal(QQmlScript::Property *prop, QQmlScript::Object *o //all handlers should be on the original, rather than cloned signals in order //to ensure all parameters are available (see qqmlboundsignal constructor for more details) prop->index = obj->metatype->originalClone(prop->index); - - QString errorString; - obj->metatype->signalParameterStringForJS(prop->index, 0, &errorString); - if (!errorString.isEmpty()) - COMPILE_EXCEPTION(prop, errorString); - prop->values.first()->signalExpressionContextStack = ctxt.stack; } } @@ -2626,12 +2612,6 @@ int QQmlCompiler::bindingIdentifier(const Variant &value) return output->indexForString(value.asScript()); } -QString QQmlCompiler::rewriteSignalHandler(const QQmlScript::Variant& value, const QString &name) -{ - QQmlRewrite::RewriteSignalHandler rewriteSignalHandler(enginePrivate->v4engine()); - return rewriteSignalHandler(value.asAST(), value.asScript(), name); -} - // Ensures that the dynamic meta specification on obj is valid bool QQmlCompiler::checkDynamicMeta(QQmlScript::Object *obj) { @@ -2747,8 +2727,6 @@ bool QQmlCompiler::mergeDynamicMetaProperties(QQmlScript::Object *obj) return true; } -#include <private/qqmljsparser_p.h> - static QStringList astNodeToStringList(QQmlJS::AST::Node *node) { if (node->kind == QQmlJS::AST::Node::Kind_IdentifierExpression) { |