diff options
author | Liang Qi <liang.qi@qt.io> | 2016-06-20 17:39:48 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-06-21 21:22:46 +0200 |
commit | 43431619d644ebd783d292a12c1904cfd7680824 (patch) | |
tree | 7d79c2b79f6ed450613b29de700ee488d8cd99f4 /src | |
parent | 7a1b5b1cfece18d5f4b2d8beb340d3cbe8f54451 (diff) | |
parent | cb6c208c77e2e3c8b6d5957fae73f0326eee4296 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
src/quick/items/qquickflickable_p_p.h
src/quick/items/qquickpathview_p_p.h
tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
Change-Id: I77664a095d8a203e07a021c9d5953e02b8b99a1e
Diffstat (limited to 'src')
26 files changed, 167 insertions, 149 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 <machine/ieee.h> #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/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index 9f44c4ec81..43036e9c3c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -554,7 +554,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/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(); } diff --git a/src/qml/jit/qv4targetplatform_p.h b/src/qml/jit/qv4targetplatform_p.h index 54b17c4f07..6f0a7374c3 100644 --- a/src/qml/jit/qv4targetplatform_p.h +++ b/src/qml/jit/qv4targetplatform_p.h @@ -152,7 +152,7 @@ public: #endif // Windows on x86 -#if CPU(X86_64) && (OS(LINUX) || OS(MAC_OS_X) || OS(FREEBSD) || defined(Q_OS_IOS)) +#if CPU(X86_64) && (OS(LINUX) || OS(MAC_OS_X) || OS(FREEBSD) || OS(QNX) || defined(Q_OS_IOS)) enum { RegAllocIsSupported = 1 }; static const JSC::MacroAssembler::RegisterID FramePointerRegister = JSC::X86Registers::ebp; diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 4c4639c94f..f4afe46fcb 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -99,8 +99,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(); } @@ -195,7 +195,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(); } } @@ -204,7 +204,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); @@ -402,7 +402,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/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 921edbc883..184375a9b6 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -135,7 +135,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 <math.h> #undef isnan #undef isfinite diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index b5e26b925f..4354e09248 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -74,11 +74,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<ArgumentsObject>()) { Scope scope(engine); Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate(); diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index f6d4046ec4..7ca0692804 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -85,11 +85,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; @@ -211,8 +209,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 58797f5eda..a6f7f8e0e7 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -126,9 +126,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) @@ -150,9 +147,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; } @@ -192,18 +186,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) @@ -345,14 +333,14 @@ struct ScopedCallData { inline Value &Value::operator =(const ScopedValue &v) { - _val = v.ptr->val(); + _val = v.ptr->rawValue(); return *this; } template<typename T> inline Value &Value::operator=(const Scoped<T> &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 f99e24c6e9..d24a5c4c76 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -72,6 +72,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. @@ -96,10 +97,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; } @@ -119,17 +120,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, @@ -266,7 +303,6 @@ struct Q_QML_PRIVATE_EXPORT Value int i = (int)d; if (i == d) { setInt_32(i); - setTag(Integer_Type_Internal); return true; } } @@ -304,22 +340,10 @@ struct Q_QML_PRIVATE_EXPORT Value return isManaged() ? m() : nullptr; } - 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; } @@ -340,7 +364,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; } @@ -393,7 +417,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<Value *>(m)->_val; } @@ -401,9 +425,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; } @@ -494,13 +515,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; } @@ -514,11 +529,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; } @@ -539,7 +550,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; } @@ -548,8 +559,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); } diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 3c7c37c1ea..6cd32852e1 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -407,7 +407,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 diff --git a/src/qml/qml/qqmlincubator.cpp b/src/qml/qml/qqmlincubator.cpp index 7494d6a633..0ce769aaea 100644 --- a/src/qml/qml/qqmlincubator.cpp +++ b/src/qml/qml/qqmlincubator.cpp @@ -433,7 +433,7 @@ example shows a simple use of QQmlIncubator. QQmlIncubator incubator; component->create(incubator); -while (incubator.isReady()) { +while (!incubator.isReady()) { QCoreApplication::processEvents(QEventLoop::AllEvents, 50); } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 0ba0384c60..7ba18cd761 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -1937,7 +1937,8 @@ void QQmlTypeLoader::trimCache() QList<TypeCache::Iterator> 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/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h index 3c59b19ec2..3d2b32286f 100644 --- a/src/quick/items/qquickflickable_p_p.h +++ b/src/quick/items/qquickflickable_p_p.h @@ -62,6 +62,7 @@ #include <private/qquicktimeline_p_p.h> #include <private/qquickanimation_p_p.h> #include <private/qquicktransitionmanager_p_p.h> +#include <private/qpodvector_p.h> QT_BEGIN_NAMESPACE diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index da48fd869d..cb2611199e 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -1549,10 +1549,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/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 7417dd64cc..04d48d0384 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2364,8 +2364,9 @@ QQuickItem::~QQuickItem() while (!d->childItems.isEmpty()) d->childItems.constFirst()->setParentItem(0); - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QQuickAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); + const auto listeners = d->changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { + QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); if (anchor) anchor->clearItem(this); } @@ -2374,14 +2375,13 @@ QQuickItem::~QQuickItem() update item anchors that depended on us unless they are our child (and will also be destroyed), or our sibling, and our parent is also being destroyed. */ - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QQuickAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); + for (const QQuickItemPrivate::ChangeListener &change : listeners) { + QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); if (anchor && anchor->item && anchor->item->parentItem() && anchor->item->parentItem() != this) anchor->update(); } - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = d->changeListeners.at(ii); + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Destroyed) change.listener->itemDestroyed(this); } @@ -3628,8 +3628,8 @@ QQuickAnchors *QQuickItemPrivate::anchors() const void QQuickItemPrivate::siblingOrderChanged() { Q_Q(QQuickItem); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::SiblingOrder) { change.listener->itemSiblingOrderChanged(q); } @@ -3737,8 +3737,8 @@ void QQuickItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo bool widthChange = (newGeometry.width() != oldGeometry.width()); bool heightChange = (newGeometry.height() != oldGeometry.height()); - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = d->changeListeners.at(ii); + const auto listeners = d->changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Geometry) { if (change.gTypes == QQuickItemPrivate::GeometryChange) { change.listener->itemGeometryChanged(this, newGeometry, oldGeometry); @@ -3874,7 +3874,7 @@ void QQuickItemPrivate::removeItemChangeListener(QQuickItemChangeListener *liste void QQuickItemPrivate::updateOrAddGeometryChangeListener(QQuickItemChangeListener *listener, GeometryChangeTypes types) { ChangeListener change(listener, types); - int index = changeListeners.find(change); + int index = changeListeners.indexOf(change); if (index > -1) changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes else @@ -3888,7 +3888,7 @@ void QQuickItemPrivate::updateOrRemoveGeometryChangeListener(QQuickItemChangeLis if (types == NoChange) { changeListeners.removeOne(change); } else { - int index = changeListeners.find(change); + int index = changeListeners.indexOf(change); if (index > -1) changeListeners[index].gTypes = change.gTypes; //we may have different GeometryChangeTypes } @@ -4297,8 +4297,8 @@ void QQuickItem::setBaselineOffset(qreal offset) d->baselineOffset = offset; - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = d->changeListeners.at(ii); + const auto listeners = d->changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Geometry) { QQuickAnchorsPrivate *anchor = change.listener->anchorPrivate(); if (anchor) @@ -5969,66 +5969,72 @@ void QQuickItemPrivate::itemChange(QQuickItem::ItemChange change, const QQuickIt { Q_Q(QQuickItem); switch (change) { - case QQuickItem::ItemChildAddedChange: + case QQuickItem::ItemChildAddedChange: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Children) { change.listener->itemChildAdded(q, data.item); } } break; - case QQuickItem::ItemChildRemovedChange: + } + case QQuickItem::ItemChildRemovedChange: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Children) { change.listener->itemChildRemoved(q, data.item); } } break; + } case QQuickItem::ItemSceneChange: q->itemChange(change, data); break; - case QQuickItem::ItemVisibleHasChanged: + case QQuickItem::ItemVisibleHasChanged: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Visibility) { change.listener->itemVisibilityChanged(q); } } break; - case QQuickItem::ItemParentHasChanged: + } + case QQuickItem::ItemParentHasChanged: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Parent) { change.listener->itemParentChanged(q, data.item); } } break; - case QQuickItem::ItemOpacityHasChanged: + } + case QQuickItem::ItemOpacityHasChanged: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Opacity) { change.listener->itemOpacityChanged(q); } } break; + } case QQuickItem::ItemActiveFocusHasChanged: q->itemChange(change, data); break; - case QQuickItem::ItemRotationHasChanged: + case QQuickItem::ItemRotationHasChanged: { q->itemChange(change, data); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::Rotation) { change.listener->itemRotationChanged(q); } } break; + } case QQuickItem::ItemAntialiasingHasChanged: // fall through case QQuickItem::ItemDevicePixelRatioHasChanged: @@ -6383,8 +6389,8 @@ void QQuickItem::resetWidth() void QQuickItemPrivate::implicitWidthChanged() { Q_Q(QQuickItem); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::ImplicitWidth) { change.listener->itemImplicitWidthChanged(q); } @@ -6547,8 +6553,8 @@ void QQuickItem::resetHeight() void QQuickItemPrivate::implicitHeightChanged() { Q_Q(QQuickItem); - for (int ii = 0; ii < changeListeners.count(); ++ii) { - const QQuickItemPrivate::ChangeListener &change = changeListeners.at(ii); + const auto listeners = changeListeners; + for (const QQuickItemPrivate::ChangeListener &change : listeners) { if (change.types & QQuickItemPrivate::ImplicitHeight) { change.listener->itemImplicitHeightChanged(q); } diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 0c5a8abb4a..3468172484 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -63,7 +63,6 @@ #include <QtQuick/qsgnode.h> #include "qquickclipnode_p.h" -#include <private/qpodvector_p.h> #include <QtQuick/private/qquickstate_p.h> #include <private/qqmlnullablevalue_p.h> #include <private/qqmlnotifier_p.h> @@ -332,7 +331,7 @@ public: Q_DECLARE_FLAGS(GeometryChangeTypes, GeometryChangeType) struct ChangeListener { - ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::ChangeTypes t) : listener(l), types(t), gTypes(GeometryChange) {} + ChangeListener(QQuickItemChangeListener *l = Q_NULLPTR, QQuickItemPrivate::ChangeTypes t = 0) : listener(l), types(t), gTypes(GeometryChange) {} ChangeListener(QQuickItemChangeListener *l, QQuickItemPrivate::GeometryChangeTypes gt) : listener(l), types(Geometry), gTypes(gt) {} QQuickItemChangeListener *listener; QQuickItemPrivate::ChangeTypes types; @@ -386,7 +385,7 @@ public: inline Qt::MouseButtons acceptedMouseButtons() const; - QPODVector<QQuickItemPrivate::ChangeListener,4> changeListeners; + QVector<QQuickItemPrivate::ChangeListener> changeListeners; void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types); void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types); @@ -935,6 +934,7 @@ QSGNode *QQuickItemPrivate::childContainerNode() } Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ChangeTypes) +Q_DECLARE_TYPEINFO(QQuickItemPrivate::ChangeListener, Q_PRIMITIVE_TYPE); QT_END_NAMESPACE diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index f843b09592..074af7ebdc 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2219,10 +2219,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 7bb52853bc..c7e476c4b5 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1313,10 +1313,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 */ diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h index d9c4baf572..652af3487f 100644 --- a/src/quick/items/qquickpathview_p_p.h +++ b/src/quick/items/qquickpathview_p_p.h @@ -61,6 +61,7 @@ #include <private/qquickanimation_p_p.h> #include <private/qqmldelegatemodel_p.h> #include <private/qquicktimeline_p_p.h> +#include <private/qpodvector_p.h> QT_BEGIN_NAMESPACE diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 33f44520fe..4dc59b100a 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1154,7 +1154,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/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 9b7eb4ea4b..65e066c611 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1042,6 +1042,7 @@ void QQuickTextInput::q_validatorChanged() QRectF QQuickTextInputPrivate::anchorRectangle() const { + Q_Q(const QQuickTextInput); QRectF rect; int a; // Unfortunately we cannot use selectionStart() and selectionEnd() @@ -1062,8 +1063,8 @@ QRectF QQuickTextInputPrivate::anchorRectangle() const a = 0; QTextLine l = m_textLayout.lineForTextPosition(a); if (l.isValid()) { - qreal x = l.cursorToX(a) - hscroll; - qreal y = l.y() - vscroll; + qreal x = l.cursorToX(a) - hscroll + q->leftPadding(); + qreal y = l.y() - vscroll + q->topPadding(); rect.setRect(x, y, 1, l.height()); } } diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index 650700e37a..afb9b673d9 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -103,8 +103,10 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &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()) { @@ -113,11 +115,13 @@ void QSGDefaultDistanceFieldGlyphCache::requestGlyphs(const QSet<glyph_t> &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); diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp index 4dd60c76f5..561eccdb0c 100644 --- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp +++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp @@ -317,7 +317,6 @@ void QSGDefaultPainterNode::updateRenderTarget() if (m_texture) delete m_texture; - texture->setTextureSize(m_size); m_texture = texture; } diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp index 83409e8b34..4139c87eda 100644 --- a/src/quick/util/qquickstyledtext.cpp +++ b/src/quick/util/qquickstyledtext.cpp @@ -658,10 +658,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<QStringRef,QStringRef> attr; do { @@ -698,14 +701,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<QStringRef,QStringRef> attr; do { attr = parseAttribute(ch, textIn); @@ -713,9 +718,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 ee3f42cb48..2a2e234224 100644 --- a/src/quick/util/qquickstyledtext_p.h +++ b/src/quick/util/qquickstyledtext_p.h @@ -68,7 +68,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; } @@ -83,6 +83,7 @@ public: QPointF pos; QSize size; int position; + qreal offset; // this offset allows us to compensate for flooring reserved space Align align; QQuickPixmap *pix; }; |