diff options
author | Liang Qi <liang.qi@qt.io> | 2017-01-14 21:52:09 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-01-14 22:17:32 +0100 |
commit | 60300fda463ae0f31c1e66ca253a2a976a88ee20 (patch) | |
tree | b2264433418280ccbb7ed173892456fce4fab43a /src | |
parent | db462cce86dba0be80239d4aaaea668ef173af3d (diff) | |
parent | 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
.qmake.conf
Change-Id: I9d87ed86e95b5901a86cc3aa65d7ac39b0b708c2
Diffstat (limited to 'src')
23 files changed, 143 insertions, 66 deletions
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index 3786d21727..fd2ff4a73e 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -762,9 +762,11 @@ bool QQuickLayout::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&in void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) { if (change == ItemChildAddedChange) { + Q_D(QQuickLayout); QQuickItem *item = value.item; qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); + d->m_hasItemChangeListeners = true; if (isReady()) updateLayoutItems(); } else if (change == ItemChildRemovedChange) { @@ -802,6 +804,30 @@ bool QQuickLayout::isReady() const return d_func()->m_isReady; } +/*! + * \brief QQuickLayout::deactivateRecur + * \internal + * + * Call this from the dtor of the top-level layout. + * Otherwise, it will trigger lots of unneeded item change listeners (itemVisibleChanged()) for all its descendants + * that will have its impact thrown away. + */ +void QQuickLayout::deactivateRecur() +{ + if (d_func()->m_hasItemChangeListeners) { + for (int i = 0; i < itemCount(); ++i) { + QQuickItem *item = itemAt(i); + // When deleting a layout with children, there is no reason for the children to inform the layout that their + // e.g. visibility got changed. The layout already knows that all its children will eventually become invisible, so + // we therefore remove its change listener. + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); + if (QQuickLayout *layout = qobject_cast<QQuickLayout*>(item)) + layout->deactivateRecur(); + } + d_func()->m_hasItemChangeListeners = false; + } +} + void QQuickLayout::itemSiblingOrderChanged(QQuickItem *item) { Q_UNUSED(item); diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h index eece6f8658..113498eb2b 100644 --- a/src/imports/layouts/qquicklayout_p.h +++ b/src/imports/layouts/qquicklayout_p.h @@ -95,6 +95,7 @@ public: void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; bool isReady() const; + void deactivateRecur(); /* QQuickItemChangeListener */ @@ -134,6 +135,7 @@ public: protected: unsigned m_isReady : 1; unsigned m_disableRearrange : 1; + unsigned m_hasItemChangeListeners : 1; // if false, we don't need to remove its item change listeners... mutable QSet<QQuickItem *> m_ignoredItems; }; diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index 13fdd496c2..50b3eed87e 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -305,11 +305,7 @@ QQuickGridLayoutBase::~QQuickGridLayoutBase() // Remove item listeners so we do not act on signalling unnecessarily // (there is no point, as the layout will be torn down anyway). - for (int i = 0; i < itemCount(); ++i) { - QQuickItem *item = itemAt(i); - QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); - } - + deactivateRecur(); delete d->styleInfo; } diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 8586c84c3d..6aac111897 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -407,6 +407,11 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory const Unit * const oldDataPtr = (data && !(data->flags & QV4::CompiledData::Unit::StaticData)) ? data : nullptr; QScopedValueRollback<const Unit *> dataPtrChange(data, mappedUnit); + if (sourcePath != QQmlFile::urlToLocalFileOrQrc(stringAt(data->sourceFileIndex))) { + *errorString = QStringLiteral("QML source file has moved to a different location."); + return false; + } + { const QString foundArchitecture = stringAt(data->architectureIndex); const QString expectedArchitecture = QSysInfo::buildAbi(); diff --git a/src/qml/doc/src/examples.qdoc b/src/qml/doc/src/examples.qdoc index f3550ae199..4f12d42f48 100644 --- a/src/qml/doc/src/examples.qdoc +++ b/src/qml/doc/src/examples.qdoc @@ -32,4 +32,40 @@ The list of examples demonstrating how to extend C++ to QML or the other way around. + +\noautolist + +\table + \row + \li \l {Extending QML - Adding Types Example} + \li Exporting C++ Classes + \row + \li \l {Extending QML - Object and List Property Types Example} + \li Exporting C++ Properties + \row + \li \l {Extending QML - Extension Objects Example} + \li Extension Objects + \row + \li \l {Extending QML - Inheritance and Coercion Example} + \li C++ Inheritance and Coercion + \row + \li \l {Extending QML - Methods Example} + \li Methods Support + \row + \li \l {Extending QML - Attached Properties Example} + \li Attached Properties + \row + \li \l {Extending QML - Signal Support Example} + \li Signal Support + \row + \li \l {Extending QML - Property Value Source Example} + \li Property Value Source + \row + \li \l {Extending QML - Default Property Example} + \li Default Property + \row + \li \l {Extending QML - Grouped Properties Example} + \li Grouped Properties +\endtable + */ diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index b473e96286..bab2e633a7 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -73,7 +73,8 @@ For the object-based types (including Date and RegExp), use the newT() functions in QJSEngine (e.g. QJSEngine::newObject()) to create a QJSValue of the desired type. For the primitive types, - use one of the QJSValue constructor overloads. + use one of the QJSValue constructor overloads. For other types, e.g. + registered gadget types such as QPoint, you can use QJSEngine::toScriptValue. The methods named isT() (e.g. isBool(), isUndefined()) can be used to test if a value is of a certain type. The methods named diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 8f2c5174da..a11f7f0875 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -158,8 +158,6 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) } Q_ASSERT(maxCallDepth > 0); - MemoryManager::GCBlocker gcBlocker(memoryManager); - if (!factory) { #if QT_CONFIG(qml_interpreter) bool jitDisabled = true; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index b54177bee9..62145f36cc 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -88,8 +88,6 @@ void Script::parse() ExecutionEngine *v4 = scope->engine(); Scope valueScope(v4); - MemoryManager::GCBlocker gcBlocker(v4->memoryManager); - IR::Module module(v4->debugger() != 0); QQmlJS::Engine ee, *engine = ⅇ diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 606d3ec162..8732b02685 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -565,16 +565,6 @@ void MemoryManager::sweep(bool lastSweep) } } -bool MemoryManager::isGCBlocked() const -{ - return m_d->gcBlocked; -} - -void MemoryManager::setGCBlocked(bool blockGC) -{ - m_d->gcBlocked = blockGC; -} - void MemoryManager::runGC() { if (m_d->gcBlocked) { diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index dfa0d85dff..86a0ba2735 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -76,26 +76,6 @@ class Q_QML_EXPORT MemoryManager public: struct Data; - class GCBlocker - { - public: - GCBlocker(MemoryManager *mm) - : mm(mm) - , wasBlocked(mm->isGCBlocked()) - { - mm->setGCBlocked(true); - } - - ~GCBlocker() - { - mm->setGCBlocked(wasBlocked); - } - - private: - MemoryManager *mm; - bool wasBlocked; - }; - public: MemoryManager(ExecutionEngine *engine); ~MemoryManager(); @@ -309,8 +289,6 @@ public: return t->d(); } - bool isGCBlocked() const; - void setGCBlocked(bool blockGC); void runGC(); void dumpStats() const; diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index d5b2067094..4fbd828307 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -199,7 +199,10 @@ void QQmlBoundSignalExpression::evaluate(void **a) // for several cases (such as QVariant type and QObject-derived types) //args[ii] = engine->metaTypeToJS(type, a[ii + 1]); if (type == qMetaTypeId<QJSValue>()) { - callData->args[ii] = *QJSValuePrivate::getValue(reinterpret_cast<QJSValue *>(a[ii + 1])); + if (QV4::Value *v4Value = QJSValuePrivate::getValue(reinterpret_cast<QJSValue *>(a[ii + 1]))) + callData->args[ii] = *v4Value; + else + callData->args[ii] = QV4::Encode::undefined(); } else if (type == QMetaType::QVariant) { callData->args[ii] = scope.engine->fromVariant(*((QVariant *)a[ii + 1])); } else if (type == QMetaType::Int) { diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 936313768a..50ed58e63d 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -47,8 +47,6 @@ #include "qqml.h" #include "qqmlengine.h" #include "qqmlbinding_p.h" -#include <private/qqmldebugconnector_p.h> -#include <private/qqmldebugserviceinterfaces_p.h> #include "qqmlincubator.h" #include "qqmlincubator_p.h" #include <private/qqmljavascriptexpression_p.h> @@ -876,15 +874,6 @@ QQmlComponentPrivate::beginCreate(QQmlContextData *context) depthIncreased = false; } - if (rv) { - if (QQmlEngineDebugService *service = - QQmlDebugConnector::service<QQmlEngineDebugService>()) { - if (!context->isInternal) - context->asQQmlContextPrivate()->instances.append(rv); - service->objectCreated(engine, rv); - } - } - return rv; } diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp index ca19691e93..097fa71200 100644 --- a/src/qml/qml/qqmlextensionplugin.cpp +++ b/src/qml/qml/qqmlextensionplugin.cpp @@ -117,4 +117,14 @@ void QQmlExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) Q_UNUSED(uri); } +/*! + \class QQmlExtensionInterface + \internal + \inmodule QtQml + + \class QQmlTypesExtensionInterface + \internal + \inmodule QtQml +*/ + QT_END_NAMESPACE diff --git a/src/qml/qml/qqmllist.cpp b/src/qml/qml/qqmllist.cpp index a719956483..edd93ef03d 100644 --- a/src/qml/qml/qqmllist.cpp +++ b/src/qml/qml/qqmllist.cpp @@ -335,7 +335,7 @@ int QQmlListReference::count() const \since 5.0 \inmodule QtQml \brief The QQmlListProperty class allows applications to expose list-like -properties to QML. +properties of QObject-derived classes to QML. QML has many list properties, where more than one object value can be assigned. The use of a list property from QML looks like this: @@ -369,7 +369,8 @@ QML list properties are type-safe - in this case \c {Fruit} is a QObject type th The \l {Qt Quick 1} version of this class is named QDeclarativeListProperty. -\note QQmlListProperty can only be used for lists of QObject-derived object pointers. +\sa {Extending QML - Object and List Property Types Example} + */ /*! diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 2e2a3fb303..09936f6e7a 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -53,6 +53,8 @@ #include <private/qqmlscriptstring_p.h> #include <private/qqmlpropertyvalueinterceptor_p.h> #include <private/qqmlvaluetypeproxybinding_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qqmldebugserviceinterfaces_p.h> QT_USE_NAMESPACE @@ -216,6 +218,17 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI phase = ObjectsCreated; + if (instance) { + if (QQmlEngineDebugService *service + = QQmlDebugConnector::service<QQmlEngineDebugService>()) { + if (!parentContext->isInternal) + parentContext->asQQmlContextPrivate()->instances.append(instance); + service->objectCreated(engine, instance); + } else if (!parentContext->isInternal && QQmlDebugConnector::service<QV4DebugService>()) { + parentContext->asQQmlContextPrivate()->instances.append(instance); + } + } + return instance; } diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index d376816ef9..b772ed97d2 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -766,7 +766,6 @@ QSGNode *QQuickCanvasItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData if (!texture) { delete node; d->node = 0; - delete d->nodeTexture; d->nodeTexture = 0; if (d->textureProvider) { d->textureProvider->tex = 0; diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 2fad9f5a8d..b6c45c40a8 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -137,6 +137,7 @@ Item { \li Qt.AltModifier - An Alt key on the keyboard is pressed. \li Qt.MetaModifier - A Meta key on the keyboard is pressed. \li Qt.KeypadModifier - A keypad button is pressed. + \li Qt.GroupSwitchModifier - X11 only. A Mode_switch key on the keyboard is pressed. \endlist For example, to react to a Shift key + Enter key combination: diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 79c957832a..2f66bbebf2 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -341,7 +341,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i position of the release of the click, and whether the click was held. When handling this signal, changing the \l {MouseEvent::}{accepted} property of the \a mouse - parameter has no effect. + parameter has no effect, unless the \l propagateComposedEvents property is \c true. The corresponding handler is \c onClicked. */ @@ -385,7 +385,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i position of the press, and which button is pressed. When handling this signal, changing the \l {MouseEvent::}{accepted} property of the \a mouse - parameter has no effect. + parameter has no effect, unless the \l propagateComposedEvents property is \c true. The corresponding handler is \c onPressAndHold. */ diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 8532786a8d..075fd48a46 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -1729,7 +1729,9 @@ void QQuickTextEdit::select(int start, int end) // QTBUG-11100 updateSelection(); +#if QT_CONFIG(im) updateInputMethod(); +#endif } /*! diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 07d87989b5..660c5f8067 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2083,11 +2083,12 @@ void QQuickWindowPrivate::flushFrameSynchronousEvents() ut->startAnimations(); } - // Once per frame, send a synthetic hover, in case items have changed position. + // Once per frame, if any items are dirty, send a synthetic hover, + // in case items have changed position, visibility, etc. // For instance, during animation (including the case of a ListView // whose delegates contain MouseAreas), a MouseArea needs to know // whether it has moved into a position where it is now under the cursor. - if (!q->mouseGrabberItem() && !lastMousePosition.isNull()) { + if (!q->mouseGrabberItem() && !lastMousePosition.isNull() && dirtyItemList) { bool accepted = false; bool delivered = deliverHoverEvent(contentItem, lastMousePosition, lastMousePosition, QGuiApplication::keyboardModifiers(), 0, accepted); if (!delivered) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 6db96f369c..d4324bc489 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -979,6 +979,10 @@ void Renderer::nodeChangedBatchRoot(Node *node, Node *root) e->root = root; e->boundsComputed = false; } + } else if (node->type() == QSGNode::RenderNodeType) { + RenderNodeElement *e = node->renderNodeElement(); + if (e) + e->root = root; } SHADOWNODE_TRAVERSE(node) @@ -2022,6 +2026,8 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip) } ClipType clipType = NoClip; + GLuint vbo = 0; + int vboSize = 0; glDisable(GL_SCISSOR_TEST); @@ -2106,7 +2112,21 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip) const QSGGeometry *g = clip->geometry(); Q_ASSERT(g->attributeCount() > 0); const QSGGeometry::Attribute *a = g->attributes(); - glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), g->vertexData()); + + if (!vbo) + glGenBuffers(1, &vbo); + + glBindBuffer(GL_ARRAY_BUFFER, vbo); + + const int vertexByteSize = g->sizeOfVertex() * g->vertexCount(); + if (vboSize < vertexByteSize) { + vboSize = vertexByteSize; + glBufferData(GL_ARRAY_BUFFER, vertexByteSize, g->vertexData(), GL_STATIC_DRAW); + } else { + glBufferSubData(GL_ARRAY_BUFFER, 0, vertexByteSize, g->vertexData()); + } + + glVertexAttribPointer(0, a->tupleSize, a->type, GL_FALSE, g->sizeOfVertex(), 0); m_clipProgram.setUniformValue(m_clipMatrixId, m); if (g->indexCount()) { @@ -2115,12 +2135,17 @@ Renderer::ClipType Renderer::updateStencilClip(const QSGClipNode *clip) glDrawArrays(g->drawingMode(), 0, g->vertexCount()); } + glBindBuffer(GL_ARRAY_BUFFER, 0); + ++m_currentStencilValue; } clip = clip->clipList(); } + if (vbo) + glDeleteBuffers(1, &vbo); + if (clipType & StencilClip) { m_clipProgram.disableAttributeArray(0); glStencilFunc(GL_EQUAL, m_currentStencilValue, 0xff); // stencil test, ref, test mask @@ -2778,8 +2803,13 @@ void Renderer::renderRenderNode(Batch *batch) updateClip(rd->m_clip_list, batch); - RenderNodeState state; QMatrix4x4 pm = projectionMatrix(); + if (m_useDepthBuffer) { + pm(2, 2) = m_zRange; + pm(2, 3) = 1.0f - e->order * m_zRange; + } + + RenderNodeState state; state.m_projectionMatrix = ± state.m_scissorEnabled = m_currentClipType & ScissorClip; state.m_stencilEnabled = m_currentClipType & StencilClip; diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp index 5915d51f2b..1bc0210b72 100644 --- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp +++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp @@ -160,10 +160,7 @@ QSGRenderNode::StateFlags QSGRenderNode::changedStates() const \list \li glDepthMask(false) \li glDisable(GL_DEPTH_TEST) - \li glStencilMask(0) - \li glEnable(GL_STENCIL_TEST)/glDisable(GL_STENCIL_TEST) depending on clip \li glStencilFunc(GL_EQUAL, state.stencilValue, 0xff) depending on clip - \li glEnable(GL_SCISSOR_TEST)/glDisable(GL_SCISSOR_TEST) depending on clip \li glScissor(state.scissorRect.x(), state.scissorRect.y(), state.scissorRect.width(), state.scissorRect.height()) depending on clip \li glEnable(GL_BLEND) diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp index 5d2af0f940..c3b5865369 100644 --- a/src/quick/util/qquickanimator.cpp +++ b/src/quick/util/qquickanimator.cpp @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE \inqmlmodule QtQuick \since 5.2 \ingroup qtquick-transitions-animations + \inherits Animation \brief Is the base of all QML animators. Animator types are a special type of animation which operate |