diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-05-24 08:57:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-24 09:15:57 +0200 |
commit | b254bbb82b7d1b42950c4267d8e618b570f88cc6 (patch) | |
tree | c8f9fd1fcbd5c5d4a75ffea79ee623ce59e9ae9b /src | |
parent | 1b0e6861ba7af231c29ebba10c93976845f7f78d (diff) | |
parent | 5b8a94eb8e5d4e3b79ab73a9a0325f838ecbe41a (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I0127f2c16de1d930bdd8cbccd42ec6785f31ab96
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp | 55 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h | 2 | ||||
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 7 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 19 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 | ||||
-rw-r--r-- | src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc | 4 | ||||
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 2 | ||||
-rw-r--r-- | src/quick/items/qquickevents.cpp | 10 | ||||
-rw-r--r-- | src/quick/items/qquickitem.cpp | 5 |
10 files changed, 70 insertions, 52 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index cc1db7b5ce..0993390483 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -73,17 +73,12 @@ QV4::Heap::ExecutionContext *QV4DataCollector::findContext(int frame) return f ? f->context()->d() : nullptr; } -QV4::Heap::CallContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) +QV4::Heap::ExecutionContext *QV4DataCollector::findScope(QV4::Heap::ExecutionContext *ctx, int scope) { - if (!ctx) - return nullptr; - for (; scope > 0 && ctx; --scope) ctx = ctx->outer; - if (!ctx || (ctx->type != QV4::Heap::ExecutionContext::Type_CallContext && ctx->type != QV4::Heap::ExecutionContext::Type_BlockContext)) - return nullptr; - return static_cast<QV4::Heap::CallContext *>(ctx); + return ctx; } QVector<QV4::Heap::ExecutionContext::ContextType> QV4DataCollector::getScopeTypes(int frame) @@ -102,16 +97,17 @@ int QV4DataCollector::encodeScopeType(QV4::Heap::ExecutionContext::ContextType s { switch (scopeType) { case QV4::Heap::ExecutionContext::Type_GlobalContext: - return 0; + break; case QV4::Heap::ExecutionContext::Type_WithContext: return 2; case QV4::Heap::ExecutionContext::Type_CallContext: return 1; - case QV4::Heap::ExecutionContext::Type_BlockContext: + case QV4::Heap::ExecutionContext::Type_QmlContext: return 3; - default: // QV4::Heap::ExecutionContext::Type_QmlContext: - return -1; + case QV4::Heap::ExecutionContext::Type_BlockContext: + return 4; } + return 0; } QV4DataCollector::QV4DataCollector(QV4::ExecutionEngine *engine) @@ -260,31 +256,32 @@ bool QV4DataCollector::isValidRef(QV4DataCollector::Ref ref) const bool QV4DataCollector::collectScope(QJsonObject *dict, int frameNr, int scopeNr) { - QStringList names; - QV4::Scope scope(engine()); - QV4::Scoped<QV4::CallContext> ctxt(scope, findScope(findContext(frameNr), scopeNr)); + QV4::Scoped<QV4::ExecutionContext> ctxt(scope, findScope(findContext(frameNr), scopeNr)); if (!ctxt) return false; - Refs collectedRefs; - QV4::ScopedValue v(scope); - QV4::Heap::InternalClass *ic = ctxt->internalClass(); - for (uint i = 0; i < ic->size; ++i) { - QString name = ic->nameMap[i].toQString(); - names.append(name); - v = ctxt->d()->locals[i]; - collectedRefs.append(collect(v)); - } - QV4::ScopedObject scopeObject(scope, engine()->newObject()); + if (ctxt->d()->type == QV4::Heap::ExecutionContext::Type_CallContext) { + QStringList names; + Refs collectedRefs; + + QV4::ScopedValue v(scope); + QV4::Heap::InternalClass *ic = ctxt->internalClass(); + for (uint i = 0; i < ic->size; ++i) { + QString name = ic->nameMap[i].toQString(); + names.append(name); + v = static_cast<QV4::Heap::CallContext *>(ctxt->d())->locals[i]; + collectedRefs.append(collect(v)); + } - Q_ASSERT(names.size() == collectedRefs.size()); - QV4::ScopedString propName(scope); - for (int i = 0, ei = collectedRefs.size(); i != ei; ++i) { - propName = engine()->newString(names.at(i)); - scopeObject->put(propName, QV4::Value::fromReturnedValue(getValue(collectedRefs.at(i)))); + Q_ASSERT(names.size() == collectedRefs.size()); + QV4::ScopedString propName(scope); + for (int i = 0, ei = collectedRefs.size(); i != ei; ++i) { + propName = engine()->newString(names.at(i)); + scopeObject->put(propName, (v = getValue(collectedRefs.at(i)))); + } } Ref scopeObjectRef = addRef(scopeObject); diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h index 87be009de5..5494e10e9a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h @@ -58,7 +58,7 @@ public: typedef uint Ref; typedef QVector<uint> Refs; - static QV4::Heap::CallContext *findScope(QV4::Heap::ExecutionContext *ctxt, int scope); + static QV4::Heap::ExecutionContext *findScope(QV4::Heap::ExecutionContext *ctxt, int scope); static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes(int frame); diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index fcd535905b..820f127331 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -2427,6 +2427,22 @@ QmlIR::Object *IRLoader::loadObject(const QV4::CompiledData::Object *serializedO object->qmlSignals->append(s); } + for (uint i = 0; i < serializedObject->nEnums; ++i) { + const QV4::CompiledData::Enum *serializedEnum = serializedObject->enumAt(i); + QmlIR::Enum *e = pool->New<QmlIR::Enum>(); + e->nameIndex = serializedEnum->nameIndex; + e->location = serializedEnum->location; + e->enumValues = pool->New<QmlIR::PoolList<QmlIR::EnumValue> >(); + + for (uint i = 0; i < serializedEnum->nEnumValues; ++i) { + QmlIR::EnumValue *v = pool->New<QmlIR::EnumValue>(); + *static_cast<QV4::CompiledData::EnumValue*>(v) = *serializedEnum->enumValueAt(i); + e->enumValues->append(v); + } + + object->qmlEnums->append(e); + } + const QV4::CompiledData::Property *serializedProperty = serializedObject->propertyTable(); for (uint i = 0; i < serializedObject->nProperties; ++i, ++serializedProperty) { QmlIR::Property *p = pool->New<QmlIR::Property>(); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index ff32671dc8..96670154e1 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -852,16 +852,19 @@ QQmlContextData *ExecutionEngine::callingQmlContext() const QString CppStackFrame::source() const { - return v4Function->sourceFile(); + return v4Function ? v4Function->sourceFile() : QString(); } QString CppStackFrame::function() const { - return v4Function->name()->toQString(); + return v4Function ? v4Function->name()->toQString() : QString(); } int CppStackFrame::lineNumber() const { + if (!v4Function) + return -1; + auto findLine = [](const CompiledData::CodeOffsetToLine &entry, uint offset) { return entry.codeOffset < offset; }; diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 8c3c487e96..d455885699 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -358,9 +358,8 @@ qreal QQmlDataBlob::progress() const /*! Returns the physical url of the data. Initially this is the same as -finalUrl(), but if a network redirect happens while fetching the data, this url -is updated to reflect the new location. Also, if a URL interceptor is set, it -will work on this URL and leave finalUrl() alone. +finalUrl(), but if a URL interceptor is set, it will work on this URL +and leave finalUrl() alone. \sa finalUrl() */ @@ -381,8 +380,12 @@ QString QQmlDataBlob::urlString() const Returns the logical URL to be used for resolving further URLs referred to in the code. -This is the blob url passed to the constructor. If a network redirect -happens while fetching the data, this url remains the same. +This is the blob url passed to the constructor. If a URL interceptor rewrites +the URL, this one stays the same. If a network redirect happens while fetching +the data, this url is updated to reflect the new location. Therefore, if both +an interception and a redirection happen, the final url will indirectly +incorporate the result of the interception, potentially breaking further +lookups. \sa url() */ @@ -1190,15 +1193,15 @@ void QQmlTypeLoader::networkReplyFinished(QNetworkReply *reply) QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redirect.isValid()) { QUrl url = reply->url().resolved(redirect.toUrl()); - blob->m_url = url; - blob->m_urlString.clear(); + blob->m_finalUrl = url; + blob->m_finalUrlString.clear(); QNetworkReply *reply = m_thread->networkAccessManager()->get(QNetworkRequest(url)); QObject *nrp = m_thread->networkReplyProxy(); QObject::connect(reply, SIGNAL(finished()), nrp, SLOT(finished())); m_networkReplies.insert(reply, blob); #ifdef DATABLOB_DEBUG - qWarning("QQmlDataBlob: redirected to %s", qPrintable(blob->urlString())); + qWarning("QQmlDataBlob: redirected to %s", qPrintable(blob->finalUrlString())); #endif return; } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 4ae78645ea..bff16441d0 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1703,7 +1703,7 @@ ReturnedValue ConsoleObject::method_count(const FunctionObject *b, const Value * QString scriptName = frame->source(); - int value = v8engine->consoleCountHelper(scriptName, frame->lineNumber(), -1); + int value = v8engine->consoleCountHelper(scriptName, frame->lineNumber(), 0); QString message = name + QLatin1String(": ") + QString::number(value); QMessageLogger(qPrintable(scriptName), frame->lineNumber(), diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc index b22b013684..30aca38678 100644 --- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc +++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc @@ -318,8 +318,8 @@ component loaded by the engine. Context properties are useful for objects that must be available as soon as the QML is loaded and cannot be instantiated in QML. -\l {Integrating QML and C++} demonstrates an alternative approach where QML is -made aware of a C++ type so that it can instantiate it itself. +For a quick guide to choosing the correct approach to expose C++ types to QML, +see \l {Choosing the Correct Integration Method Between C++ and QML}. \section2 Related Information \list diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index e01e87b45a..07d5f6d39b 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -1637,7 +1637,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(const QV4::Scoped<QQuickContext2DStyle> gradient(scope, scope.engine->memoryManager->allocate<QQuickContext2DStyle>()); QV4::ScopedObject p(scope, ed->gradientProto.value()); gradient->setPrototype(p); - *gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0)); + *gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r1, QPointF(x0, y0), r0); RETURN_RESULT(*gradient); } diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index d964f2bb32..d020ad7c4c 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -849,14 +849,16 @@ void QQuickEventPoint::setGrabberItem(QQuickItem *grabber) qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this) << ": grab" << m_exclusiveGrabber << "->" << grabber; } + QQuickItem *oldGrabberItem = grabberItem(); m_exclusiveGrabber = QPointer<QObject>(grabber); m_grabberIsHandler = false; m_sceneGrabPos = m_scenePos; - QQuickItem *oldGrabberItem = grabberItem(); - if (oldGrabberHandler) + if (oldGrabberHandler) { oldGrabberHandler->onGrabChanged(oldGrabberHandler, (grabber ? CancelGrabExclusive : UngrabExclusive), this); - else if (oldGrabberItem && oldGrabberItem != grabber && grabber && pointerEvent()->asPointerTouchEvent()) - oldGrabberItem->touchUngrabEvent(); + } else if (oldGrabberItem && oldGrabberItem != grabber && grabber && grabber->window()) { + QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(grabber->window()); + windowPriv->sendUngrabEvent(oldGrabberItem, windowPriv->isDeliveringTouchAsMouse()); + } for (QPointer<QQuickPointerHandler> passiveGrabber : m_passiveGrabbers) passiveGrabber->onGrabChanged(passiveGrabber, OverrideGrabPassive, this); } diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index f02ad24c5b..73fc12babd 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7462,11 +7462,8 @@ void QQuickItem::grabMouse() auto point = fromTouch ? windowPriv->pointerEventInstance(windowPriv->touchMouseDevice)->pointById(windowPriv->touchMouseId) : windowPriv->pointerEventInstance(QQuickPointerDevice::genericMouseDevice())->point(0); - if (point) { - QQuickItem *oldGrabber = point->grabberItem(); + if (point) point->setGrabberItem(this); - windowPriv->sendUngrabEvent(oldGrabber, fromTouch); - } } /*! |