diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-09 13:48:14 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-05-09 13:48:14 +0200 |
commit | accc75e06e6fd65b166df994ec52fecd5b8c3f2f (patch) | |
tree | e86bb9085d04d5e2a0cde8b487a7db109fec33c8 /src | |
parent | 6a02e8801c71d8008c5b4db922a736c358fee00e (diff) | |
parent | 1e82f11629e5572783e5bfc36f24ad10c235ca53 (diff) |
Merge remote-tracking branch 'origin/5.11.0' into 5.11
Change-Id: Id292599780ae47c6f2f3fa2d3bbc542b113bd16b
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 16 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 8ada1d505e..c281275da1 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2104,9 +2104,14 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast, _context->addLocalVar(QStringLiteral("arguments"), Context::VariableDeclaration, AST::VariableDeclaration::FunctionScope); bool allVarsEscape = _context->hasWith || _context->hasTry || _context->hasDirectEval; - if (_context->compilationMode == QmlBinding // we don't really need this for bindings, but we do for signal handlers, and we don't know if the code is a signal handler or not. - || (!_context->canUseSimpleCall() && _context->compilationMode != GlobalCode && - (_context->compilationMode != EvalCode || _context->isStrict))) { + bool needsCallContext = false; + const QLatin1String exprForOn("expression for on"); + if (!_context->canUseSimpleCall() && _context->compilationMode != GlobalCode && (_context->compilationMode != EvalCode || _context->isStrict)) + needsCallContext = true; + else if (_context->compilationMode == QmlBinding && name.length() > exprForOn.size() && name.startsWith(exprForOn) && name.at(exprForOn.size()).isUpper()) + // we don't really need this for bindings, but we do for signal handlers, and we don't know if the code is a signal handler or not. + needsCallContext = true; + if (needsCallContext) { Instruction::CreateCallContext createContext; bytecodeGenerator->addInstruction(createContext); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index dc8ee550d5..83608070ec 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -360,13 +360,15 @@ ReturnedValue FunctionPrototype::method_bind(const FunctionObject *b, const Valu BoundFunction *bound = static_cast<BoundFunction *>(target.getPointer()); Scoped<MemberData> oldArgs(scope, bound->boundArgs()); boundThis = bound->boundThis(); - int oldSize = oldArgs->size(); - boundArgs = MemberData::allocate(scope.engine, oldSize + nArgs); - boundArgs->d()->values.size = oldSize + nArgs; - for (uint i = 0; i < static_cast<uint>(oldSize); ++i) - boundArgs->set(scope.engine, i, oldArgs->data()[i]); - for (uint i = 0; i < static_cast<uint>(nArgs); ++i) - boundArgs->set(scope.engine, oldSize + i, argv[i + 1]); + int oldSize = !oldArgs ? 0 : oldArgs->size(); + if (oldSize + nArgs) { + boundArgs = MemberData::allocate(scope.engine, oldSize + nArgs); + boundArgs->d()->values.size = oldSize + nArgs; + for (uint i = 0; i < static_cast<uint>(oldSize); ++i) + boundArgs->set(scope.engine, i, oldArgs->data()[i]); + for (uint i = 0; i < static_cast<uint>(nArgs); ++i) + boundArgs->set(scope.engine, oldSize + i, argv[i + 1]); + } target = bound->target(); } else if (nArgs) { boundArgs = MemberData::allocate(scope.engine, nArgs); |