From a5febdbba3807e1eb8fff0b0c3bae657d3e906e7 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 9 Jun 2016 10:24:54 +0200 Subject: QmlIncubator: correct documentation snippet about waiting for Ready It makes more sense to process events until the incubator is Ready rather than while it's already Ready. Change-Id: If8b0c5057dd88ffdbb2dd39f53b5b9676d0b9d19 Reviewed-by: Paolo Angelelli Reviewed-by: Matthew Vogt --- src/qml/qml/qqmlincubator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index a568ae440c..e65760a09f 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -434,7 +434,7 @@ example shows a simple use of QQmlIncubator. QQmlIncubator incubator; component->create(incubator); -while (incubator.isReady()) { +while (!incubator.isReady()) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); } -- cgit v1.2.3 From 56d9505e9d2b7dd9507523693d81f72efaa247c8 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Fri, 10 Jun 2016 21:13:12 +0200 Subject: Blacklist qmltest::ListView::test_listInteractiveCurrentIndexEnforce() Task-number: QTBUG-54028 Change-Id: I03390ebfb99927851926c0099fb79581f7b9e7a3 Reviewed-by: Liang Qi --- tests/auto/qmltest/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qmltest/BLACKLIST b/tests/auto/qmltest/BLACKLIST index 490e20d5f8..628290f2b4 100644 --- a/tests/auto/qmltest/BLACKLIST +++ b/tests/auto/qmltest/BLACKLIST @@ -5,6 +5,8 @@ * [tst_grabImage::test_equals] linux +[ListView::test_listInteractiveCurrentIndexEnforce] +linux [Text::test_linecount] osx windows -- cgit v1.2.3 From 2ac19881f92c94f4e9427bd9ff513210675f259e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 8 Jun 2016 17:32:32 +0200 Subject: QML: Only release types if they aren't referenced anymore Just checking for references on m_compiledData is not enough. The actual component can also be referenced. Thus it won't be deleted on release(), but cannot be found in the type cache anymore. Task-number: QTBUG-53761 Change-Id: I8567af8e75a078598e4fed31e4717134e1332278 Reviewed-by: Mitch Curtis Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypeloader.cpp | 3 ++- tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index c684c8602e..01200fd881 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1961,7 +1961,8 @@ void QQmlTypeLoader::trimCache() QList unneededTypes; for (TypeCache::Iterator iter = m_typeCache.begin(), end = m_typeCache.end(); iter != end; ++iter) { QQmlTypeData *typeData = iter.value(); - if (typeData->m_compiledData && typeData->m_compiledData->count() == 1) { + if (typeData->m_compiledData && typeData->count() == 1 + && typeData->m_compiledData->count() == 1) { // There are no live objects of this type unneededTypes.append(iter); } diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 7045c7cbd4..a1eaa0567f 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -86,10 +86,19 @@ void tst_QQMLTypeLoader::trimCache() url.setQuery(QString::number(i)); QQmlTypeData *data = loader.getType(url); - if (i % 5 == 0) // keep references to some of them so that they aren't trimmed - data->compiledData()->addref(); + // Run an event loop to receive the callback that release()es. + QTRY_COMPARE(data->count(), 2); - data->release(); + // keep references to some of them so that they aren't trimmed. References to either the + // QQmlTypeData or its compiledData() should prevent the trimming. + if (i % 10 == 0) { + // keep ref on data, don't add ref on data->compiledData() + } else if (i % 5 == 0) { + data->compiledData()->addref(); + data->release(); + } else { + data->release(); + } } for (int i = 0; i < 256; ++i) { -- cgit v1.2.3 From 4f94ddcf295c59dec86c8570c19e3e7427d68b06 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Fri, 10 Jun 2016 13:01:13 +0200 Subject: QAccessibleQuickItem: Add Q_DECL_OVERRIDE Fixes compilation with clang 3.8 Task-number: QTBUG-54009 Change-Id: Ib777bd56d187e3c94de0cda643dac47eb30d8215 Reviewed-by: Frederik Gladhorn --- src/quick/accessible/qaccessiblequickitem_p.h | 68 +++++++++++++-------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/quick/accessible/qaccessiblequickitem_p.h b/src/quick/accessible/qaccessiblequickitem_p.h index af9f8db249..4d36ff5697 100644 --- a/src/quick/accessible/qaccessiblequickitem_p.h +++ b/src/quick/accessible/qaccessiblequickitem_p.h @@ -62,70 +62,70 @@ public: QWindow *window() const Q_DECL_OVERRIDE; - QRect rect() const; + QRect rect() const Q_DECL_OVERRIDE; QRect viewRect() const; bool clipsChildren() const; - QAccessibleInterface *childAt(int x, int y) const; + QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE; - QAccessibleInterface *parent() const; - QAccessibleInterface *child(int index) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface *iface) const; + QAccessibleInterface *parent() const Q_DECL_OVERRIDE; + QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface *iface) const Q_DECL_OVERRIDE; QList childItems() const; - QAccessible::State state() const; - QAccessible::Role role() const; - QString text(QAccessible::Text) const; + QAccessible::State state() const Q_DECL_OVERRIDE; + QAccessible::Role role() const Q_DECL_OVERRIDE; + QString text(QAccessible::Text) const Q_DECL_OVERRIDE; bool isAccessible() const; // Action Interface - QStringList actionNames() const; - void doAction(const QString &actionName); - QStringList keyBindingsForAction(const QString &actionName) const; + QStringList actionNames() const Q_DECL_OVERRIDE; + void doAction(const QString &actionName) Q_DECL_OVERRIDE; + QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE; // Value Interface - QVariant currentValue() const; - void setCurrentValue(const QVariant &value); - QVariant maximumValue() const; - QVariant minimumValue() const; - QVariant minimumStepSize() const; + QVariant currentValue() const Q_DECL_OVERRIDE; + void setCurrentValue(const QVariant &value) Q_DECL_OVERRIDE; + QVariant maximumValue() const Q_DECL_OVERRIDE; + QVariant minimumValue() const Q_DECL_OVERRIDE; + QVariant minimumStepSize() const Q_DECL_OVERRIDE; // Text Interface - void selection(int selectionIndex, int *startOffset, int *endOffset) const; - int selectionCount() const; - void addSelection(int startOffset, int endOffset); - void removeSelection(int selectionIndex); - void setSelection(int selectionIndex, int startOffset, int endOffset); + void selection(int selectionIndex, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; + int selectionCount() const Q_DECL_OVERRIDE; + void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE; + void removeSelection(int selectionIndex) Q_DECL_OVERRIDE; + void setSelection(int selectionIndex, int startOffset, int endOffset) Q_DECL_OVERRIDE; // cursor - int cursorPosition() const; - void setCursorPosition(int position); + int cursorPosition() const Q_DECL_OVERRIDE; + void setCursorPosition(int position) Q_DECL_OVERRIDE; // text - QString text(int startOffset, int endOffset) const; + QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE; QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; + int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; + int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; - int characterCount() const; + int *startOffset, int *endOffset) const Q_DECL_OVERRIDE; + int characterCount() const Q_DECL_OVERRIDE; // character <-> geometry - QRect characterRect(int /* offset */) const { return QRect(); } - int offsetAtPoint(const QPoint & /* point */) const { return -1; } + QRect characterRect(int /* offset */) const Q_DECL_OVERRIDE { return QRect(); } + int offsetAtPoint(const QPoint & /* point */) const Q_DECL_OVERRIDE { return -1; } - void scrollToSubstring(int /* startIndex */, int /* endIndex */) {} - QString attributes(int /* offset */, int *startOffset, int *endOffset) const { *startOffset = 0; *endOffset = 0; return QString(); } + void scrollToSubstring(int /* startIndex */, int /* endIndex */) Q_DECL_OVERRIDE {} + QString attributes(int /* offset */, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE { *startOffset = 0; *endOffset = 0; return QString(); } QTextDocument *textDocument() const; protected: QQuickItem *item() const { return static_cast(object()); } - void *interface_cast(QAccessible::InterfaceType t); + void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE; private: QTextDocument *m_doc; -- cgit v1.2.3 From 7f8dc9d00c02e0e28cdea92cac8f8e4379bed68b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 13 Jun 2016 14:52:45 +0200 Subject: Fix build of textureprovider example with -opengl dynamic Do not link to OpenGL calls directly. Instead, use QOpenGLFunctions. Task-number: QTBUG-53841 Change-Id: Ic87bb78fede1ee9f75b81247406ad858b2bf7342 Reviewed-by: Laszlo Agocs --- examples/quick/textureprovider/etcprovider.cpp | 8 +++++--- examples/quick/textureprovider/etcprovider.h | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/quick/textureprovider/etcprovider.cpp b/examples/quick/textureprovider/etcprovider.cpp index 7eff597a43..b9bef84f70 100644 --- a/examples/quick/textureprovider/etcprovider.cpp +++ b/examples/quick/textureprovider/etcprovider.cpp @@ -81,7 +81,7 @@ unsigned short getPaddedHeight(ETCHeader *pHeader) EtcTexture::EtcTexture() : m_texture_id(0), m_uploaded(false) { - + initializeOpenGLFunctions(); } EtcTexture::~EtcTexture() @@ -92,8 +92,10 @@ EtcTexture::~EtcTexture() int EtcTexture::textureId() const { - if (m_texture_id == 0) - glGenTextures(1, &const_cast(this)->m_texture_id); + if (m_texture_id == 0) { + EtcTexture *texture = const_cast(this); + texture->glGenTextures(1, &texture->m_texture_id); + } return m_texture_id; } diff --git a/examples/quick/textureprovider/etcprovider.h b/examples/quick/textureprovider/etcprovider.h index a9ec5ed606..e9761e3629 100644 --- a/examples/quick/textureprovider/etcprovider.h +++ b/examples/quick/textureprovider/etcprovider.h @@ -34,7 +34,7 @@ #ifndef ETCPROVIDER_H #define ETCPROVIDER_H -#include +#include #include #include #include @@ -54,7 +54,7 @@ private: QUrl m_baseUrl; }; -class EtcTexture : public QSGTexture +class EtcTexture : public QSGTexture, protected QOpenGLFunctions { Q_OBJECT public: -- cgit v1.2.3 From 5d22723e052480ff3893a21f6bd75142f9f4f6ea Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Tue, 14 Jun 2016 11:56:44 -0400 Subject: Make some QNX only code Dinkum specific The undefines won't be needed for QNX 7.0 with GNU libc++. Change-Id: Ibcea09aad54a956fc056ceaac5db6a0d53cd176c Reviewed-by: Simon Hausmann --- src/3rdparty/masm/wtf/MathExtras.h | 2 +- src/qml/jsruntime/qv4global_p.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/masm/wtf/MathExtras.h b/src/3rdparty/masm/wtf/MathExtras.h index 28a189b6e6..9c38af6b16 100644 --- a/src/3rdparty/masm/wtf/MathExtras.h +++ b/src/3rdparty/masm/wtf/MathExtras.h @@ -43,7 +43,7 @@ #include #endif -#if OS(QNX) +#if OS(QNX) && defined(_CPPLIB_VER) // FIXME: Look into a way to have cmath import its functions into both the standard and global // namespace. For now, we include math.h since the QNX cmath header only imports its functions // into the standard namespace. diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 01a21ea06d..960741d95f 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -122,7 +122,7 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } #define ENABLE_JIT 0 #endif -#if defined(Q_OS_QNX) +#if defined(Q_OS_QNX) && defined(_CPPLIB_VER) #include #undef isnan #undef isfinite -- cgit v1.2.3 From c175beafad259a0c17661e140e745979632fdfdc Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Tue, 7 Jun 2016 17:00:48 -0400 Subject: Add QNX to an x86-64 gcc/g++ list QNX 7.0 will support x86-64. Change-Id: I91d79f41161324fb992e17c2067e0648b476c773 Reviewed-by: Rafael Roquetto --- src/qml/jit/qv4targetplatform_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jit/qv4targetplatform_p.h b/src/qml/jit/qv4targetplatform_p.h index 1e62b23fe4..90ed1f972e 100644 --- a/src/qml/jit/qv4targetplatform_p.h +++ b/src/qml/jit/qv4targetplatform_p.h @@ -145,7 +145,7 @@ public: #endif // Windows on x86 -#if CPU(X86_64) && (OS(LINUX) || OS(MAC_OS_X) || OS(FREEBSD)) +#if CPU(X86_64) && (OS(LINUX) || OS(MAC_OS_X) || OS(FREEBSD) || OS(QNX)) enum { RegAllocIsSupported = 1 }; static const JSC::MacroAssembler::RegisterID StackFrameRegister = JSC::X86Registers::ebp; -- cgit v1.2.3 From 7190aa26f65ab97b4f54c156a107ed7748a11df5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 9 Jun 2016 13:58:40 +0200 Subject: Support glyphs outside em square in distance field cache In the distance field cache, we would assume a max height of glyphs at 64 pixels when the pixel size was 54 (em square size is 54 and then some margin). This is an arbitrary assumption which does not necessarily hold true. Indeed, some fonts would be clipped at the bottom when assuming this. [ChangeLog][QtQuick][Text] Fixed clipping of glyphs that extend beyond font's em square. Task-number: QTBUG-52389 Change-Id: I5f6c9be235d38841e40d1bd60fb380e4712dd41a Reviewed-by: Yoann Lopes --- src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index dcc485ce17..728d8b6541 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -97,8 +97,10 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet &glyph glyph_t glyphIndex = *it; int padding = QSG_DEFAULT_DISTANCEFIELD_GLYPH_CACHE_PADDING; - int glyphWidth = qCeil(glyphData(glyphIndex).boundingRect.width()) + distanceFieldRadius() * 2; - QSize glyphSize(glyphWidth + padding * 2, QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution()) + padding * 2); + QRectF boundingRect = glyphData(glyphIndex).boundingRect; + int glyphWidth = qCeil(boundingRect.width()) + distanceFieldRadius() * 2; + int glyphHeight = qCeil(boundingRect.height()) + distanceFieldRadius() * 2; + QSize glyphSize(glyphWidth + padding * 2, glyphHeight + padding * 2); QRect alloc = m_areaAllocator->allocate(glyphSize); if (alloc.isNull()) { @@ -107,11 +109,13 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet &glyph glyph_t unusedGlyph = *m_unusedGlyphs.constBegin(); TexCoord unusedCoord = glyphTexCoord(unusedGlyph); - int unusedGlyphWidth = qCeil(glyphData(unusedGlyph).boundingRect.width()) + distanceFieldRadius() * 2; + QRectF unusedGlyphBoundingRect = glyphData(unusedGlyph).boundingRect; + int unusedGlyphWidth = qCeil(unusedGlyphBoundingRect.width()) + distanceFieldRadius() * 2; + int unusedGlyphHeight = qCeil(unusedGlyphBoundingRect.height()) + distanceFieldRadius() * 2; m_areaAllocator->deallocate(QRect(unusedCoord.x - padding, unusedCoord.y - padding, padding * 2 + unusedGlyphWidth, - padding * 2 + QT_DISTANCEFIELD_TILESIZE(doubleGlyphResolution()))); + padding * 2 + unusedGlyphHeight)); m_unusedGlyphs.remove(unusedGlyph); m_glyphsTexture.remove(unusedGlyph); -- cgit v1.2.3 From 5f92f784834f8648857fa6056ac0a93c96c60543 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 14 Jun 2016 22:27:21 +0200 Subject: Remove erronous setTextureSize() as it is already set previously This was causing problems with the FrameBuffer render target when displaying on a HiDpi display as it would end up with a size which was not accounting for the devicePixelRatio. Task-number: QTBUG-52901 Change-Id: I587e2578d670cfecb016aae92c4190a37e7412a1 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/util/qsgdefaultpainternode.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp index 38bcc7a3f3..e3103341cd 100644 --- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp +++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp @@ -310,7 +310,6 @@ void QSGDefaultPainterNode::updateRenderTarget() if (m_texture) delete m_texture; - texture->setTextureSize(m_size); m_texture = texture; } -- cgit v1.2.3 From 9b1231ca3d21ade574a8a7cf3f0805a8b520bcd5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 8 Jun 2016 17:32:32 +0200 Subject: QML: Only release types if they aren't referenced anymore Just checking for references on m_compiledData is not enough. The actual component can also be referenced. Thus it won't be deleted on release(), but cannot be found in the type cache anymore. Task-number: QTBUG-53761 Change-Id: I8567af8e75a078598e4fed31e4717134e1332278 Reviewed-by: Mitch Curtis Reviewed-by: Simon Hausmann (cherry picked from commit 2ac19881f92c94f4e9427bd9ff513210675f259e) --- src/qml/qml/qqmltypeloader.cpp | 3 ++- tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index c684c8602e..01200fd881 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1961,7 +1961,8 @@ void QQmlTypeLoader::trimCache() QList unneededTypes; for (TypeCache::Iterator iter = m_typeCache.begin(), end = m_typeCache.end(); iter != end; ++iter) { QQmlTypeData *typeData = iter.value(); - if (typeData->m_compiledData && typeData->m_compiledData->count() == 1) { + if (typeData->m_compiledData && typeData->count() == 1 + && typeData->m_compiledData->count() == 1) { // There are no live objects of this type unneededTypes.append(iter); } diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 7045c7cbd4..a1eaa0567f 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -86,10 +86,19 @@ void tst_QQMLTypeLoader::trimCache() url.setQuery(QString::number(i)); QQmlTypeData *data = loader.getType(url); - if (i % 5 == 0) // keep references to some of them so that they aren't trimmed - data->compiledData()->addref(); + // Run an event loop to receive the callback that release()es. + QTRY_COMPARE(data->count(), 2); - data->release(); + // keep references to some of them so that they aren't trimmed. References to either the + // QQmlTypeData or its compiledData() should prevent the trimming. + if (i % 10 == 0) { + // keep ref on data, don't add ref on data->compiledData() + } else if (i % 5 == 0) { + data->compiledData()->addref(); + data->release(); + } else { + data->release(); + } } for (int i = 0; i < 256; ++i) { -- cgit v1.2.3 From 547d0bdf09c46f361966809f8d7db3a581969799 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 20 May 2016 16:17:59 +0200 Subject: highdpi manual test: include not qDebug.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I24b3ccd23fdb42d44978debeeec96bac179edba6 Reviewed-by: Morten Johan Sørvig --- tests/manual/highdpi/imageprovider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/manual/highdpi/imageprovider.cpp b/tests/manual/highdpi/imageprovider.cpp index 33a69cb87e..069fa5998f 100644 --- a/tests/manual/highdpi/imageprovider.cpp +++ b/tests/manual/highdpi/imageprovider.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include class ColorImageProvider : public QQuickImageProvider { -- cgit v1.2.3 From d2f1e081b9de201fd45e67b78567c6d720d0c6bf Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 3 Jun 2016 20:18:35 +0200 Subject: ItemViews: Make the wording of the warning on cache properties slightly sterner. I have seen far too many cases of someone simply setting cacheBuffer to a massive number in an attempt to workaround a slow delegate. It should be explicit that cacheBuffer is not a solution for these problems. Change-Id: I09416d06ff7faf51a104e09ca5f6b3593ddc53c7 Reviewed-by: Simon Hausmann --- src/quick/items/qquickgridview.cpp | 10 ++++++---- src/quick/items/qquicklistview.cpp | 10 ++++++---- src/quick/items/qquickpathview.cpp | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 8d84144519..6e5710a97b 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -1524,10 +1524,12 @@ void QQuickGridView::setHighlightFollowsCurrentItem(bool autoHighlight) Note that cacheBuffer is not a pixel buffer - it only maintains additional instantiated delegates. - Setting this value can make scrolling the list smoother at the expense - of additional memory usage. It is not a substitute for creating efficient - delegates; the fewer objects and bindings in a delegate, the faster a view may be - scrolled. + \note Setting this property is not a replacement for creating efficient delegates. + It can improve the smoothness of scrolling behavior at the expense of additional + memory usage. The fewer objects and bindings in a delegate, the faster a + view can be scrolled. It is important to realize that setting a cacheBuffer + will only postpone issues caused by slow-loading delegates, it is not a + solution for this scenario. The cacheBuffer operates outside of any display margins specified by displayMarginBeginning or displayMarginEnd. diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 242fdd2cfa..78a64c5df1 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2197,10 +2197,12 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation) Note that cacheBuffer is not a pixel buffer - it only maintains additional instantiated delegates. - Setting this value can improve the smoothness of scrolling behavior at the expense - of additional memory usage. It is not a substitute for creating efficient - delegates; the fewer objects and bindings in a delegate, the faster a view can be - scrolled. + \note Setting this property is not a replacement for creating efficient delegates. + It can improve the smoothness of scrolling behavior at the expense of additional + memory usage. The fewer objects and bindings in a delegate, the faster a + view can be scrolled. It is important to realize that setting a cacheBuffer + will only postpone issues caused by slow-loading delegates, it is not a + solution for this scenario. The cacheBuffer operates outside of any display margins specified by displayMarginBeginning or displayMarginEnd. diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 73146f015e..7e1fa95692 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1306,10 +1306,12 @@ void QQuickPathView::resetPathItemCount() allowing creation to occur across multiple frames and reducing the likelihood of skipping frames. - Setting this value can improve the smoothness of scrolling behavior at the expense - of additional memory usage. It is not a substitute for creating efficient - delegates; the fewer objects and bindings in a delegate, the faster a view can be - moved. + \note Setting this property is not a replacement for creating efficient delegates. + It can improve the smoothness of scrolling behavior at the expense of additional + memory usage. The fewer objects and bindings in a delegate, the faster a + view can be scrolled. It is important to realize that setting cacheItemCount + will only postpone issues caused by slow-loading delegates, it is not a + solution for this scenario. \sa pathItemCount */ -- cgit v1.2.3 From aa7c3b35ef9b737c574f436ea35452019a2ff29c Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 16 Jun 2016 13:39:57 +0200 Subject: V4: Always set the tag when boxing a pointer in QV4::Value. All setters now store tags, so no-one can play loosy-goosy with the boxed values (and accidentally forget to "tag" a value, resulting in random garbage). Change-Id: Ia0b78aa038d3ff46d5292b14bd593de310da16a0 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qqmlnativedebugservice.cpp | 2 +- src/qml/jsruntime/qv4arraydata.cpp | 10 +-- src/qml/jsruntime/qv4objectiterator.cpp | 5 -- src/qml/jsruntime/qv4persistent.cpp | 9 +-- src/qml/jsruntime/qv4scopedvalue_p.h | 16 +--- src/qml/jsruntime/qv4value_p.h | 94 ++++++++++++---------- 6 files changed, 63 insertions(+), 73 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index f5cc78e77f..24d2a82413 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -549,7 +549,7 @@ void NativeDebugger::handleExpressions(QJsonObject *response, const QJsonObject dict[QStringLiteral("name")] = name; dict[QStringLiteral("valueencoded")] = QStringLiteral("undefined"); output.append(dict); - } else if (result.ptr && result.ptr->_val) { + } else if (result.ptr && result.ptr->rawValue()) { collector.collect(&output, QString(), name, *result); } else { QJsonObject dict; diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index bd736d775e..ec0e6111ab 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -93,8 +93,8 @@ Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SparseArrayData)); static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value) { - Value v = Value::fromReturnedValue(*target); - v.setValue(value); + Value v; + v.setTagValue(Value::fromReturnedValue(*target).tag(), value); *target = v.asReturnedValue(); } @@ -189,7 +189,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt n->value = i; } else { storeValue(lastFree, i); - sparse->arrayData[i].setTag(Value::Empty_Type); + sparse->arrayData[i].setEmpty(); lastFree = &sparse->arrayData[i].rawValueRef(); } } @@ -198,7 +198,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt if (toCopy < sparse->alloc) { for (uint i = toCopy; i < sparse->alloc; ++i) { storeValue(lastFree, i); - sparse->arrayData[i].setTag(Value::Empty_Type); + sparse->arrayData[i].setEmpty(); lastFree = &sparse->arrayData[i].rawValueRef(); } storeValue(lastFree, UINT_MAX); @@ -396,7 +396,7 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot) // found two slots in a row uint idx = Value::fromReturnedValue(*last).uint_32(); Value lastV = Value::fromReturnedValue(*last); - lastV.setValue(dd->arrayData[lastV.value() + 1].value()); + lastV.setTagValue(lastV.tag(), dd->arrayData[lastV.value() + 1].value()); *last = lastV.rawValue(); dd->attrs[idx] = Attr_Accessor; return idx; diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 1413f439b1..d4587df79b 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -68,11 +68,6 @@ void ObjectIterator::init(const Object *o) object->setM(o ? o->m() : 0); current->setM(o ? o->m() : 0); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - object->setTag(QV4::Value::Managed_Type); - current->setTag(QV4::Value::Managed_Type); -#endif - if (object->as()) { Scope scope(engine); Scoped (scope, object->asReturnedValue())->fullyCreate(); diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 1b0d6383e0..fd3bd1f660 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -79,11 +79,9 @@ Page *allocatePage(PersistentValueStorage *storage) if (p->header.next) p->header.next->header.prev = &p->header.next; for (int i = 0; i < kEntriesPerPage - 1; ++i) { - p->values[i].setTag(QV4::Value::Empty_Type); - p->values[i].setInt_32(i + 1); + p->values[i].setEmpty(i + 1); } - p->values[kEntriesPerPage - 1].setTag(QV4::Value::Empty_Type); - p->values[kEntriesPerPage - 1].setInt_32(-1); + p->values[kEntriesPerPage - 1].setEmpty(-1); storage->firstPage = p; @@ -205,8 +203,7 @@ void PersistentValueStorage::free(Value *v) Page *p = getPage(v); - v->setTag(QV4::Value::Empty_Type); - v->setInt_32(p->header.freeList); + v->setEmpty(p->header.freeList); p->header.freeList = v - p->values; if (!--p->header.refCount) freePage(p); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index ca7efb1e79..0b063ee4b8 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -120,9 +120,6 @@ struct ScopedValue { ptr = scope.engine->jsStackTop++; ptr->setM(o); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - ptr->setTag(QV4::Value::Managed_Type); -#endif } ScopedValue(const Scope &scope, Managed *m) @@ -144,9 +141,6 @@ struct ScopedValue ScopedValue &operator=(Heap::Base *o) { ptr->setM(o); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - ptr->setTag(QV4::Value::Managed_Type); -#endif return *this; } @@ -186,18 +180,12 @@ struct Scoped inline void setPointer(const Managed *p) { ptr->setM(p ? p->m() : 0); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - ptr->setTag(QV4::Value::Managed_Type); -#endif } Scoped(const Scope &scope) { ptr = scope.engine->jsStackTop++; ptr->setM(0); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - ptr->setTag(QV4::Value::Managed_Type); -#endif } Scoped(const Scope &scope, const Value &v) @@ -339,14 +327,14 @@ struct ScopedCallData { inline Value &Value::operator =(const ScopedValue &v) { - _val = v.ptr->val(); + _val = v.ptr->rawValue(); return *this; } template inline Value &Value::operator=(const Scoped &t) { - _val = t.ptr->val(); + _val = t.ptr->rawValue(); return *this; } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 6bd39355c5..7c2bb31a00 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -66,6 +66,7 @@ typedef uint Bool; struct Q_QML_PRIVATE_EXPORT Value { +private: /* We use two different ways of encoding JS values. One for 32bit and one for 64bit systems. @@ -90,10 +91,10 @@ struct Q_QML_PRIVATE_EXPORT Value quint64 _val; - Q_ALWAYS_INLINE quint64 val() const { return _val; } - Q_ALWAYS_INLINE void setVal(quint64 v) { _val = v; } - Q_ALWAYS_INLINE void setValue(quint32 v) { memcpy(&_val, &v, 4); } - Q_ALWAYS_INLINE void setTag(quint32 t) { memcpy(4 + (quint8 *)&_val, &t, 4); } +public: + Q_ALWAYS_INLINE quint64 &rawValueRef() { return _val; } + Q_ALWAYS_INLINE quint64 rawValue() const { return _val; } + Q_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; } #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN static inline int valueOffset() { return 0; } @@ -113,17 +114,53 @@ struct Q_QML_PRIVATE_EXPORT Value Q_ALWAYS_INLINE Heap::Base *m() const { Q_UNREACHABLE(); return Q_NULLPTR; } Q_ALWAYS_INLINE void setM(Heap::Base *b) { Q_UNUSED(b); Q_UNREACHABLE(); } #elif defined(QV4_USE_64_BIT_VALUE_ENCODING) - Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; memcpy(&b, &_val, 8); return b; } - Q_ALWAYS_INLINE void setM(Heap::Base *b) { memcpy(&_val, &b, 8); } + Q_ALWAYS_INLINE Heap::Base *m() const + { + Heap::Base *b; + memcpy(&b, &_val, 8); + return b; + } + Q_ALWAYS_INLINE void setM(Heap::Base *b) + { + memcpy(&_val, &b, 8); + } #else // !QV4_USE_64_BIT_VALUE_ENCODING - Q_ALWAYS_INLINE Heap::Base *m() const { Q_STATIC_ASSERT(sizeof(Heap::Base*) == sizeof(quint32)); Heap::Base *b; quint32 v = value(); memcpy(&b, &v, 4); return b; } - Q_ALWAYS_INLINE void setM(Heap::Base *b) { quint32 v; memcpy(&v, &b, 4); setValue(v); } + Q_ALWAYS_INLINE Heap::Base *m() const + { + Q_STATIC_ASSERT(sizeof(Heap::Base*) == sizeof(quint32)); + Heap::Base *b; + quint32 v = value(); + memcpy(&b, &v, 4); + return b; + } + Q_ALWAYS_INLINE void setM(Heap::Base *b) + { + quint32 v; + memcpy(&v, &b, 4); + setTagValue(Managed_Type, v); + } #endif - Q_ALWAYS_INLINE int int_32() const { int i; quint32 v = value(); memcpy(&i, &v, 4); return i; } - Q_ALWAYS_INLINE void setInt_32(int i) { quint32 u; memcpy(&u, &i, 4); setValue(u); } + Q_ALWAYS_INLINE int int_32() const + { + return int(value()); + } + Q_ALWAYS_INLINE void setInt_32(int i) + { + setTagValue(Integer_Type_Internal, quint32(i)); + } Q_ALWAYS_INLINE uint uint_32() const { return value(); } + Q_ALWAYS_INLINE void setEmpty() + { + setTagValue(Empty_Type, value()); + } + + Q_ALWAYS_INLINE void setEmpty(int i) + { + setTagValue(Empty_Type, quint32(i)); + } + #ifndef QV4_USE_64_BIT_VALUE_ENCODING enum Masks { SilentNaNBit = 0x00040000, @@ -260,7 +297,6 @@ struct Q_QML_PRIVATE_EXPORT Value int i = (int)d; if (i == d) { setInt_32(i); - setTag(Integer_Type_Internal); return true; } } @@ -292,22 +328,10 @@ struct Q_QML_PRIVATE_EXPORT Value return m(); } - Q_ALWAYS_INLINE quint64 &rawValueRef() { - return _val; - } - Q_ALWAYS_INLINE quint64 rawValue() const { - return _val; - } - Q_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; } - static inline Value fromHeapObject(Heap::Base *m) { Value v; - v.setRawValue(0); v.setM(m); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - v.setTag(Managed_Type); -#endif return v; } @@ -328,7 +352,7 @@ struct Q_QML_PRIVATE_EXPORT Value inline bool tryIntegerConversion() { bool b = integerCompatible(); if (b) - setTag(Integer_Type_Internal); + setTagValue(Integer_Type_Internal, value()); return b; } @@ -378,7 +402,7 @@ struct Q_QML_PRIVATE_EXPORT Value Value &operator=(ReturnedValue v) { _val = v; return *this; } Value &operator=(Managed *m) { if (!m) { - setTagValue(Undefined_Type, 0); + setM(0); } else { _val = reinterpret_cast(m)->_val; } @@ -386,9 +410,6 @@ struct Q_QML_PRIVATE_EXPORT Value } Value &operator=(Heap::Base *o) { setM(o); -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - setTag(Managed_Type); -#endif return *this; } @@ -479,13 +500,7 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value inline Primitive Primitive::undefinedValue() { Primitive v; -#ifdef QV4_USE_64_BIT_VALUE_ENCODING - v.setRawValue(quint64(Undefined_Type) << Tag_Shift); -#else - v.setRawValue(0); - v.setTag(Undefined_Type); - v.setValue(0); -#endif + v.setTagValue(Undefined_Type, 0); return v; } @@ -499,11 +514,7 @@ inline Primitive Primitive::emptyValue() inline Primitive Primitive::nullValue() { Primitive v; -#ifndef QV4_USE_64_BIT_VALUE_ENCODING - v.setRawValue(quint64(Null_Type_Internal) << Tag_Shift); -#else v.setTagValue(Null_Type_Internal, 0); -#endif return v; } @@ -524,7 +535,7 @@ inline Primitive Primitive::fromDouble(double d) inline Primitive Primitive::fromInt32(int i) { Primitive v; - v.setTagValue(Integer_Type_Internal, 0); // For mingw482, because it complains, and for VS9, because of internal compiler errors. + v.setTagValue(Integer_Type_Internal, 0); v.setInt_32(i); return v; } @@ -533,8 +544,7 @@ inline Primitive Primitive::fromUInt32(uint i) { Primitive v; if (i < INT_MAX) { - v.setTagValue(Integer_Type_Internal, 0); // For mingw482, because it complains, and for VS9, because of internal compiler errors. - v.setInt_32((int)i); + v.setTagValue(Integer_Type_Internal, i); } else { v.setDouble(i); } -- cgit v1.2.3 From 458b4f0d37955b44c4f129541df2203cb8426296 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Wed, 15 Jun 2016 08:37:45 +0800 Subject: Expand license scope from "Qt GUI Toolkit" to "Qt Toolkit" See http://comments.gmane.org/gmane.comp.lib.qt.devel/25771 Change-Id: I92dc562e5896b11bdeafb5d603c39cdc5053a3b2 Reviewed-by: Lars Knoll --- LICENSE.GPLv3 | 2 +- LICENSE.LGPLv21 | 2 +- LICENSE.LGPLv3 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE.GPLv3 b/LICENSE.GPLv3 index 4e49b122ae..71c4ad49c3 100644 --- a/LICENSE.GPLv3 +++ b/LICENSE.GPLv3 @@ -3,7 +3,7 @@ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. Contact: http://www.qt.io/licensing/ - You may use, distribute and copy the Qt GUI Toolkit under the terms of + You may use, distribute and copy the Qt Toolkit under the terms of GNU Lesser General Public License version 3. That license references the General Public License version 3, that is displayed below. Other portions of the Qt Toolkit may be licensed directly under this license. diff --git a/LICENSE.LGPLv21 b/LICENSE.LGPLv21 index 6e18461125..dfcab5e29b 100644 --- a/LICENSE.LGPLv21 +++ b/LICENSE.LGPLv21 @@ -3,7 +3,7 @@ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. Contact: http://www.qt.io/licensing/ - You may use, distribute and copy the Qt GUI Toolkit under the terms of + You may use, distribute and copy the Qt Toolkit under the terms of GNU Lesser General Public License version 2.1, which is displayed below. ------------------------------------------------------------------------- diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3 index 4d67bac0b4..6bf924cd15 100644 --- a/LICENSE.LGPLv3 +++ b/LICENSE.LGPLv3 @@ -3,7 +3,7 @@ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. Contact: http://www.qt.io/licensing/ - You may use, distribute and copy the Qt GUI Toolkit under the terms of + You may use, distribute and copy the Qt Toolkit under the terms of GNU Lesser General Public License version 3, which is displayed below. This license makes reference to the version 3 of the GNU General Public License, which you can find in the LICENSE.GPLv3 file. -- cgit v1.2.3 From 6358e1365539d2ea26ec20617b58c0fed11d647e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 13 Jun 2016 16:52:22 -0500 Subject: Fix positioning of inline images in StyledText. Fix horizontal positioning generally, and also address RTL specifically. Change-Id: I8b75c11bc38e39da5cda302ee9b475bf0dc464e8 Task-number: QTBUG-54075 Reviewed-by: Andrew den Exter --- src/quick/items/qquicktext.cpp | 5 ++++- src/quick/util/qquickstyledtext.cpp | 15 ++++++++++----- src/quick/util/qquickstyledtext_p.h | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index aa8f04e55d..e67e2cee9c 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1138,7 +1138,10 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal foreach (QQuickStyledTextImgTag *image, imagesInLine) { totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height()); - image->pos.setX(line.cursorToX(image->position)); + const int leadX = line.cursorToX(image->position); + const int trailX = line.cursorToX(image->position, QTextLine::Trailing); + const bool rtl = trailX < leadX; + image->pos.setX(leadX + (rtl ? (-image->offset - image->size.width()) : image->offset)); image->pos.setY(image->pos.y() + height + textTop); extra->visibleImgTags << image; } diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp index c411207121..6dd9ca882b 100644 --- a/src/quick/util/qquickstyledtext.cpp +++ b/src/quick/util/qquickstyledtext.cpp @@ -652,10 +652,13 @@ bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QStr void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut) { qreal imgWidth = 0.0; + QFontMetricsF fm(layout.font()); + const qreal spaceWidth = fm.width(QChar::Nbsp); + const bool trailingSpace = textOut.endsWith(space); if (!updateImagePositions) { QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag; - image->position = textOut.length() + 1; + image->position = textOut.length() + (trailingSpace ? 0 : 1); QPair attr; do { @@ -692,14 +695,16 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri } imgWidth = image->size.width(); + image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0; imgTags->append(image); } else { // if we already have a list of img tags for this text // we only want to update the positions of these tags. QQuickStyledTextImgTag *image = imgTags->value(nbImages); - image->position = textOut.length() + 1; + image->position = textOut.length() + (trailingSpace ? 0 : 1); imgWidth = image->size.width(); + image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0; QPair attr; do { attr = parseAttribute(ch, textIn); @@ -707,9 +712,9 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri nbImages++; } - QFontMetricsF fm(layout.font()); - QString padding(qFloor(imgWidth / fm.width(QChar::Nbsp)), QChar::Nbsp); - textOut += QLatin1Char(' '); + QString padding(qFloor(imgWidth / spaceWidth), QChar::Nbsp); + if (!trailingSpace) + textOut += QLatin1Char(' '); textOut += padding; textOut += QLatin1Char(' '); } diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h index cd6710ff26..d9f1a71739 100644 --- a/src/quick/util/qquickstyledtext_p.h +++ b/src/quick/util/qquickstyledtext_p.h @@ -62,7 +62,7 @@ class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag { public: QQuickStyledTextImgTag() - : position(0), align(QQuickStyledTextImgTag::Bottom), pix(0) + : position(0), offset(0.0), align(QQuickStyledTextImgTag::Bottom), pix(0) { } ~QQuickStyledTextImgTag() { delete pix; } @@ -77,6 +77,7 @@ public: QPointF pos; QSize size; int position; + qreal offset; // this offset allows us to compensate for flooring reserved space Align align; QQuickPixmap *pix; }; -- cgit v1.2.3 From 1591d0e0f62a48d2ef45cc8af9b5d39158e169d5 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 16 Jun 2016 04:30:49 -0700 Subject: Fix reference to Windows RT which actually meant Windows Runtime. Change-Id: I701b25bc73cf84b1daae481eebfd2dc19003ce78 Reviewed-by: Maurice Kalinowski --- src/qml/qml/qqmlengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 2cfe468134..9a06f6b055 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -402,7 +402,7 @@ The following functions are also on the Qt object. \li \c "unix" - Other Unix-based OS \li \c "windows" - Windows \li \c "wince" - Windows CE - \li \c "winrt" - Windows RT + \li \c "winrt" - Windows Runtime \li \c "winphone" - Windows Phone \endlist \endtable -- cgit v1.2.3 From c8241e8551b9491081486cc98936ad5ad1824a1e Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 17 Jun 2016 14:42:37 +0200 Subject: qmltest::linecount - adjust text width With text line width 50 'Hello world!' is split into 2 lines on OS X 10.11 and the test expectes 3 lines, let's try something less than 50 (44). Task-number: QTBUG-53778 Change-Id: Id3254e9d89e7b41498ff8735eff97f0317ae9677 Reviewed-by: Shawn Rutledge --- tests/auto/qmltest/text/tst_text.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qmltest/text/tst_text.qml b/tests/auto/qmltest/text/tst_text.qml index 691a4838cd..d2899cfb74 100644 --- a/tests/auto/qmltest/text/tst_text.qml +++ b/tests/auto/qmltest/text/tst_text.qml @@ -118,9 +118,10 @@ Item { compare(txtlinecount.lineCount, 2) txtlinecount.text = txtlinecount.third; compare(txtlinecount.lineCount, 3) + console.log(txtlinecount.width) txtlinecount.text = txtlinecount.first; compare(txtlinecount.lineCount, 1) - txtlinecount.width = 50; + txtlinecount.width = 44; compare(txtlinecount.lineCount, 3) } function test_linecounts() { -- cgit v1.2.3 From 0960561981b59cbd293aeb32e87dc8a7732fe521 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sun, 29 May 2016 00:07:26 +0200 Subject: Doc: Refactor cpp integration Message sample Since MyItem.qml is a GUI element, the example as is triggers a segfault when starting. This patch refactors the cpp code to make it a GUI application. Change-Id: I983c8c1945bd4be364c988ab9fdfa69e35e7b9de Reviewed-by: J-P Nurmi Reviewed-by: Sze Howe Koh --- src/qml/doc/src/cppintegration/exposecppattributes.qdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc index f4f688520a..c7e4930bfb 100644 --- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc +++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc @@ -119,13 +119,13 @@ from C++: \code int main(int argc, char *argv[]) { - QCoreApplication app(argc, argv); + QGuiApplication app(argc, argv); - QQmlEngine engine; + QQuickView view; Message msg; - engine.rootContext()->setContextProperty("msg", &msg); - QQmlComponent component(&engine, QUrl::fromLocalFile("MyItem.qml")); - component.create(); + view.engine()->rootContext()->setContextProperty("msg", &msg); + view.setSource(QUrl::fromLocalFile("MyItem.qml")); + view.show(); return app.exec(); } -- cgit v1.2.3