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(-) (limited to 'src/qml') 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 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 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/qml') 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); } -- 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/qml/jsruntime/qv4global_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qml') 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(-) (limited to 'src/qml') 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 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 --- 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 ++++++++++++++++++--------------- 5 files changed, 62 insertions(+), 72 deletions(-) (limited to 'src/qml') 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 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(-) (limited to 'src/qml') 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 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(-) (limited to 'src/qml') 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