From 5cfcb54cc6a94b5be50d751c659f0b55e090d35b Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Mon, 18 May 2015 12:50:13 +0200 Subject: Doc: Added the missing examples \group page for Qt QML The QHP meta info. was trying to link to the Qt Quick page, which failed. This should fix the issue. Task-number: QTBUG-46163 Change-Id: Ib012f8f73b74a51b7a8d4e849070742e94d40973 Reviewed-by: Venugopal Shivashankar --- src/qml/doc/qtqml.qdocconf | 2 +- src/qml/doc/src/examples.qdoc | 35 +++++++++++++++++++++++++++++++++++ src/qml/doc/src/qtqml.qdoc | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/qml/doc/src/examples.qdoc (limited to 'src') diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index 5729a60ea3..f95764f471 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -23,7 +23,7 @@ qhp.QtQml.subprojects.classes.indexTitle = Qt QML C++ Classes qhp.QtQml.subprojects.classes.selectors = class fake:headerfile qhp.QtQml.subprojects.classes.sortPages = true qhp.QtQml.subprojects.examples.title = Examples -qhp.QtQml.subprojects.examples.indexTitle = Qt Quick Examples and Tutorials +qhp.QtQml.subprojects.examples.indexTitle = Qt QML Examples qhp.QtQml.subprojects.examples.selectors = fake:example qhp.QtQml.subprojects.qmltypes.title = QML Types qhp.QtQml.subprojects.qmltypes.indexTitle = Qt QML QML Types diff --git a/src/qml/doc/src/examples.qdoc b/src/qml/doc/src/examples.qdoc new file mode 100644 index 0000000000..29424053a4 --- /dev/null +++ b/src/qml/doc/src/examples.qdoc @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\group qmlextendingexamples +\title Qt QML Examples +\brief List of Qt QML examples for reference. + +The list of examples demonstrating how to extend C++ to QML or the other way +around. +*/ diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc index ae2cac7275..7350f65024 100644 --- a/src/qml/doc/src/qtqml.qdoc +++ b/src/qml/doc/src/qtqml.qdoc @@ -148,6 +148,7 @@ Further information for writing QML applications: \list \li \l{Qt QML C++ Classes}{C++ Classes} \li \l{Qt QML QML Types}{QML Types} +\li \l{Qt QML Examples}{Examples} \endlist */ -- cgit v1.2.3 From 72c042fa3e23fa1aa4579df801e3cd4411d80bbd Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Fri, 15 May 2015 15:35:24 +0200 Subject: Doc: Added the missing \brief and \image to the example docs Task-number: QTBUG-41996 Change-Id: Ica6e069c7753a2004a4a4c0e93a49d1f240569d3 Reviewed-by: Martin Smith --- src/qml/doc/qtqml.qdocconf | 3 ++- src/quick/doc/qtquick.qdocconf | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index f95764f471..74b61fd6e1 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -50,7 +50,8 @@ imagedirs += images # Add a thumbnail for examples that do not have images manifestmeta.thumbnail.names += "QtQml/Chapter 4*" \ - "QtQml/Chapter 6*" + "QtQml/Chapter 6*" \ + "QtQml/C++ Extensions: *" navigation.landingpage = "Qt QML" navigation.cppclassespage = "Qt QML C++ Classes" diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf index afe1b9708f..7f43dc2c31 100644 --- a/src/quick/doc/qtquick.qdocconf +++ b/src/quick/doc/qtquick.qdocconf @@ -67,7 +67,8 @@ excludedirs += ../../imports/models \ examples.fileextensions += "*.qm" -manifestmeta.thumbnail.names += "QtQuick/Threaded ListModel Example" +manifestmeta.thumbnail.names += "QtQuick/Threaded ListModel Example" \ + "QtQuick/QML Dynamic View Ordering Tutorial*" navigation.landingpage = "Qt Quick" navigation.cppclassespage = "Qt Quick C++ Classes" -- cgit v1.2.3 From 2556b97ab22cfde606d2b77d6e816fd282741291 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 21 May 2015 13:10:36 +0200 Subject: Doc: Document limits of QSGGeometry::setLineWidth Task-number: QTBUG-46260 Change-Id: Ib84a41da10d38391c3248a209a851f5b603d46b0 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/coreapi/qsggeometry.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp index 7be926ad81..7e43541ef7 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.cpp +++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp @@ -522,7 +522,8 @@ void QSGGeometry::setDrawingMode(GLenum mode) /*! Gets the current line or point width or to be used for this geometry. This property only applies to line width when the drawingMode is \c GL_LINES, \c GL_LINE_STRIP, or - \c GL_LINE_LOOP, and only applies to point size when the drawingMode is \c GL_POINTS. + \c GL_LINE_LOOP. For desktop OpenGL, it also applies to point size when the drawingMode + is \c GL_POINTS. The default value is \c 1.0 @@ -536,7 +537,12 @@ float QSGGeometry::lineWidth() const /*! Sets the line or point width to be used for this geometry to \a width. This property only applies to line width when the drawingMode is \c GL_LINES, \c GL_LINE_STRIP, or - \c GL_LINE_LOOP, and only applies to point size when the drawingMode is \c GL_POINTS. + \c GL_LINE_LOOP. For Desktop OpenGL, it also applies to point size when the drawingMode + is \c GL_POINTS. + + \note How line width and point size are treated is implementation dependent: The application + should not rely on these, but rather create triangles or similar to draw areas. On OpenGL ES, + line width support is limited and point size is unsupported. \sa lineWidth(), drawingMode() */ -- cgit v1.2.3 From 8b205fd05dcdc4a0e7ec6b25429f691a0a9099fe Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 27 May 2015 10:52:59 +0200 Subject: Improve support for HTML entities in StyledText This adds support for the non-breaking space character ( ) and properly handling entities that do not end with a semicolon, such as a stray ampersand in a text. Change-Id: I2f157c9aa651b27511809d5a47ac07660949a290 Task-number: QTBUG-44869 Task-number: QTBUG-31816 Task-number: QTBUG-33368 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/util/qquickstyledtext.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp index 5efe65ef44..6ed32c10e2 100644 --- a/src/quick/util/qquickstyledtext.cpp +++ b/src/quick/util/qquickstyledtext.cpp @@ -542,6 +542,12 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI textOut += QChar(38); else if (entity == QLatin1String("quot")) textOut += QChar(34); + else if (entity == QLatin1String("nbsp")) + textOut += QChar(QChar::Nbsp); + return; + } else if (*ch == QLatin1Char(' ')) { + QStringRef entity(&textIn, entityStart - 1, entityLength + 1); + textOut += entity + *ch; return; } ++entityLength; -- cgit v1.2.3 From eeee9f1466ffaf17f81d635c2e43dca76ce5b021 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Fri, 3 Jul 2015 10:55:35 +0200 Subject: QSGSimpleTextureNode: Fix ownership of QSGTexture Make sure the QSGSimpleTextureNode deletes the old QSGTexture if a new one is set via setTexture() and the ownsTexture flag is true. [ChangeLog][QtQuick][SceneGraph] QSGSimpleTextureNode will now delete the currently set QSGTexture object, if a new QSGTexture is set and the ownsTexture flag is on. Change-Id: Iabfbccd390e16948d4575baf29e6c8b4a184a404 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/util/qsgsimpletexturenode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp index 8d38e83029..d9f3c44374 100644 --- a/src/quick/scenegraph/util/qsgsimpletexturenode.cpp +++ b/src/quick/scenegraph/util/qsgsimpletexturenode.cpp @@ -223,9 +223,11 @@ QRectF QSGSimpleTextureNode::sourceRect() const void QSGSimpleTextureNode::setTexture(QSGTexture *texture) { Q_ASSERT(texture); + Q_D(QSGSimpleTextureNode); + if (d->ownsTexture) + delete m_material.texture(); m_material.setTexture(texture); m_opaque_material.setTexture(texture); - Q_D(QSGSimpleTextureNode); qsgsimpletexturenode_update(&m_geometry, texture, m_rect, d->sourceRect, d->texCoordMode); DirtyState dirty = DirtyMaterial; -- cgit v1.2.3 From 982fa2225b7d69181344a00816cad19042a922e6 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 2 Jul 2015 15:54:43 +0200 Subject: Delete QQuickWindow's animator driver at the right time. For the non-threaded renderloops, we there might be a timer firing before the animationController is cleaned up through deleteLater() which will then reference the deleted QQuickWindow. Rely instead on direct and explicit cleanup at the right time in each render loop. Change-Id: Id81daddae78ce3922d6a932fb21200f2dc7955bb Task-number: QTBUG-33723 Reviewed-by: Liang Qi Reviewed-by: Robin Burchell --- src/quick/items/qquickwindow.cpp | 1 - src/quick/scenegraph/qsgrenderloop.cpp | 3 +++ src/quick/scenegraph/qsgthreadedrenderloop.cpp | 5 ++++- src/quick/scenegraph/qsgwindowsrenderloop.cpp | 6 ++++-- 4 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 84b585e3b5..4238787cc8 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1112,7 +1112,6 @@ QQuickWindow::~QQuickWindow() { Q_D(QQuickWindow); - d->animationController->deleteLater(); if (d->renderControl) { QQuickRenderControlPrivate::get(d->renderControl)->windowDestroyed(); } else if (d->windowManager) { diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index ec9c3c39f9..4d3f34c71c 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -34,6 +34,7 @@ #include "qsgrenderloop_p.h" #include "qsgthreadedrenderloop_p.h" #include "qsgwindowsrenderloop_p.h" +#include #include #include @@ -305,6 +306,8 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) } else if (gl && window == gl->surface() && current) { gl->doneCurrent(); } + + delete d->animationController; } void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 56637387df..2cebbaf484 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -451,11 +451,12 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor, qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- cleanup without an OpenGL context"; } + QQuickWindowPrivate *dd = QQuickWindowPrivate::get(window); + QQuickShaderEffectMaterial::cleanupMaterialCache(); // The canvas nodes must be cleaned up regardless if we are in the destructor.. if (wipeSG) { - QQuickWindowPrivate *dd = QQuickWindowPrivate::get(window); dd->cleanupNodesOnShutdown(); } else { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- persistent SG, avoiding cleanup"; @@ -467,6 +468,8 @@ void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor, sgrc->invalidate(); QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + if (inDestructor) + delete dd->animationController; if (current) gl->doneCurrent(); qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- invalidating scene graph"; diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index c571e60018..7fd9651618 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -32,7 +32,6 @@ ****************************************************************************/ #include "qsgwindowsrenderloop_p.h" - #include #include #include @@ -47,8 +46,8 @@ #include #include - #include +#include QT_BEGIN_NAMESPACE @@ -219,6 +218,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window) hide(window); QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); + bool current = false; QScopedPointer offscreenSurface; if (m_gl) { @@ -245,6 +245,8 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window) } else if (m_gl && current) { m_gl->doneCurrent(); } + + delete d->animationController; } bool QSGWindowsRenderLoop::anyoneShowing() const -- cgit v1.2.3 From c802a8582258ca9ad1cc800a9c8e6e46b2ff6f0e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 27 Mar 2015 22:12:56 -0700 Subject: Fix ICC warning about change of sign qv4typedarray.cpp(87): error #68: integer conversion resulted in a change of sign Change-Id: Iee8cbc07c4434ce9b560ffff13cf917dd8f9012e Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4typedarray.cpp | 2 +- src/quick/util/qquickprofiler_p.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 429ec96f0b..c355207d94 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -84,7 +84,7 @@ void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, const Val return; } if (d >= 255) { - data[index] = (unsigned char)(255); + data[index] = (char)(255); return; } double f = std::floor(d); diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h index 85a03fb57b..aaed4bd60e 100644 --- a/src/quick/util/qquickprofiler_p.h +++ b/src/quick/util/qquickprofiler_p.h @@ -259,7 +259,7 @@ public: } template - static void reportSceneGraphFrame(quint64 payload = -1) + static void reportSceneGraphFrame(quint64 payload = ~0) { qint64 *timings = s_instance->m_sceneGraphData.timings(); int &offset = s_instance->m_sceneGraphData.offset(); @@ -275,7 +275,7 @@ public: } template - static void reportSceneGraphFrame(quint64 payload = -1) + static void reportSceneGraphFrame(quint64 payload = ~0) { reportSceneGraphFrame(payload); s_instance->m_sceneGraphData.offset() = 0; -- cgit v1.2.3 From b69449b0a148d1546205cd8ca36ba87f88b449e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 14 May 2015 06:20:57 +0900 Subject: Fix more casts that dropped the constness. Found with GCC's -Wcast-qual Change-Id: I66a35ce5f88941f29aa6ffff13dde502fccefb1d Reviewed-by: Simon Hausmann --- src/quick/util/qquickanimatorjob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 8b617e5e3f..2a8e3c281c 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -136,7 +136,7 @@ void QQuickAnimatorProxyJob::updateState(QAbstractAnimationJob::State newState, void QQuickAnimatorProxyJob::debugAnimation(QDebug d) const { - d << "QuickAnimatorProxyJob("<< hex << (void *) this << dec + d << "QuickAnimatorProxyJob("<< hex << (const void *) this << dec << "state:" << state() << "duration:" << duration() << "proxying: (" << job() << ')'; } @@ -225,7 +225,7 @@ QQuickAnimatorJob::QQuickAnimatorJob() void QQuickAnimatorJob::debugAnimation(QDebug d) const { - d << "QuickAnimatorJob(" << hex << (void *) this << dec + d << "QuickAnimatorJob(" << hex << (const void *) this << dec << ") state:" << state() << "duration:" << duration() << "target:" << m_target << "value:" << m_value; } -- cgit v1.2.3 From f558bc48585c69de36151248c969a484a969ebb4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 7 Jul 2015 14:13:22 +0300 Subject: Fix encoding of QV4::Value in host builds When building on a 64-bit host targeting a 32-bit architecture, we would use QT_POINTER_SIZE == 4 from qconfig.h, which is unfortunately shared. However on 64-bit hosts the 32-bit encoding appears to result in gcc/clang to miscompile simple QV4::Value uses - when optimizations are enabled. As a workaround, let's use 64-bit encoding in all host scenarios. Change-Id: I000cf13abcc9240c931191d6361b6dee578cb5d4 Task-number: QTBUG-45364 Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4value_inl_p.h | 4 ++-- src/qml/jsruntime/qv4value_p.h | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4value_inl_p.h b/src/qml/jsruntime/qv4value_inl_p.h index 3a4c5c4822..f3026900d6 100644 --- a/src/qml/jsruntime/qv4value_inl_p.h +++ b/src/qml/jsruntime/qv4value_inl_p.h @@ -82,7 +82,7 @@ inline void Value::mark(ExecutionEngine *e) const inline Primitive Primitive::nullValue() { Primitive v; -#if QT_POINTER_SIZE == 8 +#ifdef QV4_USE_64_BIT_VALUE_ENCODING v.val = quint64(_Null_Type) << Tag_Shift; #else v.tag = _Null_Type; @@ -181,7 +181,7 @@ inline bool Value::toBoolean() const #ifndef V4_BOOTSTRAP inline uint Value::asArrayIndex() const { -#if QT_POINTER_SIZE == 8 +#ifdef QV4_USE_64_BIT_VALUE_ENCODING if (!isNumber()) return UINT_MAX; if (isInteger()) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index cd1aef86d7..628950784a 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -38,6 +38,14 @@ #include #include "qv4global_p.h" +/* We cannot rely on QT_POINTER_SIZE to be set correctly on host builds. In qmldevtools the Value objects + are only used to store primitives, never object pointers. So we can use the 64-bit encoding. */ +#ifdef V4_BOOTSTRAP +#define QV4_USE_64_BIT_VALUE_ENCODING +#elif QT_POINTER_SIZE == 8 +#define QV4_USE_64_BIT_VALUE_ENCODING +#endif + QT_BEGIN_NAMESPACE namespace QV4 { @@ -119,7 +127,7 @@ struct Q_QML_PRIVATE_EXPORT Value union { quint64 val; -#if QT_POINTER_SIZE == 8 +#ifdef QV4_USE_64_BIT_VALUE_ENCODING Heap::Base *m; #else double dbl; @@ -131,7 +139,7 @@ struct Q_QML_PRIVATE_EXPORT Value union { uint uint_32; int int_32; -#if QT_POINTER_SIZE == 4 +#ifndef QV4_USE_64_BIT_VALUE_ENCODING Heap::Base *m; #endif }; @@ -141,7 +149,7 @@ struct Q_QML_PRIVATE_EXPORT Value }; }; -#if QT_POINTER_SIZE == 4 +#ifndef QV4_USE_64_BIT_VALUE_ENCODING enum Masks { SilentNaNBit = 0x00040000, NaN_Mask = 0x7ff80000, @@ -221,7 +229,7 @@ struct Q_QML_PRIVATE_EXPORT Value inline bool isUndefined() const { return tag == Undefined_Type; } inline bool isNull() const { return tag == _Null_Type; } inline bool isBoolean() const { return tag == _Boolean_Type; } -#if QT_POINTER_SIZE == 8 +#ifdef QV4_USE_64_BIT_VALUE_ENCODING inline bool isInteger() const { return (val >> IsNumber_Shift) == 1; } inline bool isDouble() const { return (val >> IsDouble_Shift); } inline bool isNumber() const { return (val >> IsNumber_Shift); } @@ -320,7 +328,7 @@ struct Q_QML_PRIVATE_EXPORT Value { Value v; v.m = m; -#if QT_POINTER_SIZE == 4 +#ifndef QV4_USE_64_BIT_VALUE_ENCODING v.tag = Managed_Type; #endif return v; @@ -386,7 +394,7 @@ struct Q_QML_PRIVATE_EXPORT Value } Value &operator=(Heap::Base *o) { m = o; -#if QT_POINTER_SIZE == 4 +#ifndef QV4_USE_64_BIT_VALUE_ENCODING tag = Managed_Type; #endif return *this; @@ -428,7 +436,7 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value inline Primitive Primitive::undefinedValue() { Primitive v; -#if QT_POINTER_SIZE == 8 +#ifdef QV4_USE_64_BIT_VALUE_ENCODING v.val = quint64(Undefined_Type) << Tag_Shift; #else v.tag = Undefined_Type; @@ -451,7 +459,7 @@ struct TypedValue : public Value template TypedValue &operator =(X *x) { m = x; -#if QT_POINTER_SIZE == 4 +#ifndef QV4_USE_64_BIT_VALUE_ENCODING tag = Managed_Type; #endif return *this; -- cgit v1.2.3 From f35be0bc5afe940bb95695a319176e45fec1f594 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 7 Mar 2015 14:35:47 -0800 Subject: QtQml: Fix const correctness in old style casts Found with GCC's -Wcast-qual. Change-Id: Ia0aac2f09e9245339951ffff13c958364a2e9859 Reviewed-by: Simon Hausmann --- src/qml/animations/qabstractanimationjob.cpp | 2 +- src/qml/animations/qcontinuinganimationgroupjob.cpp | 2 +- src/qml/animations/qparallelanimationgroupjob.cpp | 2 +- src/qml/animations/qpauseanimationjob.cpp | 2 +- src/qml/animations/qsequentialanimationgroupjob.cpp | 2 +- src/qml/jsruntime/qv4engine.cpp | 4 ++-- src/qml/jsruntime/qv4serialize.cpp | 10 +++++----- src/qml/jsruntime/qv4typedarray.cpp | 12 ++++++------ src/qml/jsruntime/qv4vme_moth.cpp | 8 ++++---- src/qml/qml/ftw/qbitfield_p.h | 11 ++++++----- src/qml/qml/ftw/qhashedstring_p.h | 4 ++-- src/qml/qml/qqmlcontext.cpp | 2 +- src/qml/qml/qqmlengine.cpp | 2 +- src/qml/qml/qqmlmetatype.cpp | 2 +- src/qml/qml/qqmlproperty.cpp | 10 +++++----- src/qml/qml/qqmlpropertycache.cpp | 2 +- src/qml/qml/qqmlvaluetype.cpp | 2 +- src/qml/qml/qqmlvmemetaobject.cpp | 4 ++-- src/qml/qml/qqmlvmemetaobject_p.h | 2 +- src/qml/util/qqmllistaccessor.cpp | 4 ++-- 20 files changed, 45 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index 7fcf383bcb..d301c43822 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -652,7 +652,7 @@ void QAbstractAnimationJob::removeAnimationChangeListener(QAnimationJobChangeLis void QAbstractAnimationJob::debugAnimation(QDebug d) const { - d << "AbstractAnimationJob(" << hex << (void *) this << dec << ") state:" + d << "AbstractAnimationJob(" << hex << (const void *) this << dec << ") state:" << m_state << "duration:" << duration(); } diff --git a/src/qml/animations/qcontinuinganimationgroupjob.cpp b/src/qml/animations/qcontinuinganimationgroupjob.cpp index c77448f153..88005baf12 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob.cpp +++ b/src/qml/animations/qcontinuinganimationgroupjob.cpp @@ -115,7 +115,7 @@ void QContinuingAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimat void QContinuingAnimationGroupJob::debugAnimation(QDebug d) const { - d << "ContinuingAnimationGroupJob(" << hex << (void *) this << dec << ")"; + d << "ContinuingAnimationGroupJob(" << hex << (const void *) this << dec << ")"; debugChildren(d); } diff --git a/src/qml/animations/qparallelanimationgroupjob.cpp b/src/qml/animations/qparallelanimationgroupjob.cpp index 0153794d6f..fe56f2b1e8 100644 --- a/src/qml/animations/qparallelanimationgroupjob.cpp +++ b/src/qml/animations/qparallelanimationgroupjob.cpp @@ -233,7 +233,7 @@ void QParallelAnimationGroupJob::uncontrolledAnimationFinished(QAbstractAnimatio void QParallelAnimationGroupJob::debugAnimation(QDebug d) const { - d << "ParallelAnimationGroupJob(" << hex << (void *) this << dec << ")"; + d << "ParallelAnimationGroupJob(" << hex << (const void *) this << dec << ")"; debugChildren(d); } diff --git a/src/qml/animations/qpauseanimationjob.cpp b/src/qml/animations/qpauseanimationjob.cpp index 8e35c58999..0e95645f41 100644 --- a/src/qml/animations/qpauseanimationjob.cpp +++ b/src/qml/animations/qpauseanimationjob.cpp @@ -62,7 +62,7 @@ void QPauseAnimationJob::updateCurrentTime(int) void QPauseAnimationJob::debugAnimation(QDebug d) const { - d << "PauseAnimationJob(" << hex << (void *) this << dec << ")" << "duration:" << m_duration; + d << "PauseAnimationJob(" << hex << (const void *) this << dec << ")" << "duration:" << m_duration; } QT_END_NAMESPACE diff --git a/src/qml/animations/qsequentialanimationgroupjob.cpp b/src/qml/animations/qsequentialanimationgroupjob.cpp index 5060b7f6cd..b92caf3bc4 100644 --- a/src/qml/animations/qsequentialanimationgroupjob.cpp +++ b/src/qml/animations/qsequentialanimationgroupjob.cpp @@ -411,7 +411,7 @@ void QSequentialAnimationGroupJob::animationRemoved(QAbstractAnimationJob *anim, void QSequentialAnimationGroupJob::debugAnimation(QDebug d) const { - d << "SequentialAnimationGroupJob(" << hex << (void *) this << dec << ")" << "currentAnimation:" << (void *)m_currentAnimation; + d << "SequentialAnimationGroupJob(" << hex << (const void *) this << dec << ")" << "currentAnimation:" << (void *)m_currentAnimation; debugChildren(d); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index ba6f5a3b79..2dbdcfc526 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1447,7 +1447,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant) QV4::Scope scope(this); if (type == qMetaTypeId()) { typedef QQmlListReferencePrivate QDLRP; - QDLRP *p = QDLRP::get((QQmlListReference*)ptr); + QDLRP *p = QDLRP::get((QQmlListReference*)const_cast(ptr)); if (p->object) { return QV4::QmlListWrapper::create(scope.engine, p->property, p->propertyType); } else { @@ -1459,7 +1459,7 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant) } else if (type == qMetaTypeId >()) { // XXX Can this be made more by using Array as a prototype and implementing // directly against QList? - const QList &list = *(QList*)ptr; + const QList &list = *(const QList*)ptr; QV4::ScopedArrayObject a(scope, newArrayObject()); a->arrayReserve(list.count()); QV4::ScopedValue v(scope); diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index e669924d4a..31d85df13e 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -116,21 +116,21 @@ static inline void reserve(QByteArray &data, int extra) static inline quint32 popUint32(const char *&data) { - quint32 rv = *((quint32 *)data); + quint32 rv = *((const quint32 *)data); data += sizeof(quint32); return rv; } static inline double popDouble(const char *&data) { - double rv = *((double *)data); + double rv = *((const double *)data); data += sizeof(double); return rv; } static inline void *popPtr(const char *&data) { - void *rv = *((void **)data); + void *rv = *((void *const *)data); data += sizeof(void *); return rv; } @@ -297,7 +297,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine) case WorkerString: { quint32 size = headersize(header); - QString qstr((QChar *)data, size); + QString qstr((const QChar *)data, size); data += ALIGN(size * sizeof(quint16)); return QV4::Encode(engine->newString(qstr)); } @@ -342,7 +342,7 @@ ReturnedValue Serialize::deserialize(const char *&data, ExecutionEngine *engine) { quint32 flags = headersize(header); quint32 length = popUint32(data); - QString pattern = QString((QChar *)data, length - 1); + QString pattern = QString((const QChar *)data, length - 1); data += ALIGN(length * sizeof(quint16)); return Encode(engine->newRegExpObject(pattern, flags)); } diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index c355207d94..19e541dba8 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -106,7 +106,7 @@ void UInt8ClampedArrayWrite(ExecutionEngine *e, char *data, int index, const Val ReturnedValue Int16ArrayRead(const char *data, int index) { - return Encode((int)*(short *)(data + index)); + return Encode((int)*(const short *)(data + index)); } void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) @@ -119,7 +119,7 @@ void Int16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &val ReturnedValue UInt16ArrayRead(const char *data, int index) { - return Encode((int)*(unsigned short *)(data + index)); + return Encode((int)*(const unsigned short *)(data + index)); } void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) @@ -132,7 +132,7 @@ void UInt16ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &va ReturnedValue Int32ArrayRead(const char *data, int index) { - return Encode(*(int *)(data + index)); + return Encode(*(const int *)(data + index)); } void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) @@ -145,7 +145,7 @@ void Int32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &val ReturnedValue UInt32ArrayRead(const char *data, int index) { - return Encode(*(unsigned int *)(data + index)); + return Encode(*(const unsigned int *)(data + index)); } void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) @@ -158,7 +158,7 @@ void UInt32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &va ReturnedValue Float32ArrayRead(const char *data, int index) { - return Encode(*(float *)(data + index)); + return Encode(*(const float *)(data + index)); } void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) @@ -171,7 +171,7 @@ void Float32ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &v ReturnedValue Float64ArrayRead(const char *data, int index) { - return Encode(*(double *)(data + index)); + return Encode(*(const double *)(data + index)); } void Float64ArrayWrite(ExecutionEngine *e, char *data, int index, const Value &value) diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index dda5848f0b..390bbf5ee3 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -593,7 +593,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallGlobalLookup) MOTH_BEGIN_INSTR(SetExceptionHandler) - exceptionHandler = instr.offset ? ((uchar *)&instr.offset) + instr.offset : 0; + exceptionHandler = instr.offset ? ((const uchar *)&instr.offset) + instr.offset : 0; MOTH_END_INSTR(SetExceptionHandler) MOTH_BEGIN_INSTR(CallBuiltinThrow) @@ -727,21 +727,21 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(ConstructGlobalLookup) MOTH_BEGIN_INSTR(Jump) - code = ((uchar *)&instr.offset) + instr.offset; + code = ((const uchar *)&instr.offset) + instr.offset; MOTH_END_INSTR(Jump) MOTH_BEGIN_INSTR(JumpEq) bool cond = VALUEPTR(instr.condition)->toBoolean(); TRACE(condition, "%s", cond ? "TRUE" : "FALSE"); if (cond) - code = ((uchar *)&instr.offset) + instr.offset; + code = ((const uchar *)&instr.offset) + instr.offset; MOTH_END_INSTR(JumpEq) MOTH_BEGIN_INSTR(JumpNe) bool cond = VALUEPTR(instr.condition)->toBoolean(); TRACE(condition, "%s", cond ? "TRUE" : "FALSE"); if (!cond) - code = ((uchar *)&instr.offset) + instr.offset; + code = ((const uchar *)&instr.offset) + instr.offset; MOTH_END_INSTR(JumpNe) MOTH_BEGIN_INSTR(UNot) diff --git a/src/qml/qml/ftw/qbitfield_p.h b/src/qml/qml/ftw/qbitfield_p.h index 0b7d507b11..e3b6b0e498 100644 --- a/src/qml/qml/ftw/qbitfield_p.h +++ b/src/qml/qml/ftw/qbitfield_p.h @@ -129,15 +129,16 @@ QBitField QBitField::united(const QBitField &o) rv.bits = max; rv.ownData = new quint32[length + 1]; *(rv.ownData) = 1; - rv.data = rv.ownData + 1; + quint32 *rvdata; + rv.data = rvdata = rv.ownData + 1; if (bits > o.bits) { - ::memcpy((quint32 *)rv.data, data, length * sizeof(quint32)); + ::memcpy(rvdata, data, length * sizeof(quint32)); for (quint32 ii = 0; ii < (o.bits + quint32(31)) / 32; ++ii) - ((quint32 *)rv.data)[ii] |= o.data[ii]; + (rvdata)[ii] |= o.data[ii]; } else { - ::memcpy((quint32 *)rv.data, o.data, length * sizeof(quint32)); + ::memcpy(rvdata, o.data, length * sizeof(quint32)); for (quint32 ii = 0; ii < (bits + quint32(31)) / 32; ++ii) - ((quint32 *)rv.data)[ii] |= data[ii]; + (rvdata)[ii] |= data[ii]; } return rv; } diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h index 6ae2e17267..d38fd668f3 100644 --- a/src/qml/qml/ftw/qhashedstring_p.h +++ b/src/qml/qml/ftw/qhashedstring_p.h @@ -252,14 +252,14 @@ public: inline bool equals(const QHashedStringRef &string) const { return length == string.length() && hash == string.hash() && - (isQString()?QHashedString::compare(string.constData(), (QChar *)utf16Data(), length): + (isQString()?QHashedString::compare(string.constData(), (const QChar *)utf16Data(), length): QHashedString::compare(string.constData(), cStrData(), length)); } inline bool equals(const QHashedCStringRef &string) const { return length == string.length() && hash == string.hash() && - (isQString()?QHashedString::compare((QChar *)utf16Data(), string.constData(), length): + (isQString()?QHashedString::compare((const QChar *)utf16Data(), string.constData(), length): QHashedString::compare(string.constData(), cStrData(), length)); } }; diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index f08f650913..fb51bad3a7 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -783,7 +783,7 @@ QString QQmlContextData::findObjectId(const QObject *obj) const if (publicContext) { QQmlContextPrivate *p = QQmlContextPrivate::get(publicContext); for (int ii = 0; ii < p->propertyValues.count(); ++ii) - if (p->propertyValues.at(ii) == QVariant::fromValue((QObject *)obj)) + if (p->propertyValues.at(ii) == QVariant::fromValue(const_cast(obj))) return properties.findId(ii); } diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 8cf3d2064d..1f27e4ecb3 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -2228,7 +2228,7 @@ QObject *QQmlEnginePrivate::toQObject(const QVariant &v, bool *ok) const int t = v.userType(); if (t == QMetaType::QObjectStar || m_compositeTypes.contains(t)) { if (ok) *ok = true; - return *(QObject **)(v.constData()); + return *(QObject *const *)(v.constData()); } else { return QQmlMetaType::toQObject(v, ok); } diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 2f7834fa41..41d44a821a 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1508,7 +1508,7 @@ QObject *QQmlMetaType::toQObject(const QVariant &v, bool *ok) if (ok) *ok = true; - return *(QObject **)v.constData(); + return *(QObject *const *)v.constData(); } bool QQmlMetaType::isQObject(int userType) diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index ae452b727e..800f650075 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1304,12 +1304,12 @@ bool QQmlPropertyPrivate::write(QObject *object, QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, argv); } else if (variantType == propertyType) { - void *a[] = { (void *)value.constData(), 0, &status, &flags }; + void *a[] = { const_cast(value.constData()), 0, &status, &flags }; QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); } else if (qMetaTypeId() == propertyType) { - void *a[] = { (void *)&value, 0, &status, &flags }; + void *a[] = { const_cast(&value), 0, &status, &flags }; QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); } else if (property.isQObject()) { @@ -1319,7 +1319,7 @@ bool QQmlPropertyPrivate::write(QObject *object, if (valMo.isNull()) return false; - QObject *o = *(QObject **)value.constData(); + QObject *o = *(QObject *const *)value.constData(); QQmlMetaObject propMo = rawMetaObjectForType(enginePriv, propertyType); if (o) valMo = o; @@ -1465,7 +1465,7 @@ bool QQmlPropertyPrivate::write(QObject *object, } if (ok) { - void *a[] = { (void *)v.constData(), 0, &status, &flags}; + void *a[] = { const_cast(v.constData()), 0, &status, &flags}; QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); } else { return false; @@ -1603,7 +1603,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, const char *propertyType = 0; if (value.userType() == QMetaType::QObjectStar) { - if (QObject *o = *(QObject **)value.constData()) { + if (QObject *o = *(QObject *const *)value.constData()) { valueType = o->metaObject()->className(); QQmlMetaObject propertyMetaObject = rawMetaObjectForType(QQmlEnginePrivate::get(engine), type); diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index dd1f93ec00..0018275b95 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -271,7 +271,7 @@ QQmlPropertyCache::~QQmlPropertyCache() stringCache.clear(); if (_parent) _parent->release(); - if (_ownMetaObject) free((void *)_metaObject); + if (_ownMetaObject) free(const_cast(_metaObject)); _metaObject = 0; _parent = 0; engine = 0; diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index b147266080..10eaae0c77 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -202,7 +202,7 @@ QQmlValueType::~QQmlValueType() QObjectPrivate *op = QObjectPrivate::get(this); Q_ASSERT(op->metaObject == this); op->metaObject = 0; - ::free((void*)_metaObject); + ::free(const_cast(_metaObject)); metaType.destroy(gadgetPtr); } diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 5b1be15869..97fc382c33 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -772,7 +772,7 @@ int QQmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) int listIndex = data[id].asInt(); const List *list = &listProperties.at(listIndex); *reinterpret_cast *>(a[0]) = - QQmlListProperty(object, (void *)list, + QQmlListProperty(object, const_cast(list), list_append, list_count, list_at, list_clear); } @@ -1090,7 +1090,7 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) } else { bool needActivate = false; if (value.userType() == QMetaType::QObjectStar) { - QObject *o = *(QObject **)value.data(); + QObject *o = *(QObject *const *)value.data(); needActivate = (data[id].dataType() != QMetaType::QObjectStar || data[id].asQObject() != o); data[id].setValue(o, this, id); } else { diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index d0e2e34ff1..f3048d426a 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -119,7 +119,7 @@ struct QQmlVMEMetaData }; PropertyData *propertyData() const { - return (PropertyData *)(((const char *)this) + sizeof(QQmlVMEMetaData)); + return (PropertyData *)(((char *)const_cast(this)) + sizeof(QQmlVMEMetaData)); } AliasData *aliasData() const { diff --git a/src/qml/util/qqmllistaccessor.cpp b/src/qml/util/qqmllistaccessor.cpp index 55b745ab6d..bebab80d28 100644 --- a/src/qml/util/qqmllistaccessor.cpp +++ b/src/qml/util/qqmllistaccessor.cpp @@ -96,7 +96,7 @@ int QQmlListAccessor::count() const case VariantList: return qvariant_cast(d).count(); case ListProperty: - return ((QQmlListReference *)d.constData())->count(); + return ((const QQmlListReference *)d.constData())->count(); case Instance: return 1; case Integer: @@ -116,7 +116,7 @@ QVariant QQmlListAccessor::at(int idx) const case VariantList: return qvariant_cast(d).at(idx); case ListProperty: - return QVariant::fromValue(((QQmlListReference *)d.constData())->at(idx)); + return QVariant::fromValue(((const QQmlListReference *)d.constData())->at(idx)); case Instance: return d; case Integer: -- cgit v1.2.3 From ea6be7e47cce456a5a838d14925bff01f664a01f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 26 Jun 2015 18:14:31 +0200 Subject: Flickable: drag-over-bounds is not velocity-sensitive The inspiration for velocity sensitivity was to make it feel more like native trackpad flicking on OS X. But on touchscreens it doesn't make as much sense, and it became too difficult to intentionally overshoot in applications that depend on pull-to-refresh functionality. Task-number: QTBUG-46108 Change-Id: I3fea5324aaac1f003ead200e14b0c76bd8c0ece6 Reviewed-by: J-P Nurmi --- src/quick/items/qquickflickable.cpp | 47 ++++++++++++++++++++++++----------- src/quick/items/qquickflickable_p_p.h | 3 ++- 2 files changed, 34 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 52142346ab..19fb66c19c 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1004,7 +1004,8 @@ void QQuickFlickablePrivate::maybeBeginDrag(qint64 currentTimestamp, const QPoin } void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventType, const QPointF &localPos, - const QVector2D &deltas, bool overThreshold, bool momentum, const QVector2D &velocity) + const QVector2D &deltas, bool overThreshold, bool momentum, + bool velocitySensitiveOverBounds, const QVector2D &velocity) { Q_Q(QQuickFlickable); bool rejectY = false; @@ -1061,9 +1062,13 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } return; } - qreal overshoot = (newY - minY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; - overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); - newY = minY + overshoot; + if (velocitySensitiveOverBounds) { + qreal overshoot = (newY - minY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; + overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); + newY = minY + overshoot; + } else { + newY = minY + (newY - minY) / 2; + } } else if (newY < maxY && maxY - minY <= 0) { // Overshoot beyond the bottom. But don't wait for momentum phase to end before returning to bounds. if (momentum && vData.atEnd) { @@ -1073,9 +1078,13 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } return; } - qreal overshoot = (newY - maxY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; - overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); - newY = maxY - overshoot; + if (velocitySensitiveOverBounds) { + qreal overshoot = (newY - maxY) * vData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; + overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); + newY = maxY - overshoot; + } else { + newY = maxY + (newY - maxY) / 2; + } } } if (!rejectY && stealMouse && dy != 0.0 && dy != vData.previousDragDelta) { @@ -1126,9 +1135,13 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } return; } - qreal overshoot = (newX - minX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; - overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); - newX = minX + overshoot; + if (velocitySensitiveOverBounds) { + qreal overshoot = (newX - minX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; + overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); + newX = minX + overshoot; + } else { + newX = minX + (newX - minX) / 2; + } } else if (newX < maxX && maxX - minX <= 0) { // Overshoot beyond the right. But don't wait for momentum phase to end before returning to bounds. if (momentum && hData.atEnd) { @@ -1138,9 +1151,13 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } return; } - qreal overshoot = (newX - maxX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; - overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); - newX = maxX - overshoot; + if (velocitySensitiveOverBounds) { + qreal overshoot = (newX - maxX) * hData.velocity / QML_FLICK_DEFAULTMAXVELOCITY / QML_FLICK_OVERSHOOTFRICTION; + overshoot = QML_FLICK_OVERSHOOT * devicePixelRatio() * EaseOvershoot(overshoot / QML_FLICK_OVERSHOOT / devicePixelRatio()); + newX = maxX - overshoot; + } else { + newX = maxX + (newX - maxX) / 2; + } } } @@ -1210,7 +1227,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (q->xflick()) overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.x(), Qt::XAxis, event); - drag(currentTimestamp, event->type(), event->localPos(), deltas, overThreshold, false, velocity); + drag(currentTimestamp, event->type(), event->localPos(), deltas, overThreshold, false, false, velocity); } void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) @@ -1433,7 +1450,7 @@ void QQuickFlickable::wheelEvent(QWheelEvent *event) QVector2D velocity(xDelta / elapsed, yDelta / elapsed); d->lastPosTime = currentTimestamp; d->accumulatedWheelPixelDelta += QVector2D(event->pixelDelta()); - d->drag(currentTimestamp, event->type(), event->posF(), d->accumulatedWheelPixelDelta, true, !d->scrollingPhase, velocity); + d->drag(currentTimestamp, event->type(), event->posF(), d->accumulatedWheelPixelDelta, true, !d->scrollingPhase, true, velocity); } if (!event->isAccepted()) diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index d7148ca57a..65bb3e802d 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -250,7 +250,8 @@ public: void maybeBeginDrag(qint64 currentTimestamp, const QPointF &pressPosn); void drag(qint64 currentTimestamp, QEvent::Type eventType, const QPointF &localPos, - const QVector2D &deltas, bool overThreshold, bool momentum, const QVector2D &velocity); + const QVector2D &deltas, bool overThreshold, bool momentum, + bool velocitySensitiveOverBounds, const QVector2D &velocity); qint64 computeCurrentTime(QInputEvent *event); qreal devicePixelRatio(); -- cgit v1.2.3 From 0c7fe9a33e696b8a319f96daaaf730ed03e9b233 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 2 Jul 2015 15:30:47 +0200 Subject: doc: fix copy/paste error in warning Change-Id: I4a9a46913b589b14c879620848d76b31e435ee02 Reviewed-by: Robin Burchell --- src/quick/items/qquickwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 4238787cc8..a17d4a4357 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -3530,7 +3530,7 @@ QQmlIncubationController *QQuickWindow::incubationController() const slot function needs to finish before execution continues, you must make sure that the connection is direct (see Qt::ConnectionType). - \warning Make very sure that a signal handler for afterRendering() leaves the GL + \warning Make very sure that a signal handler for sceneGraphAboutToStop() leaves the GL context in the same state as it was when the signal handler was entered. Failing to do so can result in the scene not rendering properly. -- cgit v1.2.3 From c749f37c83cbb458e25a7d5200facf8634ac959e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 3 Jul 2015 13:20:18 +0200 Subject: V4: track C++ heap usage for Strings in the MemoryManager ... and do a GC run when it exceeds a threshold. The issue with Strings is that they hold on to QString instances that store the real content. However, the GC only sees the light-weight JS handle, and doesn't take the size of the backing content into account. So it could happen that big QStrings accumulate in the heap as long as the GC didn't reach its threshold. The newly introduced unmanaged heap threshold is upped by a factor of two when exceeded, and lowered by a factor of 2 when the used heap space falls below a quarter of the threshold. Also grow the threshold if there is enough space after running the GC, but another GC run would be triggered for the next allocation. There is a special case for Heap::String::append, because this method will copy the data from the left and right substrings into a new QString. To track this, append notifies the memory manager directly of the new length. The pointer to the memory manager is stored in Heap::String, growing it from 40 bytes to 48 bytes (which makes it still fit in the same bucket, so no extra memory is allocated). Task-number: QTBUG-42002 Change-Id: I71313915e593a9908a2b227b0bc4d768e375ee17 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 2 +- src/qml/jsruntime/qv4function.cpp | 3 ++- src/qml/jsruntime/qv4mm.cpp | 48 +++++++++++++++++++++++++++++++++------ src/qml/jsruntime/qv4mm_p.h | 17 +++++++++++--- src/qml/jsruntime/qv4runtime.cpp | 9 +++++--- src/qml/jsruntime/qv4string.cpp | 7 ++++-- src/qml/jsruntime/qv4string_p.h | 8 +++++-- 7 files changed, 75 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 2dbdcfc526..0f2b44fac6 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -538,7 +538,7 @@ Heap::Object *ExecutionEngine::newObject(InternalClass *internalClass, QV4::Obje Heap::String *ExecutionEngine::newString(const QString &s) { Scope scope(this); - return ScopedString(scope, memoryManager->alloc(s))->d(); + return ScopedString(scope, memoryManager->allocWithStringData(s.length() * sizeof(QChar), s))->d(); } Heap::String *ExecutionEngine::newIdentifier(const QString &text) diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index efe6c7c226..be63b31e1e 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -66,7 +66,8 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, break; } // duplicate arguments, need some trick to store them - arg = engine->memoryManager->alloc(arg->d(), engine->newString(QString(0xfffe))); + MemoryManager *mm = engine->memoryManager; + arg = mm->alloc(mm, arg->d(), engine->newString(QString(0xfffe))); } } diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index d5576b400a..64491e1376 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -95,6 +95,8 @@ struct MemoryManager::Data uint maxShift; std::size_t maxChunkSize; QVector heapChunks; + std::size_t unmanagedHeapSize; // the amount of bytes of heap that is not managed by the memory manager, but which is held onto by managed items. + std::size_t unmanagedHeapSizeGCLimit; struct LargeItem { LargeItem *next; @@ -123,6 +125,8 @@ struct MemoryManager::Data , totalAlloc(0) , maxShift(6) , maxChunkSize(32*1024) + , unmanagedHeapSize(0) + , unmanagedHeapSizeGCLimit(64 * 1024) , largeItems(0) , totalLargeItemsAllocated(0) , deletable(0) @@ -157,8 +161,10 @@ struct MemoryManager::Data namespace { -bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, ExecutionEngine *engine) +bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, ExecutionEngine *engine, std::size_t *unmanagedHeapSize) { + Q_ASSERT(unmanagedHeapSize); + bool isEmpty = true; Heap::Base *tail = &header->freeItems; // qDebug("chunkStart @ %p, size=%x, pos=%x", header->itemStart, header->itemSize, header->itemSize>>4); @@ -167,8 +173,8 @@ bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, Exec #endif for (char *item = header->itemStart; item <= header->itemEnd; item += header->itemSize) { Heap::Base *m = reinterpret_cast(item); -// qDebug("chunk @ %p, size = %lu, in use: %s, mark bit: %s", -// item, m->size, (m->inUse ? "yes" : "no"), (m->markBit ? "true" : "false")); +// qDebug("chunk @ %p, in use: %s, mark bit: %s", +// item, (m->inUse() ? "yes" : "no"), (m->isMarked() ? "true" : "false")); Q_ASSERT((qintptr) item % 16 == 0); @@ -183,6 +189,13 @@ bool sweepChunk(MemoryManager::Data::ChunkHeader *header, uint *itemsInUse, Exec #ifdef V4_USE_VALGRIND VALGRIND_ENABLE_ERROR_REPORTING; #endif + if (std::size_t(header->itemSize) == MemoryManager::align(sizeof(Heap::String)) && m->gcGetVtable()->isString) { + std::size_t heapBytes = static_cast(m)->retainedTextSize(); + Q_ASSERT(*unmanagedHeapSize >= heapBytes); +// qDebug() << "-- it's a string holding on to" << heapBytes << "bytes"; + *unmanagedHeapSize -= heapBytes; + } + if (m->gcGetVtable()->destroy) m->gcGetVtable()->destroy(m); @@ -219,7 +232,7 @@ MemoryManager::MemoryManager(ExecutionEngine *engine) m_d->engine = engine; } -Heap::Base *MemoryManager::allocData(std::size_t size) +Heap::Base *MemoryManager::allocData(std::size_t size, std::size_t unmanagedSize) { if (m_d->aggressiveGC) runGC(); @@ -230,11 +243,27 @@ Heap::Base *MemoryManager::allocData(std::size_t size) Q_ASSERT(size >= 16); Q_ASSERT(size % 16 == 0); +// qDebug() << "unmanagedHeapSize:" << m_d->unmanagedHeapSize << "limit:" << m_d->unmanagedHeapSizeGCLimit << "unmanagedSize:" << unmanagedSize; + m_d->unmanagedHeapSize += unmanagedSize; + bool didGCRun = false; + if (m_d->unmanagedHeapSize > m_d->unmanagedHeapSizeGCLimit) { + runGC(); + + if (m_d->unmanagedHeapSizeGCLimit <= m_d->unmanagedHeapSize) + m_d->unmanagedHeapSizeGCLimit = std::max(m_d->unmanagedHeapSizeGCLimit, m_d->unmanagedHeapSize) * 2; + else if (m_d->unmanagedHeapSize * 4 <= m_d->unmanagedHeapSizeGCLimit) + m_d->unmanagedHeapSizeGCLimit /= 2; + else if (m_d->unmanagedHeapSizeGCLimit - m_d->unmanagedHeapSize < 5 * unmanagedSize) + // try preventing running the GC all the time when we're just below the threshold limit and manage to collect just enough to do this one allocation + m_d->unmanagedHeapSizeGCLimit += std::max(std::size_t(8 * 1024), 5 * unmanagedSize); + didGCRun = true; + } + size_t pos = size >> 4; // doesn't fit into a small bucket if (size >= MemoryManager::Data::MaxItemSize) { - if (m_d->totalLargeItemsAllocated > 8 * 1024 * 1024) + if (!didGCRun && m_d->totalLargeItemsAllocated > 8 * 1024 * 1024) runGC(); // we use malloc for this @@ -257,7 +286,7 @@ Heap::Base *MemoryManager::allocData(std::size_t size) } // try to free up space, otherwise allocate - if (m_d->allocCount[pos] > (m_d->availableItems[pos] >> 1) && m_d->totalAlloc > (m_d->totalItems >> 1) && !m_d->aggressiveGC) { + if (!didGCRun && m_d->allocCount[pos] > (m_d->availableItems[pos] >> 1) && m_d->totalAlloc > (m_d->totalItems >> 1) && !m_d->aggressiveGC) { runGC(); header = m_d->nonFullChunks[pos]; if (header) { @@ -404,7 +433,7 @@ void MemoryManager::sweep(bool lastSweep) for (int i = 0; i < m_d->heapChunks.size(); ++i) { Data::ChunkHeader *header = reinterpret_cast(m_d->heapChunks[i].base()); - chunkIsEmpty[i] = sweepChunk(header, &itemsInUse[header->itemSize >> 4], m_d->engine); + chunkIsEmpty[i] = sweepChunk(header, &itemsInUse[header->itemSize >> 4], m_d->engine, &m_d->unmanagedHeapSize); } QVector::iterator chunkIter = m_d->heapChunks.begin(); @@ -553,6 +582,11 @@ size_t MemoryManager::getLargeItemsMem() const return total; } +void MemoryManager::growUnmanagedHeapSizeUsage(size_t delta) +{ + m_d->unmanagedHeapSize += delta; +} + MemoryManager::~MemoryManager() { delete m_persistentValues; diff --git a/src/qml/jsruntime/qv4mm_p.h b/src/qml/jsruntime/qv4mm_p.h index 00b41b796a..7f6d2edba3 100644 --- a/src/qml/jsruntime/qv4mm_p.h +++ b/src/qml/jsruntime/qv4mm_p.h @@ -83,10 +83,10 @@ public: { return (size + 15) & ~0xf; } template - inline typename ManagedType::Data *allocManaged(std::size_t size) + inline typename ManagedType::Data *allocManaged(std::size_t size, std::size_t unmanagedSize = 0) { size = align(size); - Heap::Base *o = allocData(size); + Heap::Base *o = allocData(size, unmanagedSize); o->vtable = ManagedType::staticVTable(); return static_cast(o); } @@ -109,6 +109,15 @@ public: return t->d(); } + template + typename ManagedType::Data *allocWithStringData(std::size_t unmanagedSize, Arg1 arg1) + { + Scope scope(engine()); + Scoped t(scope, allocManaged(sizeof(typename ManagedType::Data), unmanagedSize)); + (void)new (t->d()) typename ManagedType::Data(this, arg1); + return t->d(); + } + template typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2) { @@ -159,10 +168,12 @@ public: size_t getAllocatedMem() const; size_t getLargeItemsMem() const; + void growUnmanagedHeapSizeUsage(size_t delta); // called when a JS object grows itself. Specifically: Heap::String::append + protected: /// expects size to be aligned // TODO: try to inline - Heap::Base *allocData(std::size_t size); + Heap::Base *allocData(std::size_t size, std::size_t unmanagedSize); #ifdef DETAILED_MM_STATS void willAllocate(std::size_t size); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index c31de6a9f0..b66e917b87 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -521,7 +521,8 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu return pright->asReturnedValue(); if (!pright->stringValue()->d()->length()) return pleft->asReturnedValue(); - return (engine->memoryManager->alloc(pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); + MemoryManager *mm = engine->memoryManager; + return (mm->alloc(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); } double x = RuntimeHelpers::toNumber(pleft); double y = RuntimeHelpers::toNumber(pright); @@ -537,7 +538,8 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left return right.asReturnedValue(); if (!right.stringValue()->d()->length()) return left.asReturnedValue(); - return (engine->memoryManager->alloc(left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue(); + MemoryManager *mm = engine->memoryManager; + return (mm->alloc(mm, left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue(); } Scope scope(engine); @@ -554,7 +556,8 @@ QV4::ReturnedValue Runtime::addString(ExecutionEngine *engine, const Value &left return pright->asReturnedValue(); if (!pright->stringValue()->d()->length()) return pleft->asReturnedValue(); - return (engine->memoryManager->alloc(pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); + MemoryManager *mm = engine->memoryManager; + return (mm->alloc(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); } void Runtime::setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 20dd84420c..6d55eb2c18 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -117,7 +117,8 @@ bool String::isEqualTo(Managed *t, Managed *o) } -Heap::String::String(const QString &t) +Heap::String::String(MemoryManager *mm, const QString &t) + : mm(mm) { subtype = String::StringType_Unknown; @@ -129,7 +130,8 @@ Heap::String::String(const QString &t) len = text->size; } -Heap::String::String(String *l, String *r) +Heap::String::String(MemoryManager *mm, String *l, String *r) + : mm(mm) { subtype = String::StringType_Unknown; @@ -187,6 +189,7 @@ void Heap::String::simplifyString() const text->ref.ref(); identifier = 0; largestSubLength = 0; + mm->growUnmanagedHeapSizeUsage(size_t(text->size) * sizeof(QChar)); } void Heap::String::createHashValue() const diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 5a0c83b4b9..1cf8f51a29 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -53,8 +53,8 @@ struct Q_QML_PRIVATE_EXPORT String : Base { StringType_ArrayIndex }; - String(const QString &text); - String(String *l, String *n); + String(MemoryManager *mm, const QString &text); + String(MemoryManager *mm, String *l, String *n); ~String() { if (!largestSubLength && !text->ref.deref()) QStringData::deallocate(text); @@ -66,6 +66,9 @@ struct Q_QML_PRIVATE_EXPORT String : Base { len == (uint)text->size); return len; } + std::size_t retainedTextSize() const { + return largestSubLength ? 0 : (std::size_t(text->size) * sizeof(QChar)); + } void createHashValue() const; inline unsigned hashValue() const { if (subtype == StringType_Unknown) @@ -107,6 +110,7 @@ struct Q_QML_PRIVATE_EXPORT String : Base { mutable uint stringHash; mutable uint largestSubLength; uint len; + MemoryManager *mm; private: static void append(const String *data, QChar *ch); }; -- cgit v1.2.3 From 34f9b8d322f74793221029ef8a6e1053f2a0d2ae Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 10 Jul 2015 14:30:05 +0200 Subject: Fix QML/JS debugging. Converting from any ScopedObject to Object* resulted in the same pointer value. Prevent this by not using either, but instead use the QV4::Value directly. Task-number: QTBUG-47061 Change-Id: I98d3889f5504dbd5962099d30d4af9d57bc518f9 Reviewed-by: Ulf Hermann --- src/qml/debugger/qv4debugservice.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/qml/debugger/qv4debugservice.cpp b/src/qml/debugger/qv4debugservice.cpp index 32b7b38285..cefb29e031 100644 --- a/src/qml/debugger/qv4debugservice.cpp +++ b/src/qml/debugger/qv4debugservice.cpp @@ -330,14 +330,14 @@ private: refsToInclude.append(value); } - void cacheObjectRef(QV4::Object *obj, int ref) + void cacheObjectRef(QV4::Value obj, int ref) { - objectRefs.insert(obj, ref); + objectRefs.insert(obj.val, ref); } - int cachedObjectRef(QV4::Object *obj) const + int cachedObjectRef(QV4::Value obj) const { - return objectRefs.value(obj, -1); + return objectRefs.value(obj.val, -1); } private: @@ -347,7 +347,7 @@ private: QJsonArray *destination; QSet usedRefs; QHash > refsByHandle; - QHash objectRefs; + QHash objectRefs; }; class QV4DebugServicePrivate : public QQmlConfigurableDebugServicePrivate -- cgit v1.2.3 From a169d310e4ecf54ce3577ae46cfc45eb9d308a13 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Wed, 15 Jul 2015 15:04:20 +0200 Subject: Doc: replace Mac OS X with OS X Task-number: QTBUG-40759 Change-Id: If21b4551eb95af3370cc21edd7a6721fc06e1346 Reviewed-by: Martin Smith --- src/particles/qquickimageparticle.cpp | 2 +- src/qml/qml/qqmlimport.cpp | 2 +- src/quick/items/qquickevents.cpp | 2 +- src/quick/items/qquicktextcontrol.cpp | 2 +- src/quick/items/qquicktextinput.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index c0e1b4e422..7df3299325 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -1271,7 +1271,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) #endif #ifdef Q_OS_MAC - // Mac OS X 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros, + // OS X 10.8.3 introduced a bug in the AMD drivers, for at least the 2011 macbook pros, // causing point sprites who read gl_PointCoord in the frag shader to come out as // green-red blobs. if (perfLevel < Deformable && strstr((char *) glGetString(GL_VENDOR), "ATI")) { diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 5a54609e12..ff48a10d95 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1641,7 +1641,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader, \row \li Unix/Linux \li \c .so \row \li AIX \li \c .a \row \li HP-UX \li \c .sl, \c .so (HP-UXi) - \row \li Mac OS X \li \c .dylib, \c .bundle, \c .so + \row \li OS X \li \c .dylib, \c .bundle, \c .so \endtable Version number on unix are ignored. diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 3ce4a8cb49..1380452718 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -323,7 +323,7 @@ Item { \qmlproperty point QtQuick::WheelEvent::pixelDelta This property holds the delta in screen pixels and is available in plataforms that - have high-resolution trackpads, such as Mac OS X. + have high-resolution trackpads, such as OS X. The x and y cordinate of this property holds the delta in horizontal and vertical orientation. The value should be used directly to scroll content on screen. diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 95d2e7c995..6929bb44a2 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -225,7 +225,7 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e) return false; } -// Except for pageup and pagedown, Mac OS X has very different behavior, we don't do it all, but +// Except for pageup and pagedown, OS X has very different behavior, we don't do it all, but // here's the breakdown: // Shift still works as an anchor, but only one of the other keys can be down Ctrl (Command), // Alt (Option), or Meta (Control). diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index a4c61209f2..5c67d914a5 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -78,7 +78,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) and setting \l echoMode to an appropriate value enables TextInput to be used for a password input field. - On Mac OS X, the Up/Down key bindings for Home/End are explicitly disabled. + On OS X, the Up/Down key bindings for Home/End are explicitly disabled. If you want such bindings (on any platform), you will need to construct them in QML. \sa TextEdit, Text -- cgit v1.2.3 From 2d8bf9eed72cff041a235160fe14a7f424475610 Mon Sep 17 00:00:00 2001 From: Nobuaki Sukegawa Date: Tue, 14 Jul 2015 01:04:20 +0900 Subject: Fix trivial bug where ArrayBuffer.isView never returned false Change-Id: I168d2ec54997d057e3d32463c2b153df38073838 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4arraybuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 11664f1194..dc65b5d21a 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -78,7 +78,7 @@ ReturnedValue ArrayBufferCtor::method_isView(CallContext *ctx) QV4::Scoped v(scope, ctx->argument(0)); if (!!v) return Encode(true); - return Encode(true); + return Encode(false); } -- cgit v1.2.3 From 7da45b21b76965e021e8a049715b1dee34081f7c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 6 Jul 2015 12:11:19 +0200 Subject: Fix warning about returning address of local variable by MSVC2015 in qv4engine.cpp. qtdeclarative\src\qml\jsruntime\qv4engine.cpp(179) : warning C4172: returning address of local variable or temporary: dummy Disable warning as using the address is intended. Change-Id: Ide894a8dc2fb94f11d0455723c46567c84d91f8d Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 0f2b44fac6..e1282eeca9 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -108,6 +108,9 @@ static ReturnedValue throwTypeError(CallContext *ctx) const int MinimumStackSize = 256; // in kbytes +QT_WARNING_PUSH +QT_WARNING_DISABLE_MSVC(4172) // MSVC 2015: warning C4172: returning address of local variable or temporary: dummy + quintptr getStackLimit() { quintptr stackLimit; @@ -172,6 +175,7 @@ quintptr getStackLimit() int dummy; // this is inexact, as part of the stack is used when being called here, // but let's simply default to 1MB from where the stack is right now + // (Note: triggers warning C4172 as of MSVC 2015, returning address of local variable) stackLimit = reinterpret_cast(&dummy) - 1024*1024; #endif @@ -179,6 +183,7 @@ quintptr getStackLimit() return stackLimit + MinimumStackSize*1024; } +QT_WARNING_POP QJSEngine *ExecutionEngine::jsEngine() const { -- cgit v1.2.3 From 74e2ed4841ac35c9af806eeb0555d492ffc82cb8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 18 Jul 2015 21:33:33 -0700 Subject: Consistently use the override keyword Clang doesn't like when it's inconsistent. Change-Id: Ib306f8f647014b399b87ffff13f23eebda07757b Reviewed-by: Simon Hausmann --- src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp | 8 ++++---- src/quick/items/qquickdrag.cpp | 2 +- src/quick/items/qquickgridview.cpp | 8 ++++---- src/quick/items/qquickimage_p.h | 2 +- src/quick/items/qquickitemview_p_p.h | 2 +- src/quick/items/qquicklistview.cpp | 8 ++++---- src/quick/items/qquickwindow.cpp | 2 +- src/quick/util/qquickanimatorjob_p.h | 8 ++++---- src/quickwidgets/qquickwidget_p.h | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp index 782d03f9f9..4a2c137aa1 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp @@ -92,7 +92,7 @@ namespace { { } - void paint(QPainter *p) const { p->fillRect(m_rect, m_brush); } + void paint(QPainter *p) const Q_DECL_OVERRIDE { p->fillRect(m_rect, m_brush); } QRectF boundingRect() const Q_DECL_OVERRIDE { return m_rect; } private: @@ -109,7 +109,7 @@ namespace { { } - void paint(QPainter *p) const { p->fillPath(m_path, m_brush); } + void paint(QPainter *p) const Q_DECL_OVERRIDE { p->fillPath(m_path, m_brush); } QRectF boundingRect() const Q_DECL_OVERRIDE { return m_path.boundingRect(); } private: @@ -126,7 +126,7 @@ namespace { { } - void paint(QPainter *p) const { p->strokePath(m_path, m_pen); } + void paint(QPainter *p) const Q_DECL_OVERRIDE { p->strokePath(m_path, m_pen); } QRectF boundingRect() const Q_DECL_OVERRIDE { @@ -148,7 +148,7 @@ namespace { { } - void paint(QPainter *p) const { p->drawImage(m_offset, m_image); } + void paint(QPainter *p) const Q_DECL_OVERRIDE { p->drawImage(m_offset, m_image); } QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(m_image.rect()).translated(m_offset); } diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index 4d46485718..2612b855bd 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -75,7 +75,7 @@ public: } void itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &) Q_DECL_OVERRIDE; - void itemParentChanged(QQuickItem *, QQuickItem *parent); + void itemParentChanged(QQuickItem *, QQuickItem *parent) Q_DECL_OVERRIDE; void updatePosition(); void restartDrag(); void deliverEnterEvent(); diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 3cc0a28b87..99c77488f4 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -60,19 +60,19 @@ public: { } - qreal position() const { + qreal position() const Q_DECL_OVERRIDE { return rowPos(); } - qreal endPosition() const { + qreal endPosition() const Q_DECL_OVERRIDE { return endRowPos(); } - qreal size() const { + qreal size() const Q_DECL_OVERRIDE { return view->flow() == QQuickGridView::FlowLeftToRight ? view->cellHeight() : view->cellWidth(); } - qreal sectionSize() const { + qreal sectionSize() const Q_DECL_OVERRIDE { return 0.0; } diff --git a/src/quick/items/qquickimage_p.h b/src/quick/items/qquickimage_p.h index 8edf153ca3..be514ae2f5 100644 --- a/src/quick/items/qquickimage_p.h +++ b/src/quick/items/qquickimage_p.h @@ -88,7 +88,7 @@ public: bool mipmap() const; void setMipmap(bool use); - virtual void emitAutoTransformBaseChanged() { emit autoTransformChanged(); } + virtual void emitAutoTransformBaseChanged() Q_DECL_OVERRIDE { emit autoTransformChanged(); } Q_SIGNALS: void fillModeChanged(); diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index 5ac88a7585..a8352b229e 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -178,7 +178,7 @@ public: void regenerate(bool orientationChanged=false); void layout(); - virtual void animationFinished(QAbstractAnimationJob *); + virtual void animationFinished(QAbstractAnimationJob *) Q_DECL_OVERRIDE; void refill(); void refill(qreal from, qreal to); void mirrorChange() Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index cc500956f5..20b6dd5b36 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -255,7 +255,7 @@ public: static_cast(attached)->m_sectionItem = s; } - qreal position() const { + qreal position() const Q_DECL_OVERRIDE { if (section()) { if (view->orientation() == QQuickListView::Vertical) return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -section()->height()-section()->y() : section()->y()); @@ -271,7 +271,7 @@ public: else return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-itemX() : itemX()); } - qreal size() const { + qreal size() const Q_DECL_OVERRIDE { if (section()) return (view->orientation() == QQuickListView::Vertical ? item->height()+section()->height() : item->width()+section()->width()); else @@ -280,12 +280,12 @@ public: qreal itemSize() const { return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width()); } - qreal sectionSize() const { + qreal sectionSize() const Q_DECL_OVERRIDE { if (section()) return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width()); return 0.0; } - qreal endPosition() const { + qreal endPosition() const Q_DECL_OVERRIDE { if (view->orientation() == QQuickListView::Vertical) { return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -itemY() diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index a17d4a4357..5958edf29f 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -113,7 +113,7 @@ public: } protected: - void timerEvent(QTimerEvent *) + void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE { killTimer(m_timer); m_timer = 0; diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 1cffae17db..f8f40b4705 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -63,7 +63,7 @@ public: QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObject *item); ~QQuickAnimatorProxyJob(); - int duration() const { return m_duration; } + int duration() const Q_DECL_OVERRIDE { return m_duration; } QAbstractAnimationJob *job() const { return m_job; } @@ -72,8 +72,8 @@ public: void markJobManagedByController() { m_jobManagedByController = true; } protected: - void updateCurrentTime(int); - void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); + void updateCurrentTime(int) Q_DECL_OVERRIDE; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) Q_DECL_OVERRIDE; void debugAnimation(QDebug d) const Q_DECL_OVERRIDE; public Q_SLOTS: @@ -116,7 +116,7 @@ public: qreal to() const { return m_to; } void setDuration(int duration) { m_duration = duration; } - int duration() const { return m_duration; } + int duration() const Q_DECL_OVERRIDE { return m_duration; } QEasingCurve easingCurve() const { return m_easing; } void setEasingCurve(const QEasingCurve &curve) { m_easing = curve; } diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index dd0da96c3d..e8d1f714f3 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -70,7 +70,7 @@ public: ~QQuickWidgetPrivate(); void execute(); - void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); + void itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE; void initResize(); void updateSize(); void updatePosition(); @@ -82,7 +82,7 @@ public: void destroyContext(); void handleContextCreationFailure(const QSurfaceFormat &format, bool isEs); - QObject *focusObject(); + QObject *focusObject() Q_DECL_OVERRIDE; GLuint textureId() const Q_DECL_OVERRIDE; QImage grabFramebuffer() Q_DECL_OVERRIDE; -- cgit v1.2.3 From 2c2eb24975bbf5c698d4d23c6a5060729339d9f3 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Fri, 10 Jul 2015 15:46:55 +0200 Subject: qquicktext: Fix using CSS line-height with RichText Only if lineHeight has explicitly been set it will override the block format. Task-number: QTBUG-45204 Change-Id: I6e0d6dd70460cbf436dda3e5640bb9b1d16d7e5a Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktext.cpp | 5 ++++- src/quick/items/qquicktext_p_p.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index dd4f57bfdb..205571f2e7 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -91,6 +91,7 @@ QQuickTextPrivate::ExtraData::ExtraData() , minimumPointSize(12) , nbActiveDownloads(0) , maximumLineCount(INT_MAX) + , lineHeightValid(false) , lineHeightMode(QQuickText::ProportionalHeight) , fontSizeMode(QQuickText::FixedSize) { @@ -344,7 +345,7 @@ void QQuickTextPrivate::updateLayout() } textHasChanged = false; } - } else { + } else if (extra.isAllocated() && extra->lineHeightValid) { ensureDoc(); QTextBlockFormat::LineHeightTypes type; type = lineHeightMode() == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight; @@ -2386,6 +2387,7 @@ void QQuickText::setLineHeight(qreal lineHeight) if ((d->lineHeight() == lineHeight) || (lineHeight < 0.0)) return; + d->extra.value().lineHeightValid = true; d->extra.value().lineHeight = lineHeight; d->implicitHeightValid = false; d->updateLayout(); @@ -2417,6 +2419,7 @@ void QQuickText::setLineHeightMode(LineHeightMode mode) return; d->implicitHeightValid = false; + d->extra.value().lineHeightValid = true; d->extra.value().lineHeightMode = mode; d->updateLayout(); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 9a6da3736e..cd14008728 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -95,6 +95,7 @@ public: int minimumPointSize; int nbActiveDownloads; int maximumLineCount; + bool lineHeightValid : 1; QQuickText::LineHeightMode lineHeightMode; QQuickText::FontSizeMode fontSizeMode; QList imgTags; -- cgit v1.2.3 From 96c35a84d30b5b5cdf8feac4959891ad0bfed6a8 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 20 Jul 2015 14:21:08 +0200 Subject: fix readonly metaproperties (revealed by compiler warning) Found thanks to -Wparentheses + gcc 5.1 Change-Id: Iad784a26d268b85f7c67623fd63f0b097a9f29f9 Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmltypecompiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 46b67d5983..4e9817aa0d 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -836,7 +836,7 @@ bool QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const QmlIR::Ob propertyFlags |= QQmlPropertyData::IsQList; } - if ((!p->flags & QV4::CompiledData::Property::IsReadOnly) && p->type != QV4::CompiledData::Property::CustomList) + if (!(p->flags & QV4::CompiledData::Property::IsReadOnly) && p->type != QV4::CompiledData::Property::CustomList) propertyFlags |= QQmlPropertyData::IsWritable; @@ -860,7 +860,7 @@ bool QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const QmlIR::Ob continue; quint32 propertyFlags = QQmlPropertyData::IsVarProperty; - if (!p->flags & QV4::CompiledData::Property::IsReadOnly) + if (!(p->flags & QV4::CompiledData::Property::IsReadOnly)) propertyFlags |= QQmlPropertyData::IsWritable; VMD *vmd = (QQmlVMEMetaData *)dynamicData.data(); -- cgit v1.2.3 From 40b9fb8946837a01710814c28fd0f04edba631ad Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 13 Jul 2015 14:57:16 +0200 Subject: Fix possible stack overflow with many property bindings When there are a lot of bindings to the same property (like 20 000), we would get stack overflows because the notify list for the changed signal was traversed recursively. Changing this also speeds up the traversal. I see something like ~40% reduction in the case of layout() for a notify list of around 200 items. Note: To make it possible to traverse the double-linked list backwards, the next-pointer needs to be moved to the beginning of the struct, because the implementation pattern assumes this (node->next->prev = &node->next). I think this code has rotted after it was added, since the prev pointer was never actually used anywhere before. Change-Id: Icdfac50b7c8584a908efa65694c7f5f416cb153b Reviewed-by: Lars Knoll --- src/qml/qml/qqmlengine.cpp | 28 +++++++++++++++------- src/qml/qml/qqmlnotifier.cpp | 56 ++++++++++++++++++++++++++++++-------------- src/qml/qml/qqmlnotifier_p.h | 7 +++--- 3 files changed, 62 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 1f27e4ecb3..392cbe9371 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1540,16 +1540,28 @@ QQmlDataExtended::~QQmlDataExtended() void QQmlData::NotifyList::layout(QQmlNotifierEndpoint *endpoint) { - if (endpoint->next) - layout(endpoint->next); + // Add a temporary sentinel at beginning of list. This will be overwritten + // when the end point is inserted into the notifies further down. + endpoint->prev = 0; - int index = endpoint->sourceSignal; - index = qMin(index, 0xFFFF - 1); + while (endpoint->next) { + Q_ASSERT(reinterpret_cast(endpoint->next->prev) == endpoint); + endpoint = endpoint->next; + } + + while (endpoint) { + QQmlNotifierEndpoint *ep = (QQmlNotifierEndpoint *) endpoint->prev; + + int index = endpoint->sourceSignal; + index = qMin(index, 0xFFFF - 1); - endpoint->next = notifies[index]; - if (endpoint->next) endpoint->next->prev = &endpoint->next; - endpoint->prev = ¬ifies[index]; - notifies[index] = endpoint; + endpoint->next = notifies[index]; + if (endpoint->next) endpoint->next->prev = &endpoint->next; + endpoint->prev = ¬ifies[index]; + notifies[index] = endpoint; + + endpoint = ep; + } } void QQmlData::NotifyList::layout() diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index 4ce5be4d1a..ea3f7a1530 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -51,30 +51,52 @@ static Callback QQmlNotifier_callbacks[] = { QQmlVMEMetaObjectEndpoint_callback }; +namespace { + struct NotifyListTraversalData { + NotifyListTraversalData(QQmlNotifierEndpoint *ep = 0) + : originalSenderPtr(0) + , disconnectWatch(0) + , endpoint(ep) + {} + + qintptr originalSenderPtr; + qintptr *disconnectWatch; + QQmlNotifierEndpoint *endpoint; + }; +} + void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a) { - qintptr originalSenderPtr; - qintptr *disconnectWatch; - - if (!endpoint->isNotifying()) { - originalSenderPtr = endpoint->senderPtr; - disconnectWatch = &originalSenderPtr; - endpoint->senderPtr = qintptr(disconnectWatch) | 0x1; - } else { - disconnectWatch = (qintptr *)(endpoint->senderPtr & ~0x1); + QVarLengthArray stack; + while (endpoint) { + stack.append(NotifyListTraversalData(endpoint)); + endpoint = endpoint->next; } - if (endpoint->next) - emitNotify(endpoint->next, a); + int i = 0; + for (; i < stack.size(); ++i) { + NotifyListTraversalData &data = stack[i]; + + if (!data.endpoint->isNotifying()) { + data.originalSenderPtr = data.endpoint->senderPtr; + data.disconnectWatch = &data.originalSenderPtr; + data.endpoint->senderPtr = qintptr(data.disconnectWatch) | 0x1; + } else { + data.disconnectWatch = (qintptr *)(data.endpoint->senderPtr & ~0x1); + } + } - if (*disconnectWatch) { + while (--i >= 0) { + const NotifyListTraversalData &data = stack.at(i); + if (*data.disconnectWatch) { - Q_ASSERT(QQmlNotifier_callbacks[endpoint->callback]); - QQmlNotifier_callbacks[endpoint->callback](endpoint, a); + Q_ASSERT(QQmlNotifier_callbacks[data.endpoint->callback]); + QQmlNotifier_callbacks[data.endpoint->callback](data.endpoint, a); - if (disconnectWatch == &originalSenderPtr && originalSenderPtr) { - // End of notifying, restore values - endpoint->senderPtr = originalSenderPtr; + if (data.disconnectWatch == &data.originalSenderPtr && data.originalSenderPtr) { + // End of notifying, restore values + data.endpoint->senderPtr = data.originalSenderPtr; + } } } } diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index 2a35dcda12..2742bfc84b 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -60,6 +60,8 @@ private: class QQmlEngine; class QQmlNotifierEndpoint { + QQmlNotifierEndpoint *next; + QQmlNotifierEndpoint **prev; public: inline QQmlNotifierEndpoint(); inline ~QQmlNotifierEndpoint(); @@ -103,9 +105,6 @@ private: // The index is in the range returned by QObjectPrivate::signalIndex(). // This is different from QMetaMethod::methodIndex(). signed int sourceSignal:28; - - QQmlNotifierEndpoint *next; - QQmlNotifierEndpoint **prev; }; QQmlNotifier::QQmlNotifier() @@ -137,7 +136,7 @@ void QQmlNotifier::notify() } QQmlNotifierEndpoint::QQmlNotifierEndpoint() -: senderPtr(0), callback(None), sourceSignal(-1), next(0), prev(0) +: next(0), prev(0), senderPtr(0), callback(None), sourceSignal(-1) { } -- cgit v1.2.3 From 38a9e94e0ee5ca8bf163fd3ed8d5d6e7fda31252 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Tue, 7 Jul 2015 23:08:30 +0900 Subject: add null check for qmlRegisterSingletonType() When the callback passed to the function returns nullptr, QQmlData::ensurePropertyCache(e, o) crashes. Change-Id: I11efd7e9d6c5f18611e796d896384dd14a280303 Reviewed-by: Michael Brasser Reviewed-by: Christopher Adams Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlmetatype.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 41d44a821a..cb8c2bd3b5 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -225,6 +225,9 @@ void QQmlType::SingletonInstanceInfo::init(QQmlEngine *e) v4->pushGlobalContext(); QObject *o = qobjectCallback(e, e); setQObjectApi(e, o); + if (!o) { + qFatal("qmlRegisterSingletonType(): \"%s\" is not available because the callback function returns a null pointer.", qPrintable(typeName)); + } // if this object can use a property cache, create it now QQmlData::ensurePropertyCache(e, o); v4->popContext(); -- cgit v1.2.3 From 6d040b2f5e028dbe9efe066bb3f0cf96ad46dcdb Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Sat, 25 Jul 2015 09:50:19 +0300 Subject: Instantiator: fix typo in docs The method is objectAt(), not itemAt(). Change-Id: Ie37636a6f9a641edfe3ec2b47def8806b9b10aa8 Reviewed-by: Martin Smith --- src/qml/types/qqmlinstantiator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/types/qqmlinstantiator.cpp b/src/qml/types/qqmlinstantiator.cpp index 7626ba5a05..735463a058 100644 --- a/src/qml/types/qqmlinstantiator.cpp +++ b/src/qml/types/qqmlinstantiator.cpp @@ -321,7 +321,7 @@ int QQmlInstantiator::count() const Note that an extra variable, index, will be available inside instances of the delegate. This variable refers to the index of the instance inside the Instantiator, - and can be used to obtain the object through the itemAt method of the Instantiator. + and can be used to obtain the object through the objectAt method of the Instantiator. If this property is changed, all instances using the old delegate will be destroyed and new instances will be created using the new delegate. -- cgit v1.2.3 From 4f7d58c9eb3e6bdf5b7e1d3737066fc0b60d8196 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 27 Jul 2015 12:57:19 +0200 Subject: Fix typo in QSGGeometryNode documentation. Change-Id: I0138aa116abdf890060e868fb95e866db1c7a398 Reviewed-by: Venugopal Shivashankar --- src/quick/scenegraph/coreapi/qsgnode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 71f4f62db9..51f3976ed9 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -806,7 +806,7 @@ void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry) the vertices and their structure, to be drawn. The Material defines how the shape is filled. - The following is a code snipped illustrating how to create a red + The following is a code snippet illustrating how to create a red line using a QSGGeometryNode: \code QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 2); -- cgit v1.2.3 From 60007e4a9db9ead75a533ca6bff369716fe70dda Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 30 Oct 2014 22:58:18 -0700 Subject: Use the new macros for disabling warnings in qtdeclarative Change-Id: I476da50ba23598c7ca98651477fb701f74053b82 Reviewed-by: Jake Petroules --- src/qml/jsruntime/qv4numberobject.cpp | 10 +++------- src/qml/jsruntime/qv4qobjectwrapper.cpp | 7 +------ src/qml/qml/qqml.h | 10 +++------- 3 files changed, 7 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 89ff110b20..4a1a94e872 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -75,14 +75,10 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor) ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf())); ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308)); -#ifdef __INTEL_COMPILER -# pragma warning( push ) -# pragma warning(disable: 239) -#endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_INTEL(239) ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Primitive::fromDouble(5e-324)); -#ifdef __INTEL_COMPILER -# pragma warning( pop ) -#endif +QT_WARNING_POP defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString, method_toString); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 1e4718c208..0a1aa56aab 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -70,14 +70,9 @@ QT_BEGIN_NAMESPACE -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) -# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 // The code in this file does not violate strict aliasing, but GCC thinks it does // so turn off the warnings for us to have a clean build -# pragma GCC diagnostic ignored "-Wstrict-aliasing" -# endif -#endif - +QT_WARNING_DISABLE_GCC("-Wstrict-aliasing") using namespace QV4; diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index d6fd7b96f6..23cb69e2f1 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -502,17 +502,13 @@ namespace QtQml { } #endif -#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wheader-hygiene" -#endif +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wheader-hygiene") // This is necessary to allow for QtQuick1 and QtQuick2 scenes in a single application. using namespace QtQml; -#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) -#pragma clang diagnostic pop -#endif +QT_WARNING_POP //The C++ version of protected namespaces in qmldir Q_QML_EXPORT bool qmlProtectModule(const char* uri, int majVersion); -- cgit v1.2.3 From f446a79410b81067c982dc48563e2acccded1247 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 31 Jul 2015 00:30:00 -0700 Subject: Work around ICC 16 beta compiler bug in SFINAE expansion Calling std::vector's constructor (or assign()) with two ints can select one of two different overloads: the (size_t, value_type) overload which fills with n copies of the value or (iterator, iterator) overload, which would copy a range. libstdc++ had some workarounds for this scenario, by using an indirect dispatch to determine whether it was a pair of integrals or not. But ever since the resolution of DR1234 (https://gcc.gnu.org/bugzilla/ show_bug.cgi?id=43813) with C++11's more expressive SFINAE, the dispatching is done actually by the outer template by adding an extra template parameter that requires std::iterator_traite to expand. That's where ICC fails: it expands std::iterator_traits and that fails. It should have ignored the expansion and discarded that overload. The workaround is simple: pass different types as the parameters, which means the compiler cannot select the overload containing a pair of iterators. /usr/include/c++/5/bits/stl_iterator_base_types.h(154): error: name followed by "::" must be a class or namespace name typedef typename _Iterator::iterator_category iterator_category; ^ detected during: instantiation of class "std::__iterator_traits<_Iterator, void> [with _Iterator=int]" at line 163 instantiation of class "std::iterator_traits<_Iterator> [with _Iterator=int]" at line 876 of "compiler/qv4ssa.cpp" Change-Id: I52dd43c12685407bb9a6ffff13f5f783820213a5 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4ssa.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index e61a602e64..c0669d3e47 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -530,7 +530,7 @@ class DominatorTree const int bbCount = function->basicBlockCount(); d->vertex = std::vector(bbCount, InvalidBasicBlockIndex); d->parent = std::vector(bbCount, InvalidBasicBlockIndex); - d->dfnum = std::vector(bbCount, 0); + d->dfnum = std::vector(size_t(bbCount), 0); d->semi = std::vector(bbCount, InvalidBasicBlockIndex); d->ancestor = std::vector(bbCount, InvalidBasicBlockIndex); idom = std::vector(bbCount, InvalidBasicBlockIndex); @@ -873,7 +873,7 @@ private: // - set the current node's depth to that of immediate dominator + 1 std::vector calculateNodeDepths() const { - std::vector nodeDepths(function->basicBlockCount(), -1); + std::vector nodeDepths(size_t(function->basicBlockCount()), -1); nodeDepths[0] = 0; foreach (BasicBlock *bb, function->basicBlocks()) { if (bb->isRemoved()) -- cgit v1.2.3 From c318fceaccb1ee23a567f1bb032df45417217e09 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jul 2015 13:47:45 +0200 Subject: Fix disappearing selection spanning different scripts Due to the way itemization is currently done in Qt, Cyrillic text (and other writing systems) separated by spaces will become separate items because the spaces are itemized as Script_Common. In the Scenegraph's text node engine, we should merge these items into a single node as long as the same font is used for all the text. But a bug in the engine caused this to fail when the text was selected. The symptom of this was that in some rare cases one of the items would vanish if it were in the middle of a selection. In order to support the bearing of selected text leaning outside the selection rect, I previously added a hack which would add all selected text as unselected text as well in b0783c21fb54b939f07ddf5658cc51113b8014e6. This was an awkward way of doing it and caused said regression. A less intrusive way is just to add the text to the scene graph twice, as this does not interfere with the logic needed to support selecting part of ligatures nor the engine's ability to merge nodes correctly. [ChangeLog][Text] Fixed regression with selections spanning different scripts. Task-number: QTBUG-46829 Change-Id: I0faed76fb2cd1ac0b2e5cc54b81008b5e2550733 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnodeengine.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 7903f79e89..5140ccb68f 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -596,7 +596,6 @@ void QQuickTextNodeEngine::addGlyphsInRange(int rangeStart, int rangeLength, for (int j=0; jaddRectangleNode(rect, color); } - // Add all unselected text first + // Add all text with unselected color first for (int i = 0; i < nodes.size(); ++i) { const BinaryTreeNode *node = nodes.at(i); - if (node->selectionState == Unselected) - parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, 0); + parentNode->addGlyphs(node->position, node->glyphRun, node->color, style, styleColor, 0); } for (int i = 0; i < imageNodes.size(); ++i) { -- cgit v1.2.3 From d218d8c8538e47cf32a06b4bdd9f60bd16a8cf50 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 29 Jul 2015 14:27:58 +0200 Subject: Fix selecting single character in middle of string The fix for QTBUG-46829 revealed a bug in the code to handle selecting part of ligatures. The ranges were assumed to be [start, end], while they are in fact [start, end>. This would cause the engine to assume the previous node overlapped completely with the selected node and that the node had thus already been added to the graph. Due to the bug in QTBUG-46829, this accidentally worked before, but when that bug was fixed, this bug appeared. Change-Id: I517d260de9f58db4504dd4320b7113fbbe305a81 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnodeengine.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 5140ccb68f..efe79b382e 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -821,14 +821,14 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int i = 0; i < node->ranges.size(); ++i) { const QPair &range = node->ranges.at(i); - int rangeLength = range.second - range.first + 1; + int rangeLength = range.second - range.first; if (previousNode != 0) { for (int j = 0; j < previousNode->ranges.size(); ++j) { const QPair &otherRange = previousNode->ranges.at(j); - if (range.first <= otherRange.second && range.second >= otherRange.first) { + if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start + 1; + rangeLength -= end - start; if (rangeLength == 0) break; } @@ -839,10 +839,10 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int j = 0; j < nextNode->ranges.size(); ++j) { const QPair &otherRange = nextNode->ranges.at(j); - if (range.first <= otherRange.second && range.second >= otherRange.first) { + if (range.first < otherRange.second && range.second > otherRange.first) { int start = qMax(range.first, otherRange.first); int end = qMin(range.second, otherRange.second); - rangeLength -= end - start + 1; + rangeLength -= end - start; if (rangeLength == 0) break; } -- cgit v1.2.3 From 97202b4eedb08b38633cec4060fb6f6c6a6381f2 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 3 Aug 2015 13:03:36 +0200 Subject: Fix typo in plugin documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5cd851e493b6663bd0a7d09a1c5435c37a4ad7d6 Reviewed-by: Topi Reiniƶ --- src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc b/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc index 79bd3df9d9..90e432a8ef 100644 --- a/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc +++ b/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc @@ -32,7 +32,7 @@ \section1 Creating a Plugin - The \l{QQmlEngine}{QML engine} load C++ plugins for QML. + The \l{QQmlEngine}{QML engine} loads C++ plugins for QML. Such plugins are usually provided in a QML extension module, and can provide types for use by clients in QML documents which import the module. A module requires at least one type registered in order to be considered -- cgit v1.2.3 From 16b716dc9f943313b5f75e0a9a374d496ffda1b8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 3 Aug 2015 13:37:28 +0200 Subject: Consolidate duplicated QQmlExtensionPlugin documentation. There have already been doc improvements made to one of the duplicated pieces and not the other. This patch uses the improved one. Change-Id: I12a6cb013e61f63e67fb9d691ee58ba12e21054d Reviewed-by: Venugopal Shivashankar --- .../doc/src/qmllanguageref/modules/cppplugins.qdoc | 85 +--------------------- .../modules/qqmlextensionplugin.qdocinc | 83 +++++++++++++++++++++ src/qml/qml/qqmlextensionplugin.cpp | 66 +---------------- 3 files changed, 85 insertions(+), 149 deletions(-) create mode 100644 src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc (limited to 'src') diff --git a/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc b/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc index 90e432a8ef..a2397b6cfb 100644 --- a/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc +++ b/src/qml/doc/src/qmllanguageref/modules/cppplugins.qdoc @@ -38,90 +38,7 @@ A module requires at least one type registered in order to be considered valid. - QQmlExtensionPlugin is a plugin interface that makes it possible to - create QML extensions that can be loaded dynamically into QML applications. - These extensions allow custom QML types to be made available to the - QML engine. - - To write a QML extension plugin: - \list 1 - \li Subclass QQmlExtensionPlugin - \list - \li Use the Q_PLUGIN_METADATA() macro to register the plugin with - the Qt meta object system - \li Override the \l{QQmlExtensionPlugin::}{registerTypes()} method - and call qmlRegisterType() to register the types to be exported - by the plugin - \endlist - \li Write a project file for the plugin - \li Create a \l{Module Definition qmldir Files}{qmldir file} to - describe the plugin - \endlist - - QML extension plugins are for either application-specific or library-like - plugins. Library plugins should limit themselves to registering types, as - any manipulation of the engine's root context may cause conflicts or other - issues in the library user's code. - -\section1 Plugin Example - - Suppose there is a new \c TimeModel C++ class that should be made available - as a new QML type. It provides the current time through \c hour and \c minute - properties. - - \snippet qmlextensionplugins/plugin.cpp 0 - \dots - - To make this type available, we create a plugin class named \c QExampleQmlPlugin - which is a subclass of \l QQmlExtensionPlugin. It overrides the - \l{QQmlExtensionPlugin::}{registerTypes()} method in order to register the \c TimeModel - type using qmlRegisterType(). It also uses the Q_PLUGIN_METADATA() macro in the class - definition to register the plugin with the Qt meta object system using a unique - identifier for the plugin. - - \snippet qmlextensionplugins/plugin.cpp plugin - - The \c TimeModel class receives a \c{1.0} version of this plugin library, as - a QML type called \c Time. The Q_ASSERT() macro can ensure the type namespace is - imported correctly by any QML components that use this plugin. The - \l{Defining QML Types from C++} article has more information about registering C++ - types into the runtime. - - For this example, the TimeExample source directory is in - \c{imports/TimeExample}. The plugin's type namespace will mirror - this structure, so the types are registered into the namespace - "TimeExample". - - Additionally, the project file, in a \c .pro file, defines the project as a plugin library, - specifies it should be built into the \c imports/TimeExample directory, and registers - the plugin target name and various other details: - - \code - TEMPLATE = lib - CONFIG += qt plugin - QT += qml - - DESTDIR = imports/TimeExample - TARGET = qmlqtimeexampleplugin - SOURCES += qexampleqmlplugin.cpp - \endcode - - Finally, a \l{Module Definition qmldir Files}{qmldir file} is required - in the \c imports/TimeExample directory to describe the plugin and the types that it - exports. The plugin includes a \c Clock.qml file along with the \c qmlqtimeexampleplugin - that is built by the project (as shown above in the \c .pro file) so both of these - need to be specified in the \c qmldir file: - - \quotefile qmlextensionplugins/imports/TimeExample/qmldir - - Once the project is built and installed, the new \c Time component is - accessible by any QML component that imports the \c TimeExample - module - - \snippet qmlextensionplugins/plugins.qml 0 - - The full source code is available in the \l {qmlextensionplugins}{plugins example}. - + \include qqmlextensionplugin.qdocinc \section1 Reference diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc new file mode 100644 index 0000000000..9bb863a90b --- /dev/null +++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc @@ -0,0 +1,83 @@ +QQmlExtensionPlugin is a plugin interface that makes it possible to +create QML extensions that can be loaded dynamically into QML applications. +These extensions allow custom QML types to be made available to the +QML engine. + +To write a QML extension plugin: +\list 1 +\li Subclass QQmlExtensionPlugin + \list + \li Use the Q_PLUGIN_METADATA() macro to register the plugin with + the Qt meta object system + \li Override the \l{QQmlExtensionPlugin::}{registerTypes()} method + and call qmlRegisterType() to register the types to be exported + by the plugin + \endlist +\li Write a project file for the plugin +\li Create a \l{Module Definition qmldir Files}{qmldir file} to + describe the plugin +\endlist + +QML extension plugins are for either application-specific or library-like +plugins. Library plugins should limit themselves to registering types, as +any manipulation of the engine's root context may cause conflicts or other +issues in the library user's code. + +\section1 Plugin Example + +Suppose there is a new \c TimeModel C++ class that should be made available +as a new QML type. It provides the current time through \c hour and \c minute +properties. + +\snippet qmlextensionplugins/plugin.cpp 0 +\dots + +To make this type available, we create a plugin class named \c QExampleQmlPlugin +which is a subclass of \l QQmlExtensionPlugin. It overrides the +\l{QQmlExtensionPlugin::}{registerTypes()} method in order to register the \c TimeModel +type using qmlRegisterType(). It also uses the Q_PLUGIN_METADATA() macro in the class +definition to register the plugin with the Qt meta object system using a unique +identifier for the plugin. + +\snippet qmlextensionplugins/plugin.cpp plugin + +The \c TimeModel class receives a \c{1.0} version of this plugin library, as +a QML type called \c Time. The Q_ASSERT() macro can ensure the type namespace is +imported correctly by any QML components that use this plugin. The +\l{Defining QML Types from C++} article has more information about registering C++ +types into the runtime. + +For this example, the TimeExample source directory is in +\c{imports/TimeExample}. The plugin's type namespace will mirror +this structure, so the types are registered into the namespace +"TimeExample". + +Additionally, the project file, in a \c .pro file, defines the project as a plugin library, +specifies it should be built into the \c imports/TimeExample directory, and registers +the plugin target name and various other details: + +\code +TEMPLATE = lib +CONFIG += qt plugin +QT += qml + +DESTDIR = imports/TimeExample +TARGET = qmlqtimeexampleplugin +SOURCES += qexampleqmlplugin.cpp +\endcode + +Finally, a \l{Module Definition qmldir Files}{qmldir file} is required +in the \c imports/TimeExample directory to describe the plugin and the types that it +exports. The plugin includes a \c Clock.qml file along with the \c qmlqtimeexampleplugin +that is built by the project (as shown above in the \c .pro file) so both of these +need to be specified in the \c qmldir file: + +\quotefile qmlextensionplugins/imports/TimeExample/qmldir + +Once the project is built and installed, the new \c Time component is +accessible by any QML component that imports the \c TimeExample +module + +\snippet qmlextensionplugins/plugins.qml 0 + +The full source code is available in the \l {qmlextensionplugins}{plugins example}. diff --git a/src/qml/qml/qqmlextensionplugin.cpp b/src/qml/qml/qqmlextensionplugin.cpp index 7b560268ba..d86fbc5999 100644 --- a/src/qml/qml/qqmlextensionplugin.cpp +++ b/src/qml/qml/qqmlextensionplugin.cpp @@ -44,71 +44,7 @@ QT_BEGIN_NAMESPACE \ingroup plugins - QQmlExtensionPlugin is a plugin interface that makes it possible to - create QML extensions that can be loaded dynamically into QML applications. - These extensions allow custom QML types to be made available to the QML engine. - - To write a QML extension plugin: - - \list - \li Subclass QQmlExtensionPlugin, implement registerTypes() method to register types - using qmlRegisterType(), and export the class using the Q_PLUGIN_METADATA() macro - \li Write an appropriate project file for the plugin - \li Create a \l{Module Definition qmldir Files}{qmldir file} to describe the plugin - \endlist - - QML extension plugins can be used to provide either application-specific or - library-like plugins. Library plugins should limit themselves to registering types, - as any manipulation of the engine's root context may cause conflicts - or other issues in the library user's code. - - - \section1 An Example - - Suppose there is a new \c TimeModel C++ class that should be made available - as a new QML element. It provides the current time through \c hour and \c minute - properties, like this: - - \snippet qmlextensionplugins/plugin.cpp 0 - \dots - - To make this class available as a QML type, create a plugin that registers - this type with a specific \l {QML Modules}{module} using qmlRegisterType(). For this example the plugin - module will be named \c TimeExample (as defined in the project - file further below). - - \snippet qmlextensionplugins/plugin.cpp plugin - - This registers the \c TimeModel class with the 1.0 version of this - plugin library, as a QML type called \c Time. The Q_ASSERT statement - ensures the module is imported correctly by any QML components that use this plugin. - - The project file defines the project as a plugin library and specifies - it should be built into the \c imports/TimeExample directory: - - \code - TEMPLATE = lib - CONFIG += qt plugin - QT += qml - - DESTDIR = imports/TimeExample - TARGET = qmlqtimeexampleplugin - ... - \endcode - - Finally, a \l{Module Definition qmldir Files}{qmldir file} is required in the \c imports/TimeExample directory - that describes the plugin. This directory includes a \c Clock.qml file that - should be bundled with the plugin, so it needs to be specified in the \c qmldir - file: - - \quotefile qmlextensionplugins/imports/TimeExample/qmldir - - Once the project is built and installed, the new \c Time element can be - used by any QML component that imports the \c TimeExample module: - - \snippet qmlextensionplugins/plugins.qml 0 - - The full source code is available in the \l {qmlextensionplugins}{plugins example}. + \include qqmlextensionplugin.qdocinc The \l {Writing QML Extensions with C++} tutorial also contains a chapter on creating QML plugins. -- cgit v1.2.3 From 3efe416da236828010a446f415583a9777e4712d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 3 Aug 2015 13:44:10 +0200 Subject: Rephrase sentence about versioning in QQmlExtensionPlugin documentation The original sentence (885735d0) is better than the new one (2c4c7a38). Some small adjustments were made in this patch as well. Change-Id: I2cc62c2ffcde7df289b07486439456350a2f60ab Reviewed-by: Venugopal Shivashankar --- src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc index 9bb863a90b..2274617f77 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc +++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc @@ -41,7 +41,7 @@ identifier for the plugin. \snippet qmlextensionplugins/plugin.cpp plugin -The \c TimeModel class receives a \c{1.0} version of this plugin library, as +This registers the \c TimeModel class with version \c{1.0} of this plugin library, as a QML type called \c Time. The Q_ASSERT() macro can ensure the type namespace is imported correctly by any QML components that use this plugin. The \l{Defining QML Types from C++} article has more information about registering C++ -- cgit v1.2.3 From d296ebfe6585010a38db0e3043ef5ceaa6a30883 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 28 Jul 2015 13:00:48 +0200 Subject: Fix selections in tables that span over several cells In the code that converts text layouts to subtrees in the scene graph specifically for TextEdit, there was a cutoff to treat text tables as single nodes in the graph (for simplicity). However, this breaks selections, since the ranges spanned by each cell will be interpreted as overlapping, messing up the selection merging logic. We need the same approach here as for any other text frame where we check frame boundaries. [ChangeLog][TextEdit] Fixed issues with selections that spanned several cells in a table. Change-Id: I789041d84b5d163e209488f8f2f1f83a6471389f Task-number: QTBUG-46928 Reviewed-by: Pierre Rossi --- src/quick/items/qquicktextedit.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 8237ad10e4..cd1cf5eef1 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -1873,13 +1873,6 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * node->m_engine->addTextObject(QPointF(0, 0), format, QQuickTextNodeEngine::Unselected, d->document, pos, textFrame->frameFormat().position()); nodeStart = pos; - } else if (qobject_cast(textFrame)) { // To keep things simple, map text tables as one text node - QTextFrame::iterator it = textFrame->begin(); - nodeOffset = d->document->documentLayout()->frameBoundingRect(textFrame).topLeft(); - updateNodeTransform(node, nodeOffset); - while (!it.atEnd()) - node->m_engine->addTextBlock(d->document, (it++).currentBlock(), -nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1); - nodeStart = textFrame->firstPosition(); } else { // Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that. QList frameBoundaries; -- cgit v1.2.3 From 372804f1f64918e281a29cd2f849f7e1b1488eee Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 30 Jul 2015 12:33:32 +0200 Subject: Doc: added documentation to undocumented methods Task-number: QTBUG-36985 Change-Id: Idc6f7961f4f02f66dc3d4a8e5d09dd15d43b7757 Reviewed-by: Venugopal Shivashankar --- src/qml/qml/qqmlabstracturlinterceptor.cpp | 2 +- src/qml/qml/qqmlengine.cpp | 15 +++++++++++++++ src/qml/qml/qqmlfileselector.cpp | 3 +++ src/quick/items/qquickframebufferobject.cpp | 9 +++++++++ src/quick/items/qquickitem.cpp | 25 ++++++++++++++++++++++++- src/quick/items/qquickpainteditem.cpp | 9 +++++++++ src/quick/items/qquickrendercontrol.cpp | 4 ++++ 7 files changed, 65 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qml/qml/qqmlabstracturlinterceptor.cpp b/src/qml/qml/qqmlabstracturlinterceptor.cpp index e64b33b181..cb57bc2146 100644 --- a/src/qml/qml/qqmlabstracturlinterceptor.cpp +++ b/src/qml/qml/qqmlabstracturlinterceptor.cpp @@ -58,7 +58,7 @@ To implement support for a custom networked scheme, see setNetworkAccessManagerFactory. */ -/* +/*! \enum QQmlAbstractUrlInterceptor::DataType Specifies where URL interception is taking place. diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 392cbe9371..ffc890a2cf 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -260,6 +260,18 @@ void QQmlEnginePrivate::activateDesignerMode() on producing the image without blocking the main thread. */ +/*! + \fn QQmlImageProviderBase::imageType() const + + Implement this method to return the image type supported by this image provider. +*/ + +/*! + \fn QQmlImageProviderBase::flags() const + + Implement this to return the properties of this image provider. +*/ + /*! \internal */ QQmlImageProviderBase::QQmlImageProviderBase() { @@ -1354,6 +1366,9 @@ QQmlEngine::ObjectOwnership QQmlEngine::objectOwnership(QObject *object) return ddata->indestructible?CppOwnership:JavaScriptOwnership; } +/*! + \reimp +*/ bool QQmlEngine::event(QEvent *e) { Q_D(QQmlEngine); diff --git a/src/qml/qml/qqmlfileselector.cpp b/src/qml/qml/qqmlfileselector.cpp index 3ee7bb3040..8597e8a5c7 100644 --- a/src/qml/qml/qqmlfileselector.cpp +++ b/src/qml/qml/qqmlfileselector.cpp @@ -102,6 +102,9 @@ QQmlFileSelector::QQmlFileSelector(QQmlEngine* engine, QObject* parent) d->engine->setUrlInterceptor(d->myInstance.data()); } +/*! + Destroys the QQmlFileSelector object. +*/ QQmlFileSelector::~QQmlFileSelector() { Q_D(QQmlFileSelector); diff --git a/src/quick/items/qquickframebufferobject.cpp b/src/quick/items/qquickframebufferobject.cpp index c3e5b97baf..6031315b90 100644 --- a/src/quick/items/qquickframebufferobject.cpp +++ b/src/quick/items/qquickframebufferobject.cpp @@ -298,11 +298,17 @@ QSGNode *QQuickFramebufferObject::updatePaintNode(QSGNode *node, UpdatePaintNode return n; } +/*! + \reimp +*/ bool QQuickFramebufferObject::isTextureProvider() const { return true; } +/*! + \reimp +*/ QSGTextureProvider *QQuickFramebufferObject::textureProvider() const { Q_D(const QQuickFramebufferObject); @@ -316,6 +322,9 @@ QSGTextureProvider *QQuickFramebufferObject::textureProvider() const return d->node; } +/*! + \reimp +*/ void QQuickFramebufferObject::releaseResources() { // When release resources is called on the GUI thread, we only need to diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 3d0f550d14..5fd1882216 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -4237,7 +4237,6 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const /*! \qmlmethod QtQuick::Item::forceActiveFocus() - \overload Forces active focus on the item. @@ -4250,6 +4249,18 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const \sa activeFocus */ +/*! + Forces active focus on the item. + + This method sets focus on the item and ensures that all ancestor + FocusScope objects in the object hierarchy are also given \l focus. + + The reason for the focus change will be \l [CPP] Qt::OtherFocusReason. Use + the overloaded method to specify the focus reason to enable better + handling of the focus change. + + \sa activeFocus +*/ void QQuickItem::forceActiveFocus() { forceActiveFocus(Qt::OtherFocusReason); @@ -4257,7 +4268,19 @@ void QQuickItem::forceActiveFocus() /*! \qmlmethod QtQuick::Item::forceActiveFocus(Qt::FocusReason reason) + \overload + + Forces active focus on the item with the given \a reason. + + This method sets focus on the item and ensures that all ancestor + FocusScope objects in the object hierarchy are also given \l focus. + \since 5.1 + + \sa activeFocus, Qt::FocusReason +*/ +/*! + \overload Forces active focus on the item with the given \a reason. This method sets focus on the item and ensures that all ancestor diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp index b3e4906c41..8d93c577ab 100644 --- a/src/quick/items/qquickpainteditem.cpp +++ b/src/quick/items/qquickpainteditem.cpp @@ -549,6 +549,9 @@ QSGNode *QQuickPaintedItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDat return node; } +/*! + \reimp +*/ void QQuickPaintedItem::releaseResources() { Q_D(QQuickPaintedItem); @@ -567,11 +570,17 @@ void QQuickPaintedItem::invalidateSceneGraph() d->node = 0; // Managed by the scene graph, just clear the pointer } +/*! + \reimp +*/ bool QQuickPaintedItem::isTextureProvider() const { return true; } +/*! + \reimp +*/ QSGTextureProvider *QQuickPaintedItem::textureProvider() const { Q_D(const QQuickPaintedItem); diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index fd4787be98..6b0b9c3a06 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -141,6 +141,10 @@ void QQuickRenderControlPrivate::cleanup() sg = 0; } +/*! + Constructs a QQuickRenderControl object, with parent + object \a parent. +*/ QQuickRenderControl::QQuickRenderControl(QObject *parent) : QObject(*(new QQuickRenderControlPrivate), parent) { -- cgit v1.2.3 From 98ff203205ec77a3f4afbbe0ca3e34afb90274bd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 5 Aug 2015 10:47:38 +0200 Subject: Make QQmlExtensionPlugin documentation clearer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I spent too long wondering why my plugin wasn't being loaded, until I realized that the directory I was installing the qmldir into was not named the same as the module. This is already documented in the "Module Definition qmldir Files" documentation: http://doc.qt.io/qt-5/qtqml-modules-qmldir.html#contents-of-a-module-definition-qmldir-file But as I was writing a plugin, I was following this documentation: http://doc.qt.io/qt-5/qtqml-modules-cppplugins.html Where it was not at all obvious that they should be named the same. Change-Id: I3e20bc31f8b42c7141b4c22c8cb1750ba9782971 Reviewed-by: Topi Reiniƶ --- .../modules/qqmlextensionplugin.qdocinc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc index 2274617f77..7c1d65b095 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc +++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc @@ -47,12 +47,7 @@ imported correctly by any QML components that use this plugin. The \l{Defining QML Types from C++} article has more information about registering C++ types into the runtime. -For this example, the TimeExample source directory is in -\c{imports/TimeExample}. The plugin's type namespace will mirror -this structure, so the types are registered into the namespace -"TimeExample". - -Additionally, the project file, in a \c .pro file, defines the project as a plugin library, +Additionally, the project file (\c .pro) defines the project as a plugin library, specifies it should be built into the \c imports/TimeExample directory, and registers the plugin target name and various other details: @@ -74,6 +69,18 @@ need to be specified in the \c qmldir file: \quotefile qmlextensionplugins/imports/TimeExample/qmldir +To make things easier for this example, the TimeExample source directory is in +\c{imports/TimeExample}, and we build +\l{Source, Build, and Install Directories}{in-source}. However, the structure +of the source directory is not so important, as the \c qmldir file can specify +paths to installed QML files. + +What is important is the name of the directory that the qmldir is installed +into. When the user imports our module, the QML engine uses the +\l{Contents of a Module Definition qmldir File}{module identifier} +(\c TimeExample) to find the plugin, and so the directory in which it is +installed must match the module identifier. + Once the project is built and installed, the new \c Time component is accessible by any QML component that imports the \c TimeExample module -- cgit v1.2.3 From 42054d0b6c3b906ba7b3815974c9d7738b49a9ea Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 11 Aug 2015 12:49:10 +0200 Subject: Fix incorrectly formatted code in QQmlEngine documentation. Change-Id: I70832871cbd697b77cfcbbe425ba5936be1c01d5 Reviewed-by: Venugopal Shivashankar --- src/qml/doc/src/qmlfunctions.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 25bb0d6068..4203cca8b3 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -470,8 +470,8 @@ as any other item). Usage: - // First, define your QML singleton type which provides the functionality. \qml + // First, define your QML singleton type which provides the functionality. pragma Singleton import QtQuick 2.0 Item { -- cgit v1.2.3 From 5762738fce7306120c1d93da84ef9c2693d95881 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Tue, 11 Aug 2015 17:55:00 +0200 Subject: Fix crash in QQuickCanvasItem::updatePaintNode() QQuickCanvasItem manages the life time of the texture already, so it shouldn't set the ownsTexture flag on the QSGSimpleTextureNode, because that would result in a double deletion when QSGSimpleTextureNode::setTexture() is called. Change-Id: I7c1cc949b664d1a8b64bab092250439171e66233 Task-number: QTBUG-47714 Reviewed-by: Gunnar Sletta --- src/quick/items/context2d/qquickcanvasitem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index cb694c499a..75507c68d2 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -57,7 +57,11 @@ class QQuickCanvasNode : public QSGSimpleTextureNode public: QQuickCanvasNode() { qsgnode_set_description(this, QStringLiteral("canvasnode")); - setOwnsTexture(true); + setOwnsTexture(false); + } + + ~QQuickCanvasNode() { + delete texture(); } }; -- cgit v1.2.3 From 4336566e48e7853bcf91d768c70d20db5de9e174 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 11 Aug 2015 18:33:01 +0200 Subject: Support QSGGeometry::lineWidth also in the batched code path. Change-Id: Ifc664b9c718744b9549953e42ac3450a88403dea Task-number: QTBUG-47090 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 43 +++++++++++++---------- src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 63938d50a9..42b9f526d0 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -1518,6 +1518,7 @@ void Renderer::prepareOpaqueBatches() if (gni->clipList() == gnj->clipList() && gni->geometry()->drawingMode() == gnj->geometry()->drawingMode() + && (gni->geometry()->drawingMode() != GL_LINES || gni->geometry()->lineWidth() == gnj->geometry()->lineWidth()) && gni->geometry()->attributes() == gnj->geometry()->attributes() && gni->inheritedOpacity() == gnj->inheritedOpacity() && gni->activeMaterial()->type() == gnj->activeMaterial()->type() @@ -1616,6 +1617,7 @@ void Renderer::prepareAlphaBatches() if (gni->clipList() == gnj->clipList() && gni->geometry()->drawingMode() == gnj->geometry()->drawingMode() + && (gni->geometry()->drawingMode() != GL_LINES || gni->geometry()->lineWidth() == gnj->geometry()->lineWidth()) && gni->geometry()->attributes() == gnj->geometry()->attributes() && gni->inheritedOpacity() == gnj->inheritedOpacity() && gni->activeMaterial()->type() == gnj->activeMaterial()->type() @@ -2278,6 +2280,7 @@ void Renderer::renderMergedBatch(const Batch *batch) m_currentMaterial = material; QSGGeometry* g = gn->geometry(); + updateLineWidth(g); char const *const *attrNames = program->attributeNames(); for (int i=0; idrawSets.size(); ++i) { const DrawSet &draw = batch->drawSets.at(i); @@ -2408,24 +2411,7 @@ void Renderer::renderUnmergedBatch(const Batch *batch) offset += a.tupleSize * size_of_type(a.type); } - if (g->drawingMode() == GL_LINE_STRIP || g->drawingMode() == GL_LINE_LOOP || g->drawingMode() == GL_LINES) - glLineWidth(g->lineWidth()); -#if !defined(QT_OPENGL_ES_2) - else if (!QOpenGLContext::currentContext()->isOpenGLES() && g->drawingMode() == GL_POINTS) { - QOpenGLFunctions_1_0 *gl1funcs = 0; - QOpenGLFunctions_3_2_Core *gl3funcs = 0; - if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) - gl3funcs = QOpenGLContext::currentContext()->versionFunctions(); - else - gl1funcs = QOpenGLContext::currentContext()->versionFunctions(); - Q_ASSERT(gl1funcs || gl3funcs); - if (gl1funcs) - gl1funcs->glPointSize(g->lineWidth()); - else - gl3funcs->glPointSize(g->lineWidth()); - } -#endif - + updateLineWidth(g); if (g->indexCount()) glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), iOffset); else @@ -2441,6 +2427,27 @@ void Renderer::renderUnmergedBatch(const Batch *batch) } } +void Renderer::updateLineWidth(QSGGeometry *g) +{ + if (g->drawingMode() == GL_LINE_STRIP || g->drawingMode() == GL_LINE_LOOP || g->drawingMode() == GL_LINES) + glLineWidth(g->lineWidth()); +#if !defined(QT_OPENGL_ES_2) + else if (!QOpenGLContext::currentContext()->isOpenGLES() && g->drawingMode() == GL_POINTS) { + QOpenGLFunctions_1_0 *gl1funcs = 0; + QOpenGLFunctions_3_2_Core *gl3funcs = 0; + if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) + gl3funcs = QOpenGLContext::currentContext()->versionFunctions(); + else + gl1funcs = QOpenGLContext::currentContext()->versionFunctions(); + Q_ASSERT(gl1funcs || gl3funcs); + if (gl1funcs) + gl1funcs->glPointSize(g->lineWidth()); + else + gl3funcs->glPointSize(g->lineWidth()); + } +#endif +} + void Renderer::renderBatches() { if (Q_UNLIKELY(debug_render())) { diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index f87dd75c8c..6b494dbaeb 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -591,6 +591,7 @@ private: void nodeWasRemoved(Node *node); void nodeWasAdded(QSGNode *node, Node *shadowParent); BatchRootInfo *batchRootInfo(Node *node); + void updateLineWidth(QSGGeometry *g); inline Batch *newBatch(); void invalidateAndRecycleBatch(Batch *b); -- cgit v1.2.3 From 521ace713d8e5230d47f3da8cd941699ca085af2 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 14 Aug 2015 11:02:28 +0200 Subject: Fix casing in Models and Views documentation. Change-Id: I461c5a55e3dbb2dc713640ec4d7aa00397a4415d Reviewed-by: Venugopal Shivashankar --- src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc index 4e894e5a33..e03b3a9bf8 100644 --- a/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc +++ b/src/quick/doc/src/concepts/modelviewsdata/modelview.qdoc @@ -187,7 +187,7 @@ To visualize data, bind the view's \c model property to a model and the QML provides several types of data models among the built-in set of QML types. In addition, models can be created with Qt C++ and then made - available to the \l{QQmlEngine}{QMLEngine} for use by + available to \l{QQmlEngine} for use by QML components. For information about creating these models, visit the \l{Using C++ Models with Qt Quick Views} and \l{qtqml-typesystem-topic.html#qml-object-types} -- cgit v1.2.3