From ba5bd2b87140c4751235619701bb84e993541f82 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 21 Oct 2016 18:38:50 +0200 Subject: Fix QML Compiler crash After commit 2afb54fb51091765f79548b0b057795bc3c6eb38, Primitive::undefinedValue() uses setM() to clear out all bits. Previously that code was #ifndef'ed out for the bootstrap build, but now that we can do the correct boxing in host builds (as we know the pointer size), we can re-enable setM() in bootstrap builds and fix this crash that was a Q_UNREACHABLE() assertion. Change-Id: I49036792c06c9a17272aba65261ab8f32beb2ad8 Task-number: QTBUG-56658 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll (cherry picked from commit 9f6ae7fce68d1592b71be7df7ebfffade60ef737) Reviewed-by: Oliver Wolff --- src/qml/jsruntime/qv4value_p.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index d588553778..d4399b46e4 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -175,10 +175,7 @@ public: Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); } Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; } -#if defined(V4_BOOTSTRAP) - 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) +#if defined(QV4_USE_64_BIT_VALUE_ENCODING) Q_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; -- cgit v1.2.3 From c5755267227a81e35052eb447895aa2f1428ebe1 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 12 Oct 2016 11:15:09 +0200 Subject: V4: Fix usage of QV4::Value tags/types These two were mixed, but have completely different values. Task-number: QTBUG-56471 (cherry picked from commit 9d2169a2d8b81b8707b20ab892550f4a55c07feb) Change-Id: I6745521ea4356acdd710285084cce8e965bfc072 Reviewed-by: Erik Verbruggen --- src/qml/jit/qv4isel_masm.cpp | 6 +++--- src/qml/jsruntime/qv4arraydata.cpp | 29 +++++++++++++++++------------ src/qml/jsruntime/qv4persistent.cpp | 2 +- src/qml/jsruntime/qv4value_p.h | 19 +++++++++++++++++++ src/qml/memory/qv4mm.cpp | 2 +- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 1bb62f40b6..859ecfbe64 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -971,7 +971,7 @@ void InstructionSelection::swapValues(IR::Expr *source, IR::Expr *target) tag = QV4::Value::Integer_Type_Internal; break; default: - tag = QV4::Value::Undefined_Type; + tag = 31337; // bogus value Q_UNREACHABLE(); } _as->store32(Assembler::TrustedImm32(tag), addr); @@ -1418,7 +1418,7 @@ void InstructionSelection::visitCJump(IR::CJump *s) Address temp = _as->loadAddress(Assembler::ScratchRegister, s->cond); Address tag = temp; tag.offset += QV4::Value::tagOffset(); - Assembler::Jump booleanConversion = _as->branch32(Assembler::NotEqual, tag, Assembler::TrustedImm32(QV4::Value::Boolean_Type)); + Assembler::Jump booleanConversion = _as->branch32(Assembler::NotEqual, tag, Assembler::TrustedImm32(QV4::Value::Boolean_Type_Internal)); Address data = temp; data.offset += QV4::Value::valueOffset(); @@ -1582,7 +1582,7 @@ void InstructionSelection::visitRet(IR::Ret *s) tag = QV4::Value::Boolean_Type_Internal; break; default: - tag = QV4::Value::Undefined_Type; + tag = 31337; // bogus value Q_UNREACHABLE(); } _as->or64(Assembler::TrustedImm64(tag << 32), diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 62ece57c41..ab29a2438f 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -100,7 +100,7 @@ Q_STATIC_ASSERT(sizeof(Heap::ArrayData) == sizeof(Heap::SparseArrayData)); static Q_ALWAYS_INLINE void storeValue(ReturnedValue *target, uint value) { Value v; - v.setTagValue(Value::fromReturnedValue(*target).tag(), value); + v.setEmpty(value); *target = v.asReturnedValue(); } @@ -189,6 +189,7 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt } else { sparse->sparse = new SparseArray; lastFree = &sparse->freeList; + storeValue(lastFree, 0); for (uint i = 0; i < toCopy; ++i) { if (!sparse->arrayData[i].isEmpty()) { SparseArrayNode *n = sparse->sparse->insert(i); @@ -209,6 +210,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt } storeValue(lastFree, UINT_MAX); } + + Q_ASSERT(Value::fromReturnedValue(sparse->freeList).isEmpty()); // ### Could explicitly free the old data } @@ -357,12 +360,12 @@ void SparseArrayData::free(Heap::ArrayData *d, uint idx) Value *v = d->arrayData + idx; if (d->attrs && d->attrs[idx].isAccessor()) { // double slot, free both. Order is important, so we have a double slot for allocation again afterwards. - v[1].setTagValue(Value::Empty_Type, Value::fromReturnedValue(d->freeList).value()); - v[0].setTagValue(Value::Empty_Type, idx + 1); + v[1].setEmpty(Value::fromReturnedValue(d->freeList).emptyValue()); + v[0].setEmpty(idx + 1); } else { - v->setTagValue(Value::Empty_Type, Value::fromReturnedValue(d->freeList).value()); + v->setEmpty(Value::fromReturnedValue(d->freeList).emptyValue()); } - d->freeList = idx; + d->freeList = Primitive::emptyValue(idx).asReturnedValue(); if (d->attrs) d->attrs[idx].clear(); } @@ -400,9 +403,9 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot) Q_ASSERT(dd->arrayData[Value::fromReturnedValue(*last).value()].value() != Value::fromReturnedValue(*last).value()); if (dd->arrayData[Value::fromReturnedValue(*last).value()].value() == (Value::fromReturnedValue(*last).value() + 1)) { // found two slots in a row - uint idx = Value::fromReturnedValue(*last).uint_32(); + uint idx = Value::fromReturnedValue(*last).emptyValue(); Value lastV = Value::fromReturnedValue(*last); - lastV.setTagValue(lastV.tag(), dd->arrayData[lastV.value() + 1].value()); + lastV.setEmpty(dd->arrayData[lastV.emptyValue() + 1].value()); *last = lastV.rawValue(); dd->attrs[idx] = Attr_Accessor; return idx; @@ -416,7 +419,8 @@ uint SparseArrayData::allocate(Object *o, bool doubleSlot) } uint idx = Value::fromReturnedValue(dd->freeList).value(); Q_ASSERT(idx != UINT_MAX); - dd->freeList = dd->arrayData[idx].uint_32(); + dd->freeList = dd->arrayData[idx].asReturnedValue(); + Q_ASSERT(Value::fromReturnedValue(dd->freeList).isEmpty()); if (dd->attrs) dd->attrs[idx] = Attr_Data; return idx; @@ -471,13 +475,14 @@ bool SparseArrayData::del(Object *o, uint index) if (isAccessor) { // free up both indices - dd->arrayData[pidx + 1].setTagValue(Value::Empty_Type, Value::fromReturnedValue(dd->freeList).value()); - dd->arrayData[pidx].setTagValue(Value::Undefined_Type, pidx + 1); + dd->arrayData[pidx + 1].setEmpty(Value::fromReturnedValue(dd->freeList).emptyValue()); + dd->arrayData[pidx].setEmpty(pidx + 1); } else { - dd->arrayData[pidx].setTagValue(Value::Empty_Type, Value::fromReturnedValue(dd->freeList).value()); + Q_ASSERT(dd->type == Heap::ArrayData::Sparse); + dd->arrayData[pidx].setEmpty(Value::fromReturnedValue(dd->freeList).emptyValue()); } - dd->freeList = pidx; + dd->freeList = Primitive::emptyValue(pidx).asReturnedValue(); dd->sparse->erase(n); return true; } diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 7ca0692804..a892194df3 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -139,7 +139,7 @@ PersistentValueStorage::Iterator &PersistentValueStorage::Iterator::operator++() while (p) { while (index < kEntriesPerPage - 1) { ++index; - if (static_cast(p)->values[index].tag() != QV4::Value::Empty_Type) + if (!static_cast(p)->values[index].isEmpty()) return *this; } index = -1; diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index d4399b46e4..9eee34aff2 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -223,6 +223,17 @@ public: setTagValue(Empty_Type_Internal, quint32(i)); } + Q_ALWAYS_INLINE void setEmpty(quint32 i) + { + setTagValue(Empty_Type_Internal, i); + } + + Q_ALWAYS_INLINE quint32 emptyValue() + { + Q_ASSERT(isEmpty()); + return quint32(value()); + } + enum Type { Undefined_Type, Managed_Type, @@ -527,6 +538,7 @@ ReturnedValue Heap::Base::asReturnedValue() const struct Q_QML_PRIVATE_EXPORT Primitive : public Value { inline static Primitive emptyValue(); + inline static Primitive emptyValue(uint v); static inline Primitive fromBoolean(bool b); static inline Primitive fromInt32(int i); inline static Primitive undefinedValue(); @@ -556,6 +568,13 @@ inline Primitive Primitive::emptyValue() return v; } +inline Primitive Primitive::emptyValue(uint e) +{ + Primitive v; + v.setEmpty(e); + return v; +} + inline Primitive Primitive::nullValue() { Primitive v; diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 990f6477d7..9924d37fdc 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -460,7 +460,7 @@ void MemoryManager::sweep(bool lastSweep) remainingWeakQObjectWrappers.reserve(pendingCount); for (int i = 0; i < pendingCount; ++i) { Value *v = m_pendingFreedObjectWrapperValue.at(i); - if (v->tag() == Value::Undefined_Type) + if (v->isUndefined() || v->isEmpty()) PersistentValueStorage::free(v); else remainingWeakQObjectWrappers.append(v); -- cgit v1.2.3 From 53eb106129a931625c9f06ac5d3f7fd6fa20a225 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Thu, 20 Oct 2016 12:51:54 +0300 Subject: Add changes file for 5.7.1 Change-Id: Ie6148c027d47bc7a297665acf5546e247c408b15 Reviewed-by: Gunnar Sletta Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- dist/changes-5.7.1 | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 dist/changes-5.7.1 diff --git a/dist/changes-5.7.1 b/dist/changes-5.7.1 new file mode 100644 index 0000000000..b9bdaedca3 --- /dev/null +++ b/dist/changes-5.7.1 @@ -0,0 +1,64 @@ +Qt 5.7.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.7.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.7 series is binary compatible with the 5.6.x series. +Applications compiled for 5.6 will continue to run with 5.7. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - [QTBUG-55935] AnimatedSprite will no longer cause scenegraph updates when not + visible + - [QTBUG-46263] Fix QObjects becoming undefined when used in multiple QML + engines + - [QTBUG-54238] qt.scenegraph.info logging category got renamed to + qt.scenegraph.general. + - [QTBUG-50592] QVariants (e.g. QUrl) will now be better handled by + JSON.stringify + - [QTBUG-37095] Canvas now properly supports high-DPI screens + - QQuickWidget now properly repaints text on high-DPI screen changes. + +**************************************************************************** +* Library * +**************************************************************************** + +QtQml +----- + + - [QTBUG-53412] Fix mapping of null JS values to null SQL values instead + of empty strings. + - [QTBUG-53794] Fix crash when using the "with" statement with an + expression that throws an exception. + - [QTBUG-54589] Fix assertion when deleting properties of JS objects + - [QTBUG-56658] Fix a crash in the QML compiler + - [QTBUG-53672] Fix crash caused by passing 0 to Array.join + +QtQuick +------- + + - The relevant child item is now sent a hover event when the window + receives a QEnterEvent, making sure hovering is recognized without + waiting for mouse movement. + - The threaded scene graph renderer does not sleep up to one vsync + interval before the first frame anymore. + - [QTBUG-56056] Fix crash when cancelling a QQuickImageResponse + - [QTBUG-39888] Fix crash with QQuickItems created via JavaScript being + garbage collected sometimes when they're not assigned to a window. + - [QTBUG-31861] Item: Fixed issue with mouse button events being sent even + when they were disabled by setAcceptedMouseButtons. + - [QTBUG-52389] Text: Fixed clipping of glyphs that extend beyond font's em + square. -- cgit v1.2.3 From 2a992040e2ef3f9dab087be3bfac05e28596672b Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 9 Nov 2016 16:06:56 +0100 Subject: Fix more cases where DSE would optimize out too many stores GCC5/6 do aggressive dead store elimination on memory passed to placement-new. This resulted in the Heap::Object::prototype being a nullptr. qml.pro already contained the -fno-lifetime-dse flag, but there are other places where we ask the memory manager to allocate data. This is temporary band-aid, and is already fixed in 5.8. Change-Id: Ia61a69f65fab351068a588cfc36b5b3d762ffc9f Task-number: QTBUG-56932 (cherry picked from commit f4ac007f4a19bc095ff15d415a6629986de78e49) Reviewed-by: Lars Knoll --- src/imports/particles/particles.pro | 5 +++++ src/quick/quick.pro | 5 +++++ tests/auto/qml/qqmlecmascript/qqmlecmascript.pro | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index 4460d03a04..fb9626c40e 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -3,6 +3,11 @@ TARGET = particlesplugin TARGETPATH = QtQuick/Particles.2 IMPORT_VERSION = 2.0 +greaterThan(QT_GCC_MAJOR_VERSION, 5) { + # Our code is bad. Temporary workaround. Fixed in 5.8 + QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse +} + SOURCES += \ plugin.cpp diff --git a/src/quick/quick.pro b/src/quick/quick.pro index 1c14ff8d57..f56fb2e081 100644 --- a/src/quick/quick.pro +++ b/src/quick/quick.pro @@ -13,6 +13,11 @@ exists("qqml_enable_gcov") { LIBS_PRIVATE += -lgcov } +greaterThan(QT_GCC_MAJOR_VERSION, 5) { + # Our code is bad. Temporary workaround. Fixed in 5.8 + QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse +} + QMAKE_DOCS = $$PWD/doc/qtquick.qdocconf ANDROID_LIB_DEPENDENCIES = \ diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro index 101181bba0..684e7adb98 100644 --- a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro +++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro @@ -13,6 +13,11 @@ RESOURCES += qqmlecmascript.qrc include (../../shared/util.pri) +greaterThan(QT_GCC_MAJOR_VERSION, 5) { + # Our code is bad. Temporary workaround. Fixed in 5.8 + QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse +} + # QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage # LIBS += -lgcov -- cgit v1.2.3 From 59c9993a6a0d25904d278aabafa9be767e977b77 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 15 Nov 2016 11:26:34 +0100 Subject: QML: Check for failing realloc/malloc in the QmlJS memory pool This should make (properly functioning) static code checkers stop complaining. Task-number: QTBUG-57025 Change-Id: Ic7e6f1b0b02f2e9324dbc891ab4620d53d9f9a18 Reviewed-by: Simon Hausmann --- src/qml/parser/qqmljsmemorypool_p.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/parser/qqmljsmemorypool_p.h b/src/qml/parser/qqmljsmemorypool_p.h index ae9f1d8257..a08e91f2c3 100644 --- a/src/qml/parser/qqmljsmemorypool_p.h +++ b/src/qml/parser/qqmljsmemorypool_p.h @@ -116,6 +116,7 @@ private: _allocatedBlocks *= 2; _blocks = (char **) realloc(_blocks, sizeof(char *) * _allocatedBlocks); + Q_CHECK_PTR(_blocks); for (int index = _blockCount; index < _allocatedBlocks; ++index) _blocks[index] = 0; @@ -123,8 +124,10 @@ private: char *&block = _blocks[_blockCount]; - if (! block) + if (! block) { block = (char *) malloc(BLOCK_SIZE); + Q_CHECK_PTR(block); + } _ptr = block; _end = _ptr + BLOCK_SIZE; -- cgit v1.2.3 From 4ef8b7e7a8a93b2921560db8cf021f89409154e5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 15 Nov 2016 13:48:43 +0100 Subject: Doc: improve FolderListModel::rootFolder documentation Change-Id: I33ca6140d89041f89f0e3db9db7206aca50361d7 Reviewed-by: Robin Burchell --- src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index d01fc5e74e..df83d50325 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -440,9 +440,9 @@ void QQuickFolderListModel::setFolder(const QUrl &folder) /*! \qmlproperty url FolderListModel::rootFolder - When the rootFolder is set, then this folder will - be threated as the root in the file system, so that - you can only travers sub folders from this rootFolder. + When this property is set, the given folder will + be treated as the root in the file system, so that + you can only traverse subfolders within it. */ QUrl QQuickFolderListModel::rootFolder() const { -- cgit v1.2.3 From 12b7e6bfe5a8fb7666a929090483921c3f99ae8a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 15 Nov 2016 14:44:21 +0100 Subject: Fix reading of enum properties from gadgets QMetaProperty::type() maps an un-registered enum to QMetaType::Int, and so if a property cache is created for a gadget with enum properties, then their type will be int and we'll correctly read enum properties as ints in JavaScript. However if the enum is registered at the time we create the cache, then the property type will be the specific type and not QMetaType::Int. The property reading code in QV4::QObjectWrapper can deal with that, but the property reading code in the gadget value type wrapper code did not. [ChangeLog][Qt][Qml] Fix reading of enum properties from gadgets / value types when the enum was registered with qRegisterMetaType(). Change-Id: I7812b216a276dcc95c36e313507e1a1142250d0b Reviewed-by: Erik Verbruggen --- src/qml/qml/qqmlvaluetypewrapper.cpp | 1 + .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 34 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 5486c14c38..810a2bdf2c 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -353,6 +353,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha // These four types are the most common used by the value type wrappers VALUE_TYPE_LOAD(QMetaType::QReal, qreal, qreal); + VALUE_TYPE_LOAD(QMetaType::Int || result->isEnum(), int, int); VALUE_TYPE_LOAD(QMetaType::Int, int, int); VALUE_TYPE_LOAD(QMetaType::QString, QString, v4->newString); VALUE_TYPE_LOAD(QMetaType::Bool, bool, bool); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 04abe0bfcb..e82df79acb 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -94,6 +94,7 @@ private slots: void customValueTypeInQml(); void gadgetInheritance(); void toStringConversion(); + void enumProperties(); private: QQmlEngine engine; @@ -1652,6 +1653,39 @@ void tst_qqmlvaluetypes::toStringConversion() QCOMPARE(stringConversion.toString(), StringLessGadget_to_QString(g)); } +struct GadgetWithEnum +{ + Q_GADGET +public: + + enum MyEnum { FirstValue, SecondValue }; + + Q_ENUM(MyEnum) + Q_PROPERTY(MyEnum enumProperty READ enumProperty) + + MyEnum enumProperty() const { return SecondValue; } +}; + +void tst_qqmlvaluetypes::enumProperties() +{ + QJSEngine engine; + + // When creating the property cache for the gadget when MyEnum is _not_ a registered + // meta-type, then QMetaProperty::type() will return QMetaType::Int and consequently + // property-read meta-calls will return an int (as expected in this test). However if we + // explicitly register the gadget, then QMetaProperty::type() will return the user-type + // and QQmlValueTypeWrapper should still handle that and return an integer/number for the + // enum property when it is read. + qRegisterMetaType(); + + GadgetWithEnum g; + QJSValue value = engine.toScriptValue(g); + + QJSValue enumValue = value.property("enumProperty"); + QVERIFY(enumValue.isNumber()); + QCOMPARE(enumValue.toInt(), int(g.enumProperty())); +} + QTEST_MAIN(tst_qqmlvaluetypes) -- cgit v1.2.3 From 835eac4ea0ded27c16e319177ef3087058808b0f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:06:01 +0100 Subject: QML: Change C++ benchmark to reflect QML benchmark The QQmlListReference will build a property cache entry, but it won't assign it to an engine when none is available (meaning: it would create the entry every time a QQmlListReference is created). QML won't do that, because it (obviously) has an engine available. Change-Id: I46eeaf3dffcb690902dd3d78be48c8509be6e84d Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/creation/tst_creation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index dbda07be5a..6c8d1eb21a 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -256,12 +256,13 @@ void tst_creation::itemtree_cpp() void tst_creation::itemtree_data_cpp() { + QQmlEngine engine; QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; QQmlGraphics_setParent_noEvent(child,item); - QQmlListReference ref(item, "data"); + QQmlListReference ref(item, "data", &engine); ref.append(child); } delete item; -- cgit v1.2.3 From 5718dac919c16e9c6c7b98043e1ecb74117af268 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Nov 2016 14:04:04 +0100 Subject: QML: Fix memory leak in a benchmark Change-Id: I64b671243a107c518da2000e2ffd964f441af037 Reviewed-by: Simon Hausmann Reviewed-by: Robin Burchell --- tests/benchmarks/qml/creation/tst_creation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp index 6c8d1eb21a..b9df0ca8b5 100644 --- a/tests/benchmarks/qml/creation/tst_creation.cpp +++ b/tests/benchmarks/qml/creation/tst_creation.cpp @@ -219,12 +219,15 @@ inline void QQmlGraphics_setParent_noEvent(QObject *object, QObject *parent) void tst_creation::itemtree_notree_cpp() { + std::vector kids; + kids.resize(30); QBENCHMARK { QQuickItem *item = new QQuickItem; for (int i = 0; i < 30; ++i) { QQuickItem *child = new QQuickItem; - Q_UNUSED(child); + kids[i] = child; } + qDeleteAll(kids); delete item; } } -- cgit v1.2.3 From a3fe91ba463fcd27d6e0a69b66bc389bd6470c46 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 17 Nov 2016 12:40:25 +0100 Subject: Doc: fix incorrect argument name for createQmlObject() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "string" is the argument type, not its name. Change-Id: Ia8f1afe01363eb6bfa69247aca5c0849c56000c4 Reviewed-by: Topi Reiniƶ --- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index b90fd7eb17..8cddd95fda 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. @@ -932,7 +932,7 @@ ReturnedValue QtObject::method_quit(CallContext *ctx) /*! \qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath) -Returns a new object created from the given \a string of QML which will have the specified \a parent, +Returns a new object created from the given \a qml string which will have the specified \a parent, or \c null if there was an error in creating the object. If \a filepath is specified, it will be used for error reporting for the created object. -- cgit v1.2.3 From 1969991c4a4bd39ee224b0fa3c8cffa51f061757 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 1 Sep 2016 16:46:29 +0200 Subject: Fix binding re-evaluation when list model properties change This is a regression from commit 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e, which avoided returning an expensive QObject when calling get() but also lost the ability to perform binding captures when accessing the properties. This change restores the captures by performing them by hand in get() and also triggering the notifiers directly when the values change, without creating the QObject. Task-number: QTBUG-52356 Change-Id: Ia429ffafd4032b63d3e592aa63bb0864a24e0965 Reviewed-by: Michael Brasser Reviewed-by: Lars Knoll --- src/qml/qml/qqmlnotifier.cpp | 6 +++ src/qml/qml/qqmlnotifier_p.h | 2 + src/qml/types/qqmllistmodel.cpp | 44 ++++++++++++++++++++-- src/qml/types/qqmllistmodel_p_p.h | 2 + .../qml/qqmllistmodel/data/bindingsOnGetResult.qml | 27 +++++++++++++ tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp | 13 +++++++ 6 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml diff --git a/src/qml/qml/qqmlnotifier.cpp b/src/qml/qml/qqmlnotifier.cpp index ea3f7a1530..e3f23b3e5d 100644 --- a/src/qml/qml/qqmlnotifier.cpp +++ b/src/qml/qml/qqmlnotifier.cpp @@ -65,6 +65,12 @@ namespace { }; } +void QQmlNotifier::notify(QQmlData *ddata, int notifierIndex) +{ + if (QQmlNotifierEndpoint *ep = ddata->notify(notifierIndex)) + emitNotify(ep, Q_NULLPTR); +} + void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a) { QVarLengthArray stack; diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index ac0aab892f..60ba041b4a 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -59,6 +59,8 @@ public: inline ~QQmlNotifier(); inline void notify(); + static void notify(QQmlData *ddata, int notifierIndex); + private: friend class QQmlData; friend class QQmlNotifierEndpoint; diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 3d71621290..299097d0c0 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -40,10 +40,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -52,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -1259,9 +1262,14 @@ ModelNodeMetaObject *ModelNodeMetaObject::get(QObject *obj) void ModelNodeMetaObject::updateValues() { - if (!m_initialized) + const int roleCount = m_model->m_listModel->roleCount(); + if (!m_initialized) { + int *changedRoles = reinterpret_cast(alloca(roleCount * sizeof(int))); + for (int i = 0; i < roleCount; ++i) + changedRoles[i] = i; + emitDirectNotifies(changedRoles, roleCount); return; - int roleCount = m_model->m_listModel->roleCount(); + } for (int i=0 ; i < roleCount ; ++i) { const ListLayout::Role &role = m_model->m_listModel->getExistingRole(i); QByteArray name = role.name.toUtf8(); @@ -1272,8 +1280,10 @@ void ModelNodeMetaObject::updateValues() void ModelNodeMetaObject::updateValues(const QVector &roles) { - if (!m_initialized) + if (!m_initialized) { + emitDirectNotifies(roles.constData(), roles.count()); return; + } int roleCount = roles.count(); for (int i=0 ; i < roleCount ; ++i) { int roleIndex = roles.at(i); @@ -1303,6 +1313,22 @@ void ModelNodeMetaObject::propertyWritten(int index) } } +// Does the emission of the notifiers when we haven't created the meta-object yet +void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCount) +{ + Q_ASSERT(!m_initialized); + QQmlData *ddata = QQmlData::get(object(), /*create*/false); + if (!ddata) + return; + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine(m_model)); + if (!ep) + return; + for (int i = 0; i < roleCount; ++i) { + const int changedRole = changedRoles[i]; + QQmlNotifier::notify(ddata, changedRole); + } +} + namespace QV4 { void ModelObject::put(Managed *m, String *name, const Value &value) @@ -1332,6 +1358,18 @@ ReturnedValue ModelObject::get(const Managed *m, String *name, bool *hasProperty return QObjectWrapper::get(m, name, hasProperty); if (hasProperty) *hasProperty = true; + + if (QQmlEngine *qmlEngine = that->engine()->qmlEngine()) { + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine); + if (ep && ep->propertyCapture) { + QObjectPrivate *op = QObjectPrivate::get(that->object()); + // Temporarily hide the dynamic meta-object, to prevent it from being created when the capture + // triggers a QObject::connectNotify() by calling obj->metaObject(). + QScopedValueRollback metaObjectBlocker(op->metaObject, 0); + ep->propertyCapture->captureProperty(that->object(), -1, role->index); + } + } + const int elementIndex = that->d()->m_elementIndex; QVariant value = that->d()->m_model->data(elementIndex, role->index); return that->engine()->fromVariant(value); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index d7e0defaec..f23fec1e59 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -146,6 +146,8 @@ private: setValue(name, val); } + void emitDirectNotifies(const int *changedRoles, int roleCount); + void initialize(); bool m_initialized; }; diff --git a/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml new file mode 100644 index 0000000000..6bf750dcda --- /dev/null +++ b/tests/auto/qml/qqmllistmodel/data/bindingsOnGetResult.qml @@ -0,0 +1,27 @@ +import QtQuick 2.0 + +QtObject { + property ListModel model: ListModel { + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + ListElement { modified: false } + } + + property bool isModified: { + for (var i = 0; i < model.count; ++i) { + if (model.get(i).modified) + return true; + } + return false; + } + + property bool success: false + Component.onCompleted: { + // trigger read and setup of property captures + success = isModified + model.setProperty(0, "modified", true) + success = isModified + } +} diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 6b1deceaf2..8a90be601a 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -127,6 +127,7 @@ private slots: void datetime_data(); void about_to_be_signals(); void modify_through_delegate(); + void bindingsOnGetResult(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -1474,6 +1475,18 @@ void tst_qqmllistmodel::modify_through_delegate() QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); } +void tst_qqmllistmodel::bindingsOnGetResult() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("bindingsOnGetResult.qml")); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); + + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + + QVERIFY(obj->property("success").toBool()); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" -- cgit v1.2.3 From 5ffd0d8be35cea57acbf1e8d7a740d3fab5cbe43 Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 11 Nov 2016 15:35:02 +0100 Subject: Text: Make use of the new cached isSmoothlyScaled attribute on QFontEngine Relies on qtbase/f2205c48c21a6b135f2f59d0cf46e72f90f9f0f4. Asking QFontDatabase whether or not the font can be smoothly scaled is expensive Now that the attribute is available on QFontEngine, we can bypass all that. Benchmark results from qmlbench on creation/delegates_text on a 2011 mbp. Before: Average: 173.2 ops/frame; using 5/5 samples; MedianAll=173; StdDev=1.94, CoV=0.0112 - StdDev (all samples included)=1.94 After: Average: 180.8 ops/frame; using 5/5 samples; MedianAll=182; StdDev=1.94, CoV=0.0107 - StdDev (all samples included)=1.94 Change-Id: I56efd903037a29ee014de0cbf482cfbef7fce494 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnode.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 2c7ab254f8..f91c8de634 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -93,10 +93,12 @@ QSGGlyphNode *QQuickTextNode::addGlyphs(const QPointF &position, const QGlyphRun bool preferNativeGlyphNode = m_useNativeRenderer; if (!preferNativeGlyphNode) { QRawFontPrivate *fontPriv = QRawFontPrivate::get(font); - if (fontPriv->fontEngine->hasUnreliableGlyphOutline()) + if (fontPriv->fontEngine->hasUnreliableGlyphOutline()) { preferNativeGlyphNode = true; - else - preferNativeGlyphNode = !QFontDatabase().isSmoothlyScalable(font.familyName(), font.styleName()); + } else { + QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; + preferNativeGlyphNode = !fe->isSmoothlyScalable; + } } QSGGlyphNode *node = sg->sceneGraphContext()->createGlyphNode(sg, preferNativeGlyphNode); -- cgit v1.2.3 From b160cd4eda1c2a8284f4eb0d10e715f98c8bda88 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 10:20:47 +0100 Subject: Allow for the QML engine to run on "hardened" Linux systems Similar to WinRT let's test whether we can allocate executable memory before enabling the JIT. The caller code will fall back to the interpreter. Task-number: QTBUG-56758 Change-Id: I63d6830c6acc8cb316333162be212e1764483baa Reviewed-by: Erik Verbruggen --- src/3rdparty/masm/wtf/OSAllocatorPosix.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp index bbf11e4488..0c902c7172 100644 --- a/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp +++ b/src/3rdparty/masm/wtf/OSAllocatorPosix.cpp @@ -191,6 +191,16 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes) bool OSAllocator::canAllocateExecutableMemory() { + int flags = MAP_PRIVATE | MAP_ANON; +#if PLATFORM(IOS) + if (executable) + flags |= MAP_JIT; +#endif + const auto size = pageSize(); + void *testPage = mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, flags, /*fd*/-1, /*offset*/0); + if (testPage == MAP_FAILED) + return false; + munmap(testPage, size); return true; } -- cgit v1.2.3 From c4ebe96c34c2179d0ebdc555afdce179e3de52e8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:16:09 +0100 Subject: Improved robustness of the optimizer when removing expressions For example during dead code elimination we may invalidate statements, but at the same time there may still be instances left in the work list of optimizeSSA(). When we encounter then, we should not process them any further. Task-number: QTBUG-56255 Change-Id: I4c24b1a225ce1bde112172e9606f91c426c19f19 Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4ssa.cpp | 15 ++++++--------- tests/auto/qml/qjsengine/tst_qjsengine.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index f20dbbf4fe..93692b3996 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -1968,14 +1968,9 @@ public: return *this; } - bool isEmpty() const - { - return worklistSize == 0; - } - Stmt *takeNext(Stmt *last) { - if (isEmpty()) + if (worklistSize == 0) return 0; const int startAt = last ? last->id() + 1 : 0; @@ -1991,6 +1986,10 @@ public: --worklistSize; Stmt *s = stmts.at(pos); Q_ASSERT(s); + + if (removed.at(s->id())) + return takeNext(s); + return s; } @@ -3960,9 +3959,7 @@ void optimizeSSA(StatementWorklist &W, DefUses &defUses, DominatorTree &df) ExprReplacer replaceUses(defUses, function); Stmt *s = 0; - while (!W.isEmpty()) { - s = W.takeNext(s); - Q_ASSERT(s); + while ((s = W.takeNext(s))) { if (Phi *phi = s->asPhi()) { // dead code elimination: diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 6cbafbf055..781f3f93e4 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -197,6 +197,8 @@ private slots: void withNoContext(); void holeInPropertyData(); + void malformedExpression(); + signals: void testSignal(); }; @@ -3872,6 +3874,12 @@ void tst_QJSEngine::holeInPropertyData() QVERIFY(ok.toBool()); } +void tst_QJSEngine::malformedExpression() +{ + QJSEngine engine; + engine.evaluate("5%55555&&5555555\n7-0"); +} + QTEST_MAIN(tst_QJSEngine) #include "tst_qjsengine.moc" -- cgit v1.2.3 From c712f638a0a3ad2a71a9a18601fd320dabd50f16 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 23 Nov 2016 13:56:34 +0100 Subject: V4: Fix JIT codegen for null/undefined conditional jumps When checking for undefined, both the tag and the value need to be checked. When loading the tag, it shouldn't end up in the same register that is used to hold the address of the QV4::Value. Change-Id: I380fce432ba489fdabe569dd2c9cac31e9905260 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4isel_masm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 05afc1ee77..4a201200fa 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -1871,7 +1871,7 @@ bool InstructionSelection::visitCJumpStrictUndefined(IR::Binop *binop, Assembler::RelationalCondition cond = binop->op == IR::OpStrictEqual ? Assembler::Equal : Assembler::NotEqual; - const Assembler::RegisterID tagReg = Assembler::ScratchRegister; + const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister; #ifdef QV4_USE_64_BIT_VALUE_ENCODING Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, varSrc); _as->load64(addr, tagReg); @@ -1970,7 +1970,7 @@ bool InstructionSelection::visitCJumpNullUndefined(IR::Type nullOrUndef, IR::Bin Assembler::Pointer tagAddr = _as->loadAddress(Assembler::ScratchRegister, varSrc); tagAddr.offset += 4; - const Assembler::RegisterID tagReg = Assembler::ScratchRegister; + const Assembler::RegisterID tagReg = Assembler::ReturnValueRegister; _as->load32(tagAddr, tagReg); if (binop->op == IR::OpNotEqual) -- cgit v1.2.3 From 2837f1c868b92e7cc8293064ff7ec3f76cdf6c7b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 24 Nov 2016 11:50:45 +0100 Subject: QmlProfiler: Explicitly specify the offsets for scene graph events The profiler can be switched on in the middle of a frame. In that case the last offset into the timing data would be some random number, which may lead to a crash when recording the sample. However, as we know all the data points we are going to record, we can as well specify where they are supposed to go. The timings themselves may still be random for frames of which we only recorded parts, but the clients can deal with this. Task-number: QTBUG-57304 Change-Id: I1d507f2591516e43d5b3cd25f7939716f2b64ed9 Reviewed-by: Simon Hausmann --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 6 +- src/quick/scenegraph/coreapi/qsgrenderer.cpp | 12 +- src/quick/scenegraph/qsgadaptationlayer.cpp | 4 +- src/quick/scenegraph/qsgrenderloop.cpp | 12 +- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 24 ++-- src/quick/scenegraph/qsgwindowsrenderloop.cpp | 21 ++-- src/quick/scenegraph/util/qsgatlastexture.cpp | 17 ++- src/quick/scenegraph/util/qsgtexture.cpp | 18 ++- src/quick/util/qquickprofiler_p.h | 140 +++++++++++++++------- 9 files changed, 172 insertions(+), 82 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 525d702a76..45fb857fb3 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -163,7 +163,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterial(QSGMaterial *material) qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame, + QQuickProfiler::SceneGraphContextMaterialCompile); rewrittenShaders[type] = shader; return shader; @@ -194,7 +195,8 @@ ShaderManager::Shader *ShaderManager::prepareMaterialNoRewrite(QSGMaterial *mate qCDebug(QSG_LOG_TIME_COMPILATION, "shader compiled in %dms (no rewrite)", (int) qsg_renderer_timer.elapsed()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphContextFrame, + QQuickProfiler::SceneGraphContextMaterialCompile); return shader; } diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 775277e588..bd60454a50 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -199,7 +199,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) bindable.bind(); if (profileFrames) bindTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererBinding); // Sanity check that attribute registers are disabled if (qsg_sanity_check) { @@ -217,7 +218,8 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) render(); if (profileFrames) renderTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererRender); m_is_rendering = false; m_changed_emitted = false; @@ -281,13 +283,15 @@ void QSGRenderer::preprocess() bool profileFrames = QSG_LOG_TIME_RENDERER().isDebugEnabled(); if (profileFrames) preprocessTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererPreprocess); nodeUpdater()->updateStates(root); if (profileFrames) updatePassTime = frameTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, + QQuickProfiler::SceneGraphRendererUpdate); } void QSGRenderer::addNodesToPreprocess(QSGNode *node) diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index bf97133e97..f32829c2ea 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -179,7 +179,8 @@ void QSGDistanceFieldGlyphCache::update() int count = m_pendingGlyphs.size(); if (profileFrames) renderTime = qsg_render_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphAdaptationLayerFrame, + QQuickProfiler::SceneGraphAdaptationLayerGlyphRender); m_pendingGlyphs.reset(); @@ -200,6 +201,7 @@ void QSGDistanceFieldGlyphCache::update() int((now - (renderTime / 1000000)))); } Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(QQuickProfiler::SceneGraphAdaptationLayerFrame, + QQuickProfiler::SceneGraphAdaptationLayerGlyphStore, (qint64)count); } diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 68947d3a3c..8fba301c4e 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -383,7 +383,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) polishTime = renderTimer.nsecsElapsed(); Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, - QQuickProfiler::SceneGraphRenderLoopFrame); + QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphPolishPolish); emit window->afterAnimating(); @@ -391,13 +392,15 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) syncTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); cd->renderSceneGraph(window->size()); if (profileFrames) renderTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); if (data.grabOnly) { bool alpha = window->format().alphaBufferSize() > 0 && window->color().alpha() != 255; @@ -414,7 +417,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) qint64 swapTime = 0; if (profileFrames) swapTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) { static QTime lastFrameTime = QTime::currentTime(); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index ceb3caa53f..c9cc3b9fa0 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -591,7 +591,8 @@ void QSGRenderThread::syncAndRender() if (profileFrames) syncTime = threadTimer.nsecsElapsed(); #endif - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); if (!syncResultedInChanges && !repaintRequested && sgrc->isValid()) { qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- no changes, render aborted"; @@ -623,12 +624,14 @@ void QSGRenderThread::syncAndRender() d->renderSceneGraph(windowSize); if (profileFrames) renderTime = threadTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); if (!d->customRenderStage || !d->customRenderStage->swap()) gl->swapBuffers(window); d->fireFrameSwapped(); } else { - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync, 1); qCDebug(QSG_LOG_RENDERLOOP) << QSG_RT_PAD << "- window not ready, skipping render"; } @@ -653,7 +656,8 @@ void QSGRenderThread::syncAndRender() int(threadTimer.elapsed() - renderTime / 1000000)); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); } @@ -1158,7 +1162,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) if (profileFrames) polishTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncPolish); w->updateDuringSync = false; @@ -1173,7 +1178,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) qCDebug(QSG_LOG_RENDERLOOP) << "- wait for sync"; if (profileFrames) waitTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncWait); w->thread->waitCondition.wait(&w->thread->mutex); m_lockedForSync = false; w->thread->mutex.unlock(); @@ -1181,7 +1187,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) if (profileFrames) syncTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncSync); if (m_animation_timer == 0 && m_animation_driver->isRunning()) { qCDebug(QSG_LOG_RENDERLOOP) << "- advancing animations"; @@ -1202,7 +1209,8 @@ void QSGThreadedRenderLoop::polishAndSync(Window *w, bool inExpose) << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on Gui thread) " << window; - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncAnimations); } bool QSGThreadedRenderLoop::event(QEvent *e) diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 04a46bf929..510d65398d 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -61,9 +61,9 @@ static QElapsedTimer qsg_render_timer; if (QSG_LOG_TIME_RENDERLOOP().isDebugEnabled()) \ sampleName = qsg_render_timer.nsecsElapsed(); \ -#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName) \ +#define QSG_RENDER_TIMING_SAMPLE(frameType, sampleName, position) \ QSG_LOG_TIME_SAMPLE(sampleName) \ - Q_QUICK_SG_PROFILE_RECORD(frameType); + Q_QUICK_SG_PROFILE_RECORD(frameType, position); QSGWindowsRenderLoop::QSGWindowsRenderLoop() @@ -389,7 +389,7 @@ void QSGWindowsRenderLoop::render() "animations ticked in %dms", int((qsg_render_timer.nsecsElapsed() - time_start)/1000000)); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphWindowsAnimations, 1); // It is not given that animations triggered another maybeUpdate() // and thus another render pass, so to keep things running, @@ -440,22 +440,26 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) d->polishItems(); QSG_LOG_TIME_SAMPLE(time_polished); Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, - QQuickProfiler::SceneGraphRenderLoopFrame); + QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphPolishPolish); emit window->afterAnimating(); RLDEBUG(" - syncing"); d->syncSceneGraph(); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_synced, + QQuickProfiler::SceneGraphRenderLoopSync); RLDEBUG(" - rendering"); d->renderSceneGraph(window->size()); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_rendered, + QQuickProfiler::SceneGraphRenderLoopRender); RLDEBUG(" - swapping"); if (!d->customRenderStage || !d->customRenderStage->swap()) m_gl->swapBuffers(window); - QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped); + QSG_RENDER_TIMING_SAMPLE(QQuickProfiler::SceneGraphRenderLoopFrame, time_swapped, + QQuickProfiler::SceneGraphRenderLoopSwap); RLDEBUG(" - frameDone"); d->fireFrameSwapped(); @@ -468,7 +472,8 @@ void QSGWindowsRenderLoop::renderWindow(QQuickWindow *window) << ", swap=" << (time_swapped - time_rendered) / 1000000 << " - " << window; - Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); } QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index e163191c6e..d26629900f 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -388,9 +388,12 @@ void Atlas::bind(QSGTexture::Filtering filtering) bool profileFrames = QSG_LOG_TIME_TEXTURE().isDebugEnabled(); if (profileFrames) qsg_renderer_timer.start(); - // Skip bind, convert, swizzle; they're irrelevant + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphTexturePrepare); - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 3); + + // Skip bind, convert, swizzle; they're irrelevant + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareStart, 3); Texture *t = m_pending_uploads.at(i); if (m_externalFormat == GL_BGRA && @@ -408,10 +411,14 @@ void Atlas::bind(QSGTexture::Filtering filtering) << "ms (" << t->textureSize().width() << "x" << t->textureSize().height() << ")"; + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload); + // Skip mipmap; unused - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, 1); - Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload, 1); + Q_QUICK_SG_PROFILE_REPORT(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareMipmap); } GLenum f = filtering == QSGTexture::Nearest ? GL_NEAREST : GL_LINEAR; diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index df9e569ca3..7625130dfe 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -646,7 +646,8 @@ void QSGPlainTexture::bind() (int) qsg_renderer_timer.elapsed(), m_texture_size.width(), m_texture_size.height()); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTextureDeletion, + QQuickProfiler::SceneGraphTextureDeletionDelete); } m_texture_id = 0; m_texture_size = QSize(); @@ -662,7 +663,8 @@ void QSGPlainTexture::bind() qint64 bindTime = 0; if (profileFrames) bindTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareBind); // ### TODO: check for out-of-memory situations... @@ -703,7 +705,8 @@ void QSGPlainTexture::bind() qint64 convertTime = 0; if (profileFrames) convertTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareConvert); updateBindOptions(m_dirty_bind_options); @@ -746,14 +749,16 @@ void QSGPlainTexture::bind() qint64 swizzleTime = 0; if (profileFrames) swizzleTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareSwizzle); funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, m_texture_size.width(), m_texture_size.height(), 0, externalFormat, GL_UNSIGNED_BYTE, tmp.constBits()); qint64 uploadTime = 0; if (profileFrames) uploadTime = qsg_renderer_timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareUpload); if (mipmapFiltering() != QSGTexture::None) { funcs->glGenerateMipmap(GL_TEXTURE_2D); @@ -776,7 +781,8 @@ void QSGPlainTexture::bind() int((mipmapTime - uploadTime)/1000000), m_texture_size != m_image.size() ? " (scaled to GL_MAX_TEXTURE_SIZE)" : ""); } - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphTexturePrepare, + QQuickProfiler::SceneGraphTexturePrepareMipmap); m_texture_rect = QRectF(0, 0, 1, 1); diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h index 6b6e7fa062..7aff1605c6 100644 --- a/src/quick/util/qquickprofiler_p.h +++ b/src/quick/util/qquickprofiler_p.h @@ -64,37 +64,52 @@ QT_BEGIN_NAMESPACE #define Q_QUICK_PROFILE(feature, Method)\ Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method) +// Record current timestamp for \a Type at position 0. #define Q_QUICK_SG_PROFILE_START(Type)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ (QQuickProfiler::startSceneGraphFrame())) -#define Q_QUICK_SG_PROFILE_RECORD(Type)\ +// Record current timestamp for \a Type at \a position. +#define Q_QUICK_SG_PROFILE_RECORD(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::recordSceneGraphTimestamp())) + (QQuickProfiler::recordSceneGraphTimestamp(position))) -#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\ +// Use the timestamp for \a Type at position \a position and repeat it \a Skip times in subsequent +// positions. +#define Q_QUICK_SG_PROFILE_SKIP(Type, position, Skip)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::skipSceneGraphTimestamps())) + (QQuickProfiler::skipSceneGraphTimestamps(position))) +// Record current timestamp for both \a Type1 and \a Type2 at position 0. #define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ (QQuickProfiler::startSceneGraphFrame())) -#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \ +// report \a Type1, using the current timestamp at \a position, and switch to \a Typ2, using +// the current timestamp at position 0. +#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(\ + position))) -#define Q_QUICK_SG_PROFILE_REPORT(Type)\ +// report \a Type, using data points 0 to \a position, including \a position. +#define Q_QUICK_SG_PROFILE_REPORT(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(position))) -#define Q_QUICK_SG_PROFILE_END(Type)\ +// report \a Type, using data points 0 to \a position, including \a position, and setting the +// timestamp at \a position to the current one. +#define Q_QUICK_SG_PROFILE_END(Type, position)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame())) + (QQuickProfiler::reportSceneGraphFrame(position))) -#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\ +// report \a Type, using data points 0 to \a position, including \a position, and setting the +// timestamp at \a position to the current one. Remaining data points up to position 5 are filled +// with \a Payload. +#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, position, Payload)\ Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame(Payload))) + (QQuickProfiler::reportSceneGraphFrame(position,\ + Payload))) #define Q_QUICK_INPUT_PROFILE(Method)\ @@ -173,7 +188,6 @@ private: template struct TimingData { qint64 values[size][s_numSceneGraphTimings + 1]; - int offsets[size]; }; QThreadStorage > renderThreadTimings; @@ -188,15 +202,6 @@ public: else return guiThreadTimings.values[type - NumRenderThreadFrameTypes]; } - - template - int &offset() - { - if (type < NumRenderThreadFrameTypes) - return renderThreadTimings.localData().offsets[type]; - else - return guiThreadTimings.offsets[type - NumRenderThreadFrameTypes]; - } }; class Q_QUICK_PRIVATE_EXPORT QQuickProfiler : public QQmlAbstractProfilerAdapter { @@ -208,6 +213,59 @@ public: RenderThread }; + enum SceneGraphContextStage { + SceneGraphContextStart, + SceneGraphContextMaterialCompile + }; + + enum SceneGraphRendererStage { + SceneGraphRendererStart, + SceneGraphRendererPreprocess, + SceneGraphRendererUpdate, + SceneGraphRendererBinding, + SceneGraphRendererRender + }; + + enum SceneGraphAdaptationLayerStage { + SceneGraphAdaptationLayerStart, + SceneGraphAdaptationLayerGlyphRender, + SceneGraphAdaptationLayerGlyphStore + }; + + enum SceneGraphRenderLoopStage { + SceneGraphRenderLoopStart, + SceneGraphRenderLoopSync, + SceneGraphRenderLoopRender, + SceneGraphRenderLoopSwap + }; + + enum SceneGraphPolishStage { + SceneGraphPolishStart, + SceneGraphPolishPolish + }; + + enum SceneGraphPolishAndSyncStage { + SceneGraphPolishAndSyncStart, + SceneGraphPolishAndSyncPolish, + SceneGraphPolishAndSyncWait, + SceneGraphPolishAndSyncSync, + SceneGraphPolishAndSyncAnimations + }; + + enum SceneGraphTexturePrepareStage { + SceneGraphTexturePrepareStart, + SceneGraphTexturePrepareBind, + SceneGraphTexturePrepareConvert, + SceneGraphTexturePrepareSwizzle, + SceneGraphTexturePrepareUpload, + SceneGraphTexturePrepareMipmap + }; + + enum SceneGraphTextureDeletionStage { + SceneGraphTextureDeletionStart, + SceneGraphTextureDeletionDelete + }; + template static void addEvent() { @@ -230,7 +288,6 @@ public: static void startSceneGraphFrame() { startSceneGraphFrame(); - s_instance->m_sceneGraphData.offset() = 0; s_instance->m_sceneGraphData.timings()[0] = s_instance->m_sceneGraphData.timings()[0]; } @@ -238,50 +295,45 @@ public: template static void startSceneGraphFrame() { - s_instance->m_sceneGraphData.offset() = 0; s_instance->m_sceneGraphData.timings()[0] = s_instance->timestamp(); } template - static void recordSceneGraphTimestamp() + static void recordSceneGraphTimestamp(uint position) { - s_instance->m_sceneGraphData.timings() - [++s_instance->m_sceneGraphData.offset()] = s_instance->timestamp(); + s_instance->m_sceneGraphData.timings()[position] = s_instance->timestamp(); } template - static void skipSceneGraphTimestamps() + static void skipSceneGraphTimestamps(uint position) { qint64 *timings = s_instance->m_sceneGraphData.timings(); - const qint64 last = timings[s_instance->m_sceneGraphData.offset()]; + const qint64 last = timings[position]; for (uint i = 0; i < Skip; ++i) - timings[++s_instance->m_sceneGraphData.offset()] = last; + timings[++position] = last; } template - static void reportSceneGraphFrame(quint64 payload = ~0) + static void reportSceneGraphFrame(uint position, quint64 payload = ~0) { qint64 *timings = s_instance->m_sceneGraphData.timings(); - int &offset = s_instance->m_sceneGraphData.offset(); if (Record) - timings[++offset] = s_instance->timestamp(); + timings[position] = s_instance->timestamp(); s_instance->processMessage(QQuickProfilerData( - timings[offset], 1 << SceneGraphFrame, 1 << FrameType, - offset > 0 ? timings[1] - timings[0] : payload, - offset > 1 ? timings[2] - timings[1] : payload, - offset > 2 ? timings[3] - timings[2] : payload, - offset > 3 ? timings[4] - timings[3] : payload, - offset > 4 ? timings[5] - timings[4] : payload)); + timings[position], 1 << SceneGraphFrame, 1 << FrameType, + position > 0 ? timings[1] - timings[0] : payload, + position > 1 ? timings[2] - timings[1] : payload, + position > 2 ? timings[3] - timings[2] : payload, + position > 3 ? timings[4] - timings[3] : payload, + position > 4 ? timings[5] - timings[4] : payload)); } template - static void reportSceneGraphFrame(quint64 payload = ~0) + static void reportSceneGraphFrame(uint position, quint64 payload = ~0) { - reportSceneGraphFrame(payload); - s_instance->m_sceneGraphData.offset() = 0; + reportSceneGraphFrame(position, payload); s_instance->m_sceneGraphData.timings()[0] = - s_instance->m_sceneGraphData.timings() - [s_instance->m_sceneGraphData.offset()]; + s_instance->m_sceneGraphData.timings()[position]; } template -- cgit v1.2.3 From 4fae8ff1e73eeb48734b28a9c846fbdff1c2ffe1 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 25 Nov 2016 11:17:12 +0100 Subject: Doc: fix incorrect syntax in "Code-Behind Implementation Resource" Change-Id: Ie86302f12d4ad65ff46335a1ea248bbb4c5559f3 Task-number: QTBUG-56008 Reviewed-by: J-P Nurmi --- src/qml/doc/src/javascript/resources.qdoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qml/doc/src/javascript/resources.qdoc b/src/qml/doc/src/javascript/resources.qdoc index b831e2ba70..4f9b40f1d7 100644 --- a/src/qml/doc/src/javascript/resources.qdoc +++ b/src/qml/doc/src/javascript/resources.qdoc @@ -78,13 +78,13 @@ Rectangle { \code // my_button_impl.js -property var clickCount = 0; // this state is separate for each instance of MyButton -function onClicked(btn) { +var clickCount = 0; // this state is separate for each instance of MyButton +function onClicked(button) { clickCount += 1; if ((clickCount % 5) == 0) { - obj.color = Qt.rgba(1,0,0,1); + button.color = Qt.rgba(1,0,0,1); } else { - obj.color = Qt.rgba(0,1,0,1); + button.color = Qt.rgba(0,1,0,1); } } \endcode -- cgit v1.2.3 From ea9d6955f4c1c1141d0909ddb32abb59c032ac3c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 Nov 2016 16:46:35 +0100 Subject: D3D12: Output error messages Format error messages via struct _com_error. Change-Id: Ice755597ec56a106e9fc5ac0288b69d9411a6ea8 Reviewed-by: Laszlo Agocs --- src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp | 72 +++++++++++++++++-------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp index caf64ebb8b..908f1221ab 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp @@ -61,6 +61,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE // NOTE: Avoid categorized logging. It is slow. @@ -98,6 +100,19 @@ static const int BUCKETS_PER_HEAP = 8; // must match freeMap static const int DESCRIPTORS_PER_BUCKET = 32; // the bit map (freeMap) is quint32 static const int MAX_DESCRIPTORS_PER_HEAP = BUCKETS_PER_HEAP * DESCRIPTORS_PER_BUCKET; +static QString comErrorMessage(HRESULT hr) +{ +#ifndef Q_OS_WINRT + const _com_error comError(hr); +#else + const _com_error comError(hr, nullptr); +#endif + QString result = QLatin1String("Error 0x") + QString::number(ulong(hr), 16); + if (const wchar_t *msg = comError.ErrorMessage()) + result += QLatin1String(": ") + QString::fromWCharArray(msg); + return result; +} + D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DESCRIPTOR_HEAP_TYPE type) { D3D12_CPU_DESCRIPTOR_HANDLE h = {}; @@ -128,7 +143,8 @@ D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DES HRESULT hr = m_device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&heap.heap)); if (FAILED(hr)) { - qWarning("Failed to create heap with type 0x%x: %x", type, hr); + qWarning("Failed to create heap with type 0x%x: %s", + type, qPrintable(comErrorMessage(hr))); return h; } @@ -211,7 +227,8 @@ static void getHardwareAdapter(IDXGIFactory1 *factory, IDXGIAdapter1 **outAdapte *outAdapter = adapter.Detach(); return; } else { - qWarning("Failed to create device for requested adapter '%s': 0x%x", qPrintable(name), hr); + qWarning("Failed to create device for requested adapter '%s': %s", + qPrintable(name), qPrintable(comErrorMessage(hr))); } } } @@ -270,7 +287,7 @@ void QSGD3D12DeviceManager::ensureCreated() HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(&m_factory)); if (FAILED(hr)) { - qWarning("Failed to create DXGI: 0x%x", hr); + qWarning("Failed to create DXGI: %s", qPrintable(comErrorMessage(hr))); return; } @@ -283,7 +300,7 @@ void QSGD3D12DeviceManager::ensureCreated() if (SUCCEEDED(hr)) warp = false; else - qWarning("Failed to create device: 0x%x", hr); + qWarning("Failed to create device: %s", qPrintable(comErrorMessage(hr))); } if (warp) { @@ -291,7 +308,7 @@ void QSGD3D12DeviceManager::ensureCreated() m_factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter)); HRESULT hr = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)); if (FAILED(hr)) { - qWarning("Failed to create WARP device: 0x%x", hr); + qWarning("Failed to create WARP device: %s", qPrintable(comErrorMessage(hr))); return; } } @@ -798,15 +815,18 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int if (SUCCEEDED(hr)) { hr = dcompDevice->CreateVisual(&dcompVisual); if (FAILED(hr)) { - qWarning("Failed to create DirectComposition visual: 0x%x", hr); + qWarning("Failed to create DirectComposition visual: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("Failed to create DirectComposition target: 0x%x", hr); + qWarning("Failed to create DirectComposition target: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("Failed to create DirectComposition device: 0x%x", hr); + qWarning("Failed to create DirectComposition device: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } @@ -833,11 +853,13 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int if (SUCCEEDED(hr)) { hr = dcompTarget->SetRoot(dcompVisual.Get()); if (FAILED(hr)) { - qWarning("SetRoot failed for DirectComposition target: 0x%x", hr); + qWarning("SetRoot failed for DirectComposition target: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("SetContent failed for DirectComposition visual: 0x%x", hr); + qWarning("SetContent failed for DirectComposition visual: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { @@ -867,11 +889,12 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int ComPtr baseSwapChain; HRESULT hr = dev->dxgi()->CreateSwapChain(commandQueue.Get(), &swapChainDesc, &baseSwapChain); if (FAILED(hr)) { - qWarning("Failed to create swap chain: 0x%x", hr); + qWarning("Failed to create swap chain: %s", qPrintable(comErrorMessage(hr))); return; } - if (FAILED(baseSwapChain.As(&swapChain))) { - qWarning("Failed to cast swap chain"); + hr = baseSwapChain.As(&swapChain); + if (FAILED(hr)) { + qWarning("Failed to cast swap chain: %s", qPrintable(comErrorMessage(hr))); return; } } @@ -1165,7 +1188,7 @@ void QSGD3D12EnginePrivate::setWindowSize(const QSize &size, float dpr) deviceManager()->deviceLossDetected(); return; } else if (FAILED(hr)) { - qWarning("Failed to resize buffers: 0x%x", hr); + qWarning("Failed to resize buffers: %s", qPrintable(comErrorMessage(hr))); return; } @@ -1188,7 +1211,7 @@ QSGD3D12CPUWaitableFence *QSGD3D12EnginePrivate::createCPUWaitableFence() const QSGD3D12CPUWaitableFence *f = new QSGD3D12CPUWaitableFence; HRESULT hr = device->CreateFence(f->value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&f->fence)); if (FAILED(hr)) { - qWarning("Failed to create fence: 0x%x", hr); + qWarning("Failed to create fence: %s", qPrintable(comErrorMessage(hr))); return f; } f->event = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -1202,7 +1225,7 @@ void QSGD3D12EnginePrivate::waitForGPU(QSGD3D12CPUWaitableFence *f) const if (f->fence->GetCompletedValue() < newValue) { HRESULT hr = f->fence->SetEventOnCompletion(newValue, f->event); if (FAILED(hr)) { - qWarning("SetEventOnCompletion failed: 0x%x", hr); + qWarning("SetEventOnCompletion failed: %s", qPrintable(comErrorMessage(hr))); return; } WaitForSingleObject(f->event, INFINITE); @@ -1283,7 +1306,7 @@ ID3D12Resource *QSGD3D12EnginePrivate::createBuffer(int size) HRESULT hr = device->CreateCommittedResource(&uploadHeapProp, D3D12_HEAP_FLAG_NONE, &bufDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&buf)); if (FAILED(hr)) - qWarning("Failed to create buffer resource: 0x%x", hr); + qWarning("Failed to create buffer resource: %s", qPrintable(comErrorMessage(hr))); return buf; } @@ -1640,7 +1663,7 @@ void QSGD3D12EnginePrivate::endDrawCalls(bool lastInFrame) // Go! HRESULT hr = frameCommandList->Close(); if (FAILED(hr)) { - qWarning("Failed to close command list: 0x%x", hr); + qWarning("Failed to close command list: %s", qPrintable(comErrorMessage(hr))); if (hr == E_INVALIDARG) qWarning("Invalid arguments. Some of the commands in the list is invalid in some way."); } @@ -1874,7 +1897,8 @@ void QSGD3D12EnginePrivate::finalizePipeline(const QSGD3D12PipelineState &pipeli HRESULT hr = device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&cachedPso->pso)); if (FAILED(hr)) { - qWarning("Failed to create graphics pipeline state"); + qWarning("Failed to create graphics pipeline state: %s", + qPrintable(comErrorMessage(hr))); return; } @@ -2179,7 +2203,7 @@ void QSGD3D12EnginePrivate::present() deviceManager()->deviceLossDetected(); return; } else if (FAILED(hr)) { - qWarning("Present failed: 0x%x", hr); + qWarning("Present failed: %s", qPrintable(comErrorMessage(hr))); return; } @@ -2433,7 +2457,7 @@ void QSGD3D12EnginePrivate::createTexture(uint id, const QSize &size, QImage::Fo HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture)); if (FAILED(hr)) { - qWarning("Failed to create texture resource: 0x%x", hr); + qWarning("Failed to create texture resource: %s", qPrintable(comErrorMessage(hr))); return; } @@ -2498,7 +2522,8 @@ void QSGD3D12EnginePrivate::queueTextureResize(uint id, const QSize &size) HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture)); if (FAILED(hr)) { - qWarning("Failed to create resized texture resource: 0x%x", hr); + qWarning("Failed to create resized texture resource: %s", + qPrintable(comErrorMessage(hr))); return; } @@ -2954,7 +2979,8 @@ void QSGD3D12EnginePrivate::createRenderTarget(uint id, const QSize &size, const HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&rt.colorResolve)); if (FAILED(hr)) { - qWarning("Failed to create resolve buffer: 0x%x", hr); + qWarning("Failed to create resolve buffer: %s", + qPrintable(comErrorMessage(hr))); return; } -- cgit v1.2.3 From e579076bb36e6594003b2ade7f3d062944ef6f47 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 16 Nov 2016 14:22:36 +0100 Subject: Get rid of most QT_NO_FOO usages Instead use QT_CONFIG(foo). This change actually detected a few mis-spelled macros and invalid usages. Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85 Reviewed-by: Simon Hausmann --- examples/qml/networkaccessmanagerfactory/main.cpp | 16 +-- examples/quick/quickwidgets/quickwidget/fbitem.cpp | 4 +- .../scenegraph/rendernode/customrenderitem.cpp | 2 +- .../quick/scenegraph/rendernode/openglrenderer.cpp | 4 +- .../quick/scenegraph/rendernode/openglrenderer.h | 4 +- src/imports/folderlistmodel/fileinfothread.cpp | 16 +-- src/imports/folderlistmodel/fileinfothread_p.h | 4 +- src/imports/folderlistmodel/plugin.cpp | 2 - src/imports/localstorage/plugin.cpp | 6 +- .../qmldbg_inspector/qquickwindowinspector.cpp | 2 +- src/qml/compiler/qqmlpropertyvalidator.cpp | 4 +- src/qml/compiler/qv4compileddata.cpp | 2 +- src/qml/debugger/qqmlmemoryprofiler.cpp | 4 +- src/qml/qml/qqmlapplicationengine.cpp | 6 +- src/qml/qml/qqmlapplicationengine_p.h | 2 +- src/qml/qml/qqmlerror.cpp | 2 +- src/qml/qml/qqmlglobal.cpp | 2 - src/qml/qml/qqmlglobal_p.h | 2 - src/qml/qml/qqmlimport.cpp | 14 +- src/qml/qml/qqmlmetatype.cpp | 2 +- src/qml/qml/qqmlobjectcreator.cpp | 4 +- src/qml/qml/qqmlstringconverters.cpp | 12 +- src/qml/qml/qqmlstringconverters_p.h | 2 +- src/qml/qml/qqmlxmlhttprequest.cpp | 10 +- src/qml/qml/qqmlxmlhttprequest_p.h | 4 +- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 10 +- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 4 +- src/qml/qml/v8/qv8engine.cpp | 4 +- src/qmltest/quicktest.cpp | 2 +- src/qmltest/quicktestevent.cpp | 4 +- src/qmltest/quicktestevent_p.h | 2 +- src/quick/accessible/qaccessiblequickitem.cpp | 4 +- src/quick/accessible/qaccessiblequickitem_p.h | 4 +- src/quick/accessible/qaccessiblequickview.cpp | 4 +- src/quick/accessible/qaccessiblequickview_p.h | 4 +- src/quick/accessible/qquickaccessiblefactory.cpp | 2 +- src/quick/accessible/qquickaccessiblefactory_p.h | 2 +- src/quick/designer/qquickdesignersupport.cpp | 2 +- src/quick/designer/qquickdesignerwindowmanager.cpp | 4 +- src/quick/designer/qquickdesignerwindowmanager_p.h | 4 +- src/quick/items/context2d/qquickcanvasitem.cpp | 2 +- src/quick/items/context2d/qquickcontext2d.cpp | 14 +- .../context2d/qquickcontext2dcommandbuffer.cpp | 2 +- .../items/context2d/qquickcontext2dtexture.cpp | 10 +- .../items/context2d/qquickcontext2dtexture_p.h | 8 +- src/quick/items/context2d/qquickcontext2dtile.cpp | 4 +- src/quick/items/context2d/qquickcontext2dtile_p.h | 4 +- src/quick/items/qquickaccessibleattached.cpp | 2 +- src/quick/items/qquickaccessibleattached_p.h | 4 +- src/quick/items/qquickdrag.cpp | 4 +- src/quick/items/qquickdrag_p.h | 4 +- src/quick/items/qquickdroparea.cpp | 4 +- src/quick/items/qquickdroparea_p.h | 4 +- src/quick/items/qquickflickable.cpp | 2 +- src/quick/items/qquickflickable_p.h | 2 +- src/quick/items/qquickgraphicsinfo.cpp | 2 +- src/quick/items/qquickitem.cpp | 68 ++++----- src/quick/items/qquickitem.h | 14 +- src/quick/items/qquickitem_p.h | 10 +- src/quick/items/qquickitemsmodule.cpp | 8 +- src/quick/items/qquickmousearea.cpp | 30 ++-- src/quick/items/qquickmousearea_p.h | 12 +- src/quick/items/qquickmousearea_p_p.h | 4 +- src/quick/items/qquickpainteditem.cpp | 2 +- src/quick/items/qquickpincharea.cpp | 4 +- src/quick/items/qquickrendercontrol.cpp | 8 +- src/quick/items/qquickshadereffect.cpp | 48 +++---- src/quick/items/qquickshadereffect_p.h | 2 +- src/quick/items/qquicktext.cpp | 6 +- src/quick/items/qquicktextcontrol.cpp | 89 ++++++------ src/quick/items/qquicktextcontrol_p.h | 6 +- src/quick/items/qquicktextcontrol_p_p.h | 8 +- src/quick/items/qquicktextdocument.cpp | 2 +- src/quick/items/qquicktextedit.cpp | 72 +++++----- src/quick/items/qquicktextedit_p.h | 6 +- src/quick/items/qquicktextedit_p_p.h | 6 +- src/quick/items/qquicktextinput.cpp | 152 ++++++++++----------- src/quick/items/qquicktextinput_p.h | 8 +- src/quick/items/qquicktextinput_p_p.h | 26 ++-- src/quick/items/qquicktextnode.cpp | 4 +- src/quick/items/qquicktextnodeengine.cpp | 6 +- src/quick/items/qquickwindow.cpp | 58 ++++---- src/quick/items/qquickwindow.h | 8 +- src/quick/items/qquickwindow_p.h | 12 +- src/quick/qtquick2.cpp | 2 +- src/quick/scenegraph/coreapi/qsggeometry.cpp | 4 +- src/quick/scenegraph/coreapi/qsgmaterial.cpp | 10 +- src/quick/scenegraph/coreapi/qsgmaterial.h | 12 +- src/quick/scenegraph/coreapi/qsgmaterialshader_p.h | 2 +- src/quick/scenegraph/coreapi/qsgrenderer.cpp | 12 +- src/quick/scenegraph/coreapi/qsgrenderer_p.h | 2 +- src/quick/scenegraph/qsgadaptationlayer.cpp | 2 +- src/quick/scenegraph/qsgcontextplugin.cpp | 12 +- src/quick/scenegraph/qsgrenderloop.cpp | 12 +- src/quick/scenegraph/util/qsgdistancefieldutil.cpp | 2 +- src/quick/scenegraph/util/qsgengine.cpp | 6 +- src/quick/scenegraph/util/qsgflatcolormaterial.cpp | 10 +- src/quick/scenegraph/util/qsgsimplematerial.h | 4 +- src/quick/scenegraph/util/qsgtexture.cpp | 18 +-- src/quick/scenegraph/util/qsgtexture_p.h | 2 +- src/quick/scenegraph/util/qsgtexturematerial.cpp | 18 +-- .../scenegraph/util/qsgvertexcolormaterial.cpp | 10 +- src/quick/util/qquickanimatorjob_p.h | 2 +- src/quick/util/qquickglobal.cpp | 2 +- src/quick/util/qquickutilmodule.cpp | 4 +- src/quick/util/qquickvalidator.cpp | 4 +- src/quick/util/qquickvalidator_p.h | 4 +- src/quickwidgets/qquickwidget.cpp | 42 +++--- src/quickwidgets/qquickwidget.h | 4 +- src/quickwidgets/qquickwidget_p.h | 4 +- .../tst_qqmlprofilerservice.cpp | 2 +- .../tst_qqmlapplicationengine.cpp | 6 +- .../auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp | 4 +- tests/auto/quick/examples/tst_examples.cpp | 2 +- tests/auto/quick/nokeywords/tst_nokeywords.cpp | 2 +- .../qquickborderimage/tst_qquickborderimage.cpp | 4 +- .../quick/qquickflickable/tst_qquickflickable.cpp | 2 +- .../qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp | 4 +- tests/auto/quick/qquickitem2/tst_qquickitem.cpp | 4 +- .../quick/qquickitemlayer/tst_qquickitemlayer.cpp | 6 +- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 6 +- .../qquickpainteditem/tst_qquickpainteditem.cpp | 4 +- .../qquickpixmapcache/tst_qquickpixmapcache.cpp | 10 +- .../quick/qquicktextedit/tst_qquicktextedit.cpp | 14 +- .../quick/qquicktextinput/tst_qquicktextinput.cpp | 14 +- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 22 +-- tests/auto/quick/scenegraph/tst_scenegraph.cpp | 14 +- tests/auto/quick/shared/viewtestutil.cpp | 2 +- tests/auto/shared/platformquirks.h | 2 +- .../benchmarks/qml/compilation/tst_compilation.cpp | 2 +- tools/qml/main.cpp | 10 +- tools/qmleasing/splineeditor.cpp | 4 +- tools/qmleasing/splineeditor.h | 4 +- tools/qmlscene/main.cpp | 16 +-- 134 files changed, 645 insertions(+), 660 deletions(-) diff --git a/examples/qml/networkaccessmanagerfactory/main.cpp b/examples/qml/networkaccessmanagerfactory/main.cpp index 55e00d6917..5b6b7681a9 100644 --- a/examples/qml/networkaccessmanagerfactory/main.cpp +++ b/examples/qml/networkaccessmanagerfactory/main.cpp @@ -56,10 +56,10 @@ networkaccessmanagerfactory [-host -port ] [file] */ -#ifndef QT_NO_NETWORKPROXY +#if QT_CONFIG(networkproxy) static QString proxyHost; static int proxyPort = 0; -#endif // !QT_NO_NETWORKPROXY +#endif // networkproxy class MyNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory { @@ -70,13 +70,13 @@ public: QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) { QNetworkAccessManager *nam = new QNetworkAccessManager(parent); -#ifndef QT_NO_NETWORKPROXY +#if QT_CONFIG(networkproxy) if (!proxyHost.isEmpty()) { qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); nam->setProxy(proxy); } -#endif // !QT_NO_NETWORKPROXY +#endif // networkproxy return nam; } @@ -88,12 +88,12 @@ int main(int argc, char ** argv) QGuiApplication app(argc, argv); QCommandLineParser parser; -#ifndef QT_NO_NETWORKPROXY +#if QT_CONFIG(networkproxy) QCommandLineOption proxyHostOption("host", "The proxy host to use.", "host"); parser.addOption(proxyHostOption); QCommandLineOption proxyPortOption("port", "The proxy port to use.", "port", "0"); parser.addOption(proxyPortOption); -#endif // !QT_NO_NETWORKPROXY +#endif // networkproxy parser.addPositionalArgument("file", "The file to use."); QCommandLineOption helpOption = parser.addHelpOption(); parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); @@ -106,7 +106,7 @@ int main(int argc, char ** argv) qWarning() << parser.helpText(); exit(0); } -#ifndef QT_NO_NETWORKPROXY +#if QT_CONFIG(networkproxy) if (parser.isSet(proxyHostOption)) proxyHost = parser.value(proxyHostOption); if (parser.isSet(proxyPortOption)) { @@ -118,7 +118,7 @@ int main(int argc, char ** argv) exit(1); } } -#endif // !QT_NO_NETWORKPROXY +#endif // networkproxy if (parser.positionalArguments().count() == 1) source = QUrl::fromLocalFile(parser.positionalArguments().first()); diff --git a/examples/quick/quickwidgets/quickwidget/fbitem.cpp b/examples/quick/quickwidgets/quickwidget/fbitem.cpp index fc2a4ea7ad..cb3cc976fb 100644 --- a/examples/quick/quickwidgets/quickwidget/fbitem.cpp +++ b/examples/quick/quickwidgets/quickwidget/fbitem.cpp @@ -44,7 +44,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class FbRenderer : public QQuickFramebufferObject::Renderer { public: @@ -82,7 +82,7 @@ private: QQuickFramebufferObject::Renderer *FbItem::createRenderer() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) return new FbRenderer; #else return nullptr; diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.cpp b/examples/quick/scenegraph/rendernode/customrenderitem.cpp index a92a400922..27c55bf86d 100644 --- a/examples/quick/scenegraph/rendernode/customrenderitem.cpp +++ b/examples/quick/scenegraph/rendernode/customrenderitem.cpp @@ -62,7 +62,7 @@ QSGNode *CustomRenderItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) return nullptr; switch (ri->graphicsApi()) { case QSGRendererInterface::OpenGL: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) n = new OpenGLRenderNode(this); break; #endif diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.cpp b/examples/quick/scenegraph/rendernode/openglrenderer.cpp index 3de864b7b9..65c2a210bc 100644 --- a/examples/quick/scenegraph/rendernode/openglrenderer.cpp +++ b/examples/quick/scenegraph/rendernode/openglrenderer.cpp @@ -41,7 +41,7 @@ #include "openglrenderer.h" #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include @@ -161,4 +161,4 @@ QRectF OpenGLRenderNode::rect() const return QRect(0, 0, m_item->width(), m_item->height()); } -#endif // QT_NO_OPENGL +#endif // opengl diff --git a/examples/quick/scenegraph/rendernode/openglrenderer.h b/examples/quick/scenegraph/rendernode/openglrenderer.h index 92cc2bc72b..ea2bbcbc38 100644 --- a/examples/quick/scenegraph/rendernode/openglrenderer.h +++ b/examples/quick/scenegraph/rendernode/openglrenderer.h @@ -43,7 +43,7 @@ #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QT_BEGIN_NAMESPACE @@ -75,6 +75,6 @@ private: QT_END_NAMESPACE -#endif // QT_NO_OPENGL +#endif // opengl #endif diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp index 0b62935f87..d3e256bb7e 100644 --- a/src/imports/folderlistmodel/fileinfothread.cpp +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -46,7 +46,7 @@ FileInfoThread::FileInfoThread(QObject *parent) : QThread(parent), abort(false), -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) watcher(0), #endif sortFlags(QDir::Name), @@ -61,11 +61,11 @@ FileInfoThread::FileInfoThread(QObject *parent) showOnlyReadable(false), caseSensitive(true) { -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString))); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); -#endif // !QT_NO_FILESYSTEMWATCHER +#endif // filesystemwatcher } FileInfoThread::~FileInfoThread() @@ -80,7 +80,7 @@ FileInfoThread::~FileInfoThread() void FileInfoThread::clear() { QMutexLocker locker(&mutex); -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) watcher->removePaths(watcher->files()); watcher->removePaths(watcher->directories()); #endif @@ -89,7 +89,7 @@ void FileInfoThread::clear() void FileInfoThread::removePath(const QString &path) { QMutexLocker locker(&mutex); -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) if (!path.startsWith(QLatin1Char(':'))) watcher->removePath(path); #else @@ -103,7 +103,7 @@ void FileInfoThread::setPath(const QString &path) Q_ASSERT(!path.isEmpty()); QMutexLocker locker(&mutex); -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) if (!path.startsWith(QLatin1Char(':'))) watcher->addPath(path); #endif @@ -120,7 +120,7 @@ void FileInfoThread::setRootPath(const QString &path) rootPath = path; } -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) void FileInfoThread::dirChanged(const QString &directoryPath) { Q_UNUSED(directoryPath); @@ -204,7 +204,7 @@ void FileInfoThread::setCaseSensitive(bool on) condition.wakeAll(); } -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) void FileInfoThread::updateFile(const QString &path) { Q_UNUSED(path); diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h index 8a154f264e..75da12a421 100644 --- a/src/imports/folderlistmodel/fileinfothread_p.h +++ b/src/imports/folderlistmodel/fileinfothread_p.h @@ -88,7 +88,7 @@ public: void setCaseSensitive(bool on); public Q_SLOTS: -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) void dirChanged(const QString &directoryPath); void updateFile(const QString &path); #endif @@ -103,7 +103,7 @@ private: QWaitCondition condition; volatile bool abort; -#ifndef QT_NO_FILESYSTEMWATCHER +#if QT_CONFIG(filesystemwatcher) QFileSystemWatcher *watcher; #endif QList currentFileList; diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index affde1c3aa..ef719109bd 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -62,12 +62,10 @@ public: void registerTypes(const char *uri) Q_DECL_OVERRIDE { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); -#ifndef QT_NO_DIRMODEL qmlRegisterType(uri,1,0,"FolderListModel"); qmlRegisterType(uri,2,0,"FolderListModel"); qmlRegisterType(uri,2,1,"FolderListModel"); qmlRegisterType(uri,2,2,"FolderListModel"); -#endif } }; //![class decl] diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index bf70fd1050..cd6d37ea5a 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -449,7 +449,7 @@ static ReturnedValue qmlsqldatabase_changeVersion(CallContext *ctx) if (ok) { *w->d()->version = to_version; -#ifndef QT_NO_SETTINGS +#if QT_CONFIG(settings) QSettings ini(qmlsqldatabase_databaseFile(db.connectionName(), scope.engine) + QLatin1String(".ini"), QSettings::IniFormat); ini.setValue(QLatin1String("Version"), to_version); #endif @@ -700,7 +700,7 @@ public: void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) { -#ifndef QT_NO_SETTINGS +#if QT_CONFIG(settings) QV4::Scope scope(args->v4engine()); if (scope.engine->qmlEngine()->offlineStoragePath().isEmpty()) V4THROW_SQL2(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled.")); @@ -770,7 +770,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) } args->setReturnValue(db.asReturnedValue()); -#endif // QT_NO_SETTINGS +#endif // settings } static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine) diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp index 2525500e65..7d260a4d2a 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.cpp @@ -153,7 +153,7 @@ bool QQuickWindowInspector::eventFilter(QObject *obj, QEvent *event) case QEvent::MouseButtonDblClick: m_tool->mouseDoubleClickEvent(static_cast(event)); return true; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) case QEvent::Wheel: return true; #endif diff --git a/src/qml/compiler/qqmlpropertyvalidator.cpp b/src/qml/compiler/qqmlpropertyvalidator.cpp index 45379d5155..383c20239f 100644 --- a/src/qml/compiler/qqmlpropertyvalidator.cpp +++ b/src/qml/compiler/qqmlpropertyvalidator.cpp @@ -412,7 +412,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache } } break; -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) case QVariant::Date: { bool ok = false; QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok); @@ -437,7 +437,7 @@ QQmlCompileError QQmlPropertyValidator::validateLiteralBinding(QQmlPropertyCache } } break; -#endif // QT_NO_DATESTRING +#endif // datestring case QVariant::Point: { bool ok = false; QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok); diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index f8668b48e4..8586c84c3d 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -471,7 +471,7 @@ QString Binding::valueAsString(const Unit *unit) const return QString::number(valueAsNumber()); case Type_Invalid: return QString(); -#ifdef QT_NO_TRANSLATION +#if !QT_CONFIG(translation) case Type_TranslationById: case Type_Translation: return unit->stringAt(stringIndex); diff --git a/src/qml/debugger/qqmlmemoryprofiler.cpp b/src/qml/debugger/qqmlmemoryprofiler.cpp index 53d4e7ab21..b89dbfd02d 100644 --- a/src/qml/debugger/qqmlmemoryprofiler.cpp +++ b/src/qml/debugger/qqmlmemoryprofiler.cpp @@ -62,13 +62,13 @@ static qmlmemprofile_pop_location *memprofile_pop_location; static qmlmemprofile_save *memprofile_save; static qmlmemprofile_is_enabled *memprofile_is_enabled; -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) extern QFunctionPointer qt_linux_find_symbol_sys(const char *symbol); #endif bool QQmlMemoryScope::doOpenLibrary() { -#if defined(Q_OS_LINUX) && !defined(QT_NO_LIBRARY) +#if defined(Q_OS_LINUX) && QT_CONFIG(library) if (state == Unloaded) { memprofile_stats = (qmlmemprofile_stats *) qt_linux_find_symbol_sys("qmlmemprofile_stats"); memprofile_clear = (qmlmemprofile_clear *) qt_linux_find_symbol_sys("qmlmemprofile_clear"); diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index fef2da753b..21a1a13687 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -58,7 +58,7 @@ QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate() void QQmlApplicationEnginePrivate::cleanUp() { qDeleteAll(objects); -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) qDeleteAll(translators); #endif } @@ -70,7 +70,7 @@ void QQmlApplicationEnginePrivate::init() q, SLOT(_q_finishLoad(QObject*))); q->connect(q, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) QTranslator* qtTranslator = new QTranslator; if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) QCoreApplication::installTranslator(qtTranslator); @@ -82,7 +82,7 @@ void QQmlApplicationEnginePrivate::init() void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile) { -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) if (rootFile.scheme() != QLatin1String("file") && rootFile.scheme() != QLatin1String("qrc")) return; diff --git a/src/qml/qml/qqmlapplicationengine_p.h b/src/qml/qml/qqmlapplicationengine_p.h index e1d1b4a7bb..8c342a43a9 100644 --- a/src/qml/qml/qqmlapplicationengine_p.h +++ b/src/qml/qml/qqmlapplicationengine_p.h @@ -78,7 +78,7 @@ public: QSignalMapper statusMapper; QObject *appObj; -#ifndef QT_NO_TRANSLATIONS +#if QT_CONFIG(translation) QList translators; #endif }; diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index b309550ca8..0a6c7b4960 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -285,7 +285,7 @@ QDebug operator<<(QDebug debug, const QQmlError &error) if (f.open(QIODevice::ReadOnly)) { QByteArray data = f.readAll(); QTextStream stream(data, QIODevice::ReadOnly); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) stream.setCodec("UTF-8"); #endif const QString code = stream.readAll(); diff --git a/src/qml/qml/qqmlglobal.cpp b/src/qml/qml/qqmlglobal.cpp index 722527a546..f967dacd34 100644 --- a/src/qml/qml/qqmlglobal.cpp +++ b/src/qml/qml/qqmlglobal.cpp @@ -326,7 +326,6 @@ QObject *QQmlGuiProvider::application(QObject *) { return new QQmlApplication(); QStringList QQmlGuiProvider::fontFamilies() { return QStringList(); } bool QQmlGuiProvider::openUrlExternally(QUrl &) { return false; } -#ifndef QT_NO_IM QObject *QQmlGuiProvider::inputMethod() { // We don't have any input method code by default @@ -335,7 +334,6 @@ QObject *QQmlGuiProvider::inputMethod() QQmlEngine::setObjectOwnership(o, QQmlEngine::JavaScriptOwnership); return o; } -#endif QObject *QQmlGuiProvider::styleHints() { diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 0f5cf3a392..707814e781 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -307,9 +307,7 @@ class Q_QML_PRIVATE_EXPORT QQmlGuiProvider public: virtual ~QQmlGuiProvider(); virtual QObject *application(QObject *parent); -#ifndef QT_NO_IM virtual QObject *inputMethod(); -#endif virtual QObject *styleHints(); virtual QStringList fontFamilies(); virtual bool openUrlExternally(QUrl &); diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 98e2f9eefd..f2cbf5a94f 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -176,7 +176,7 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa } // namespace -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) struct RegisteredPlugin { QString uri; QPluginLoader* loader; @@ -301,7 +301,7 @@ public: const QString &uri, const QString &url, int vmaj, int vmin, QV4::CompiledData::Import::ImportType type, QList *errors, bool lowPrecedence = false); -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) bool populatePluginPairVector(QVector &result, const QString &uri, const QStringList &versionUris, const QString &qmldirPath, QList *errors); #endif @@ -897,7 +897,7 @@ static QStringList versionUriList(const QString &uri, int vmaj, int vmin) return result; } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) /*! Get all static plugins that are QML plugins and has a meta data URI that matches with one of \a versionUris, which is a list of all possible versioned URI combinations - see versionUriList() @@ -960,7 +960,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath, const QQmlTypeLoader::QmldirContent *qmldir, QList *errors) { -#if !defined(QT_NO_LIBRARY) +#if QT_CONFIG(library) Q_ASSERT(qmldir); if (qmlImportTrace()) @@ -1087,7 +1087,7 @@ bool QQmlImportsPrivate::importExtension(const QString &qmldirFilePath, } return false; -#endif // QT_NO_LIBRARY +#endif // library return true; } @@ -1948,7 +1948,7 @@ bool QQmlImportDatabase::registerPluginTypes(QObject *instance, const QString &b bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &basePath, const QString &uri, const QString &typeNamespace, int vmaj, QList *errors) { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Dynamic plugins are differentiated by their filepath. For static plugins we // don't have that information so we use their address as key instead. const QString uniquePluginID = QString::asprintf("%p", instance); @@ -2001,7 +2001,7 @@ bool QQmlImportDatabase::importStaticPlugin(QObject *instance, const QString &ba bool QQmlImportDatabase::importDynamicPlugin(const QString &filePath, const QString &uri, const QString &typeNamespace, int vmaj, QList *errors) { -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) QFileInfo fileInfo(filePath); const QString absoluteFilePath = fileInfo.absoluteFilePath(); diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index ce0f4b798a..51964a7d11 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1158,7 +1158,7 @@ void qmlClearTypeRegistrations() // Declared in qqml.h data->uriToModule.clear(); QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) qmlClearEnginePlugins(); #endif } diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 2218f277d6..115925e34a 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -402,7 +402,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const } } break; -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) case QVariant::Date: { bool ok = false; QDate value = QQmlStringConverters::dateFromString(binding->valueAsString(qmlUnit), &ok); @@ -430,7 +430,7 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const property->writeProperty(_qobject, &value, propertyWriteFlags); } break; -#endif // QT_NO_DATESTRING +#endif // datestring case QVariant::Point: { bool ok = false; QPoint value = QQmlStringConverters::pointFFromString(binding->valueAsString(qmlUnit), &ok).toPoint(); diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp index d2b3577a1f..e53f90b45b 100644 --- a/src/qml/qml/qqmlstringconverters.cpp +++ b/src/qml/qml/qqmlstringconverters.cpp @@ -71,14 +71,14 @@ QVariant QQmlStringConverters::variantFromString(const QString &s, int preferred return QVariant(int(qRound(s.toDouble(ok)))); case QMetaType::UInt: return QVariant(uint(qRound(s.toDouble(ok)))); -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) case QMetaType::QDate: return QVariant::fromValue(dateFromString(s, ok)); case QMetaType::QTime: return QVariant::fromValue(timeFromString(s, ok)); case QMetaType::QDateTime: return QVariant::fromValue(dateTimeFromString(s, ok)); -#endif // QT_NO_DATESTRING +#endif // datestring case QMetaType::QPointF: return QVariant::fromValue(pointFFromString(s, ok)); case QMetaType::QPoint: @@ -106,7 +106,7 @@ unsigned QQmlStringConverters::rgbaFromString(const QString &s, bool *ok) return QQml_colorProvider()->rgbaFromString(s, ok); } -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok) { QDate d = QDate::fromString(s, Qt::ISODate); @@ -130,7 +130,7 @@ QDateTime QQmlStringConverters::dateTimeFromString(const QString &s, bool *ok) d.setTimeSpec(Qt::UTC); return d; } -#endif // QT_NO_DATESTRING +#endif // datestring //expects input of "x,y" QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok) @@ -229,7 +229,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da *p = uint(qRound(s.toDouble(&ok))); return ok; } -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) case QMetaType::QDate: { Q_ASSERT(n >= sizeof(QDate)); @@ -251,7 +251,7 @@ bool QQmlStringConverters::createFromString(int type, const QString &s, void *da *p = dateTimeFromString(s, &ok); return ok; } -#endif // QT_NO_DATESTRING +#endif // datestring case QMetaType::QPointF: { Q_ASSERT(n >= sizeof(QPointF)); diff --git a/src/qml/qml/qqmlstringconverters_p.h b/src/qml/qml/qqmlstringconverters_p.h index b67cefaf35..af344e3344 100644 --- a/src/qml/qml/qqmlstringconverters_p.h +++ b/src/qml/qml/qqmlstringconverters_p.h @@ -72,7 +72,7 @@ namespace QQmlStringConverters Q_QML_PRIVATE_EXPORT QVariant colorFromString(const QString &, bool *ok = 0); Q_QML_PRIVATE_EXPORT unsigned rgbaFromString(const QString &, bool *ok = 0); -#ifndef QT_NO_DATESTRING +#if QT_CONFIG(datestring) Q_QML_PRIVATE_EXPORT QDate dateFromString(const QString &, bool *ok = 0); Q_QML_PRIVATE_EXPORT QTime timeFromString(const QString &, bool *ok = 0); Q_QML_PRIVATE_EXPORT QDateTime dateTimeFromString(const QString &, bool *ok = 0); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 10b1cbcfd4..6b86e38f19 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -70,7 +70,7 @@ using namespace QV4; -#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network) +#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network) #define V4THROW_REFERENCE(string) { \ ScopedObject error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \ @@ -1068,7 +1068,7 @@ private: QByteArray m_mime; QByteArray m_charset; QTextCodec *m_textCodec; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec* findTextCodec() const; #endif void readEncoding(); @@ -1510,7 +1510,7 @@ QV4::ReturnedValue QQmlXMLHttpRequest::xmlResponseBody(QV4::ExecutionEngine* eng return m_parsedDocument.value(); } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec* QQmlXMLHttpRequest::findTextCodec() const { QTextCodec *codec = 0; @@ -1539,7 +1539,7 @@ QTextCodec* QQmlXMLHttpRequest::findTextCodec() const QString QQmlXMLHttpRequest::responseBody() { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (!m_textCodec) m_textCodec = findTextCodec(); if (m_textCodec) @@ -2056,6 +2056,6 @@ void *qt_add_qmlxmlhttprequest(ExecutionEngine *v4) QT_END_NAMESPACE -#endif // QT_NO_XMLSTREAMREADER && qml_network +#endif // xmlstreamreader && qml_network #include diff --git a/src/qml/qml/qqmlxmlhttprequest_p.h b/src/qml/qml/qqmlxmlhttprequest_p.h index fdb6194537..f2836d8301 100644 --- a/src/qml/qml/qqmlxmlhttprequest_p.h +++ b/src/qml/qml/qqmlxmlhttprequest_p.h @@ -55,7 +55,7 @@ #include #include -#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network) +#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network) QT_BEGIN_NAMESPACE @@ -64,7 +64,7 @@ void qt_rem_qmlxmlhttprequest(QV4::ExecutionEngine *engine, void *); QT_END_NAMESPACE -#endif // QT_NO_XMLSTREAMREADER && qml_network +#endif // xmlstreamreader && qml_network #endif // QQMLXMLHTTPREQUEST_P_H diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index c8a0463a2d..7bab2415c5 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -148,9 +148,7 @@ void Heap::QtObject::init(QQmlEngine *qmlEngine) o->defineAccessorProperty(QStringLiteral("platform"), QV4::QtObject::method_get_platform, 0); o->defineAccessorProperty(QStringLiteral("application"), QV4::QtObject::method_get_application, 0); -#ifndef QT_NO_IM o->defineAccessorProperty(QStringLiteral("inputMethod"), QV4::QtObject::method_get_inputMethod, 0); -#endif o->defineAccessorProperty(QStringLiteral("styleHints"), QV4::QtObject::method_get_styleHints, 0); o->defineDefaultProperty(QStringLiteral("callLater"), QV4::QtObject::method_callLater); @@ -1423,13 +1421,11 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx) return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->application); } -#ifndef QT_NO_IM ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx) { QObject *o = QQml_guiProvider()->inputMethod(); return QV4::QObjectWrapper::wrap(ctx->d()->engine, o); } -#endif ReturnedValue QtObject::method_get_styleHints(CallContext *ctx) { @@ -1740,7 +1736,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext Scope scope(v4); if (extensions.testFlag(QJSEngine::TranslationExtension)) { - #ifndef QT_NO_TRANSLATION + #if QT_CONFIG(translation) globalObject->defineDefaultProperty(QStringLiteral("qsTranslate"), QV4::GlobalExtensions::method_qsTranslate); globalObject->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), QV4::GlobalExtensions::method_qsTranslateNoOp); globalObject->defineDefaultProperty(QStringLiteral("qsTr"), QV4::GlobalExtensions::method_qsTr); @@ -1767,7 +1763,7 @@ void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions ext } -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) /*! \qmlmethod string Qt::qsTranslate(string context, string sourceText, string disambiguation, int n) @@ -2015,7 +2011,7 @@ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx) return QV4::Encode::undefined(); return ctx->args()[0].asReturnedValue(); } -#endif // QT_NO_TRANSLATION +#endif // translation QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index f428e377d7..f84c819e6a 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -135,9 +135,7 @@ struct QtObject : Object static ReturnedValue method_get_platform(CallContext *ctx); static ReturnedValue method_get_application(CallContext *ctx); -#ifndef QT_NO_IM static ReturnedValue method_get_inputMethod(CallContext *ctx); -#endif static ReturnedValue method_get_styleHints(CallContext *ctx); static ReturnedValue method_callLater(CallContext *ctx); @@ -169,7 +167,7 @@ struct ConsoleObject : Object struct Q_QML_PRIVATE_EXPORT GlobalExtensions { static void init(Object *globalObject, QJSEngine::Extensions extensions); -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) static ReturnedValue method_qsTranslate(CallContext *ctx); static ReturnedValue method_qsTranslateNoOp(CallContext *ctx); static ReturnedValue method_qsTr(CallContext *ctx); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index b0599dd0a2..1df468dd49 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -160,7 +160,7 @@ QV8Engine::~QV8Engine() qDeleteAll(m_extensionData); m_extensionData.clear(); -#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network) +#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network) qt_rem_qmlxmlhttprequest(m_v4Engine, m_xmlHttpRequestData); m_xmlHttpRequestData = 0; #endif @@ -195,7 +195,7 @@ void QV8Engine::initializeGlobal() QQmlDateExtension::registerExtension(m_v4Engine); QQmlNumberExtension::registerExtension(m_v4Engine); -#if !defined(QT_NO_XMLSTREAMREADER) && QT_CONFIG(qml_network) +#if QT_CONFIG(xmlstreamreader) && QT_CONFIG(qml_network) qt_add_domexceptions(m_v4Engine); m_xmlHttpRequestData = qt_add_qmlxmlhttprequest(m_v4Engine); #endif diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 0e348eee11..70733da121 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -266,7 +266,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD QuickTestResult::parseArgs(testArgC, testArgV.data()); -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) QTranslator translator; if (!translationFile.isEmpty()) { if (translator.load(translationFile)) { diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 32cc5eefd7..3d6365503d 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -197,7 +197,7 @@ namespace QtQuickTest } } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) static void mouseWheel(QWindow* window, QObject* item, Qt::MouseButtons buttons, Qt::KeyboardModifiers stateKey, QPointF _pos, int xDelta, int yDelta, int delay = -1) @@ -241,7 +241,7 @@ bool QuickTestEvent::mousePress return true; } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) bool QuickTestEvent::mouseWheel( QObject *item, qreal x, qreal y, int buttons, int modifiers, int xDelta, int yDelta, int delay) diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h index 1adf8f3317..1f6de7ed28 100644 --- a/src/qmltest/quicktestevent_p.h +++ b/src/qmltest/quicktestevent_p.h @@ -86,7 +86,7 @@ public Q_SLOTS: int modifiers, int delay); bool mouseMove(QObject *item, qreal x, qreal y, int delay, int buttons); -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) bool mouseWheel(QObject *item, qreal x, qreal y, int buttons, int modifiers, int xDelta, int yDelta, int delay); #endif diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp index 1626aaac2d..897e1143d5 100644 --- a/src/quick/accessible/qaccessiblequickitem.cpp +++ b/src/quick/accessible/qaccessiblequickitem.cpp @@ -47,7 +47,7 @@ #include "QtQuick/qquicktextdocument.h" QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item) : QAccessibleObject(item), m_doc(textDocument()) @@ -591,6 +591,6 @@ void QAccessibleQuickItem::setSelection(int /* selectionIndex */, int /* startOf } -#endif // QT_NO_ACCESSIBILITY +#endif // accessibility QT_END_NAMESPACE diff --git a/src/quick/accessible/qaccessiblequickitem_p.h b/src/quick/accessible/qaccessiblequickitem_p.h index 7445fd1400..577a105627 100644 --- a/src/quick/accessible/qaccessiblequickitem_p.h +++ b/src/quick/accessible/qaccessiblequickitem_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QTextDocument; @@ -141,7 +141,7 @@ private: QRect itemScreenRect(QQuickItem *item); QList accessibleUnignoredChildren(QQuickItem *item, bool paintOrder = false); -#endif // QT_NO_ACCESSIBILITY +#endif // accessibility QT_END_NAMESPACE diff --git a/src/quick/accessible/qaccessiblequickview.cpp b/src/quick/accessible/qaccessiblequickview.cpp index edd39ed9db..222690e4f2 100644 --- a/src/quick/accessible/qaccessiblequickview.cpp +++ b/src/quick/accessible/qaccessiblequickview.cpp @@ -46,7 +46,7 @@ #include "qaccessiblequickitem_p.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QT_BEGIN_NAMESPACE @@ -145,4 +145,4 @@ int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) cons QT_END_NAMESPACE -#endif // QT_NO_ACCESSIBILITY +#endif // accessibility diff --git a/src/quick/accessible/qaccessiblequickview_p.h b/src/quick/accessible/qaccessiblequickview_p.h index 457e8b456b..007a6fd990 100644 --- a/src/quick/accessible/qaccessiblequickview_p.h +++ b/src/quick/accessible/qaccessiblequickview_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) class QAccessibleQuickWindow : public QAccessibleObject { @@ -80,7 +80,7 @@ private: QList rootItems() const; }; -#endif // QT_NO_ACCESSIBILITY +#endif // accessibility QT_END_NAMESPACE diff --git a/src/quick/accessible/qquickaccessiblefactory.cpp b/src/quick/accessible/qquickaccessiblefactory.cpp index 69a74f2b3d..a1fa695e5a 100644 --- a/src/quick/accessible/qquickaccessiblefactory.cpp +++ b/src/quick/accessible/qquickaccessiblefactory.cpp @@ -44,7 +44,7 @@ #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object) { diff --git a/src/quick/accessible/qquickaccessiblefactory_p.h b/src/quick/accessible/qquickaccessiblefactory_p.h index 6407b70223..ab8eb12ca4 100644 --- a/src/quick/accessible/qquickaccessiblefactory_p.h +++ b/src/quick/accessible/qquickaccessiblefactory_p.h @@ -54,7 +54,7 @@ #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleInterface *qQuickAccessibleFactory(const QString &classname, QObject *object); diff --git a/src/quick/designer/qquickdesignersupport.cpp b/src/quick/designer/qquickdesignersupport.cpp index 3ff5a3ce96..749ece8221 100644 --- a/src/quick/designer/qquickdesignersupport.cpp +++ b/src/quick/designer/qquickdesignersupport.cpp @@ -95,7 +95,7 @@ void QQuickDesignerSupport::refFromEffectItem(QQuickItem *referencedItem, bool h texture->setRect(referencedItem->boundingRect()); texture->setSize(referencedItem->boundingRect().size().toSize()); texture->setRecursive(true); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #ifndef QT_OPENGL_ES if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) texture->setFormat(GL_RGBA8); diff --git a/src/quick/designer/qquickdesignerwindowmanager.cpp b/src/quick/designer/qquickdesignerwindowmanager.cpp index 2d37db08e7..e2d7b98c33 100644 --- a/src/quick/designer/qquickdesignerwindowmanager.cpp +++ b/src/quick/designer/qquickdesignerwindowmanager.cpp @@ -39,7 +39,7 @@ #include "qquickdesignerwindowmanager_p.h" #include "private/qquickwindow_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif #include @@ -67,7 +67,7 @@ void QQuickDesignerWindowManager::windowDestroyed(QQuickWindow *) void QQuickDesignerWindowManager::makeOpenGLContext(QQuickWindow *window) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!m_openGlContext) { m_openGlContext.reset(new QOpenGLContext()); m_openGlContext->setFormat(window->requestedFormat()); diff --git a/src/quick/designer/qquickdesignerwindowmanager_p.h b/src/quick/designer/qquickdesignerwindowmanager_p.h index a50f8aa49f..09e15dad73 100644 --- a/src/quick/designer/qquickdesignerwindowmanager_p.h +++ b/src/quick/designer/qquickdesignerwindowmanager_p.h @@ -57,7 +57,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif @@ -97,7 +97,7 @@ public: static void createOpenGLContext(QQuickWindow *window); private: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QScopedPointer m_openGlContext; #endif QScopedPointer m_sgContext; diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 3b2b125c63..212148b754 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -802,7 +802,7 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const return QQuickItem::textureProvider(); Q_D(const QQuickCanvasItem); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickWindow *w = window(); if (!w || !w->isSceneGraphInitialized() || QThread::currentThread() != QQuickWindowPrivate::get(w)->context->thread()) { diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 2483a8eadb..bcaedd67b4 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -75,7 +75,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif @@ -3997,7 +3997,7 @@ public: ~QQuickContext2DThreadCleanup() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) context->makeCurrent(surface); delete texture; context->doneCurrent(); @@ -4038,7 +4038,7 @@ QQuickContext2D::~QQuickContext2D() delete m_buffer; if (m_renderTarget == QQuickCanvasItem::FramebufferObject) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_renderStrategy == QQuickCanvasItem::Immediate && m_glContext) { Q_ASSERT(QThread::currentThread() == m_glContext->thread()); m_glContext->makeCurrent(m_surface.data()); @@ -4115,7 +4115,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args m_texture = new QQuickContext2DImageTexture; break; case QQuickCanvasItem::FramebufferObject: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_texture = new QQuickContext2DFBOTexture; #else // It shouldn't be possible to use a FramebufferObject without OpenGL @@ -4134,7 +4134,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args m_thread = QThread::currentThread(); QThread *renderThread = m_thread; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickWindow *window = canvasItem->window(); QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); QThread *sceneGraphThread = wd->context->thread(); @@ -4151,7 +4151,7 @@ void QQuickContext2D::init(QQuickCanvasItem *canvasItem, const QVariantMap &args if (renderThread && renderThread != QThread::currentThread()) m_texture->moveToThread(renderThread); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_renderTarget == QQuickCanvasItem::FramebufferObject && renderThread != sceneGraphThread) { auto openglRenderContext = static_cast(QQuickWindowPrivate::get(window)->context); QOpenGLContext *cc = openglRenderContext->openglContext(); @@ -4212,7 +4212,7 @@ QImage QQuickContext2D::toImage(const QRectF& bounds) flush(); m_texture->grabImage(bounds); } else { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickWindow *window = m_canvas->window(); QOpenGLContext *ctx = window ? window->openglContext() : 0; if (ctx && ctx->isValid()) { diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp index 8d659040b3..b985cb0ccc 100644 --- a/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp +++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer.cpp @@ -43,7 +43,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #endif diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index 4435c0c37b..38b5f054bf 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -44,7 +44,7 @@ #include #include "qquickcontext2dcommandbuffer_p.h" #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include @@ -53,7 +53,7 @@ #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #define QT_MINIMUM_FBO_SIZE 64 static inline int qt_next_power_of_two(int v) @@ -90,7 +90,7 @@ struct GLAcquireContext { #endif QQuickContext2DTexture::QQuickContext2DTexture() : m_context(0) -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) , m_gl(0) #endif , m_surface(0) @@ -254,7 +254,7 @@ void QQuickContext2DTexture::paint(QQuickContext2DCommandBuffer *ccb) return; } QQuickContext2D::mutex.unlock(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) GLAcquireContext currentContext(m_gl, m_surface); #endif if (!m_tiledCanvas) { @@ -383,7 +383,7 @@ bool QQuickContext2DTexture::event(QEvent *e) } return QObject::event(e); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) static inline QSize npotAdjustedSize(const QSize &size) { static bool checked = false; diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h index 6a5d4e8b09..04d7b40ab7 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture_p.h +++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h @@ -58,7 +58,7 @@ QT_REQUIRE_CONFIG(quick_canvas); #include #include "qquickcanvasitem_p.h" #include "qquickcontext2d_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #endif @@ -125,7 +125,7 @@ public: // Called during sync() on the scene graph thread while GUI is blocked. virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) = 0; bool event(QEvent *e); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) { m_gl = gl; m_surface = s; @@ -157,7 +157,7 @@ protected: QList m_tiles; QQuickContext2D *m_context; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext *m_gl; #endif QSurface *m_surface; @@ -180,7 +180,7 @@ protected: uint m_painting : 1; uint m_onCustomThread : 1; // Not GUI and not SGRender }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class QQuickContext2DFBOTexture : public QQuickContext2DTexture { Q_OBJECT diff --git a/src/quick/items/context2d/qquickcontext2dtile.cpp b/src/quick/items/context2d/qquickcontext2dtile.cpp index 95b6c9d961..d31fee7f91 100644 --- a/src/quick/items/context2d/qquickcontext2dtile.cpp +++ b/src/quick/items/context2d/qquickcontext2dtile.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qquickcontext2dtile_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include # include @@ -97,7 +97,7 @@ QPainter* QQuickContext2DTile::createPainter(bool smooth, bool antialiasing) return 0; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickContext2DFBOTile::QQuickContext2DFBOTile() : QQuickContext2DTile() , m_fbo(0) diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h index 2f3fdeb54f..e7eed7b086 100644 --- a/src/quick/items/context2d/qquickcontext2dtile_p.h +++ b/src/quick/items/context2d/qquickcontext2dtile_p.h @@ -56,7 +56,7 @@ QT_REQUIRE_CONFIG(quick_canvas); #include "qquickcontext2d_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif QT_BEGIN_NAMESPACE @@ -87,7 +87,7 @@ protected: QPainter m_painter; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class QQuickContext2DFBOTile : public QQuickContext2DTile { public: diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp index 41c036c7a8..4e918802d1 100644 --- a/src/quick/items/qquickaccessibleattached.cpp +++ b/src/quick/items/qquickaccessibleattached.cpp @@ -39,7 +39,7 @@ #include "qquickaccessibleattached_p.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "private/qquickitem_p.h" diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h index 2c209ae664..c8538745cc 100644 --- a/src/quick/items/qquickaccessibleattached_p.h +++ b/src/quick/items/qquickaccessibleattached_p.h @@ -56,7 +56,7 @@ #include #include -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include #include @@ -265,6 +265,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickAccessibleAttached) QML_DECLARE_TYPEINFO(QQuickAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES) -#endif // QT_NO_ACCESSIBILITY +#endif // accessibility #endif diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index cbb052856e..7a112e840a 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -55,7 +55,7 @@ #include #include -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QT_BEGIN_NAMESPACE @@ -995,4 +995,4 @@ QQuickDragAttached *QQuickDrag::qmlAttachedProperties(QObject *obj) QT_END_NAMESPACE -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h index 17721251d9..cc6318a4a3 100644 --- a/src/quick/items/qquickdrag_p.h +++ b/src/quick/items/qquickdrag_p.h @@ -60,7 +60,7 @@ #include #include -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QT_BEGIN_NAMESPACE @@ -318,6 +318,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickDrag) QML_DECLARE_TYPEINFO(QQuickDrag, QML_HAS_ATTACHED_PROPERTIES) -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop #endif diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index 8dcc13971e..84c44c6541 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -43,7 +43,7 @@ #include -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QT_BEGIN_NAMESPACE @@ -618,4 +618,4 @@ void QQuickDropEvent::accept(QQmlV4Function *args) QT_END_NAMESPACE -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h index d3b37979da..ccde2bcd19 100644 --- a/src/quick/items/qquickdroparea_p.h +++ b/src/quick/items/qquickdroparea_p.h @@ -55,7 +55,7 @@ #include -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QT_BEGIN_NAMESPACE @@ -190,6 +190,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickDropEvent) QML_DECLARE_TYPE(QQuickDropArea) -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop #endif // QQUICKDROPAREA_P_H diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 12b01b8aaf..1e778306e0 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1404,7 +1404,7 @@ void QQuickFlickable::mouseReleaseEvent(QMouseEvent *event) } } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void QQuickFlickable::wheelEvent(QWheelEvent *event) { Q_D(QQuickFlickable); diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h index 610bfd1427..62733bda1c 100644 --- a/src/quick/items/qquickflickable_p.h +++ b/src/quick/items/qquickflickable_p.h @@ -249,7 +249,7 @@ protected: void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickgraphicsinfo.cpp b/src/quick/items/qquickgraphicsinfo.cpp index 761d0c3cad..f735f17a4d 100644 --- a/src/quick/items/qquickgraphicsinfo.cpp +++ b/src/quick/items/qquickgraphicsinfo.cpp @@ -257,7 +257,7 @@ void QQuickGraphicsInfo::updateInfo() } QSurfaceFormat format = QSurfaceFormat::defaultFormat(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_window && m_window->isSceneGraphInitialized()) { QOpenGLContext *context = m_window->openglContext(); if (context) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 13b75c0482..cbfd776941 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -73,7 +73,7 @@ #include #include -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) # include #endif @@ -317,7 +317,7 @@ void QQuickItemKeyFilter::keyReleased(QKeyEvent *event, bool post) if (m_next) m_next->keyReleased(event, post); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void QQuickItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post) { if (m_next) @@ -331,7 +331,7 @@ QVariant QQuickItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const if (m_next) return m_next->inputMethodQuery(query); return QVariant(); } -#endif // QT_NO_IM +#endif // im void QQuickItemKeyFilter::componentComplete() { @@ -1298,7 +1298,7 @@ void QQuickKeysAttached::setPriority(Priority order) void QQuickKeysAttached::componentComplete() { -#ifndef QT_NO_IM +#if QT_CONFIG(im) Q_D(QQuickKeysAttached); if (d->item) { for (QQuickItem *targetItem : qAsConst(d->targets)) { @@ -1387,7 +1387,7 @@ void QQuickKeysAttached::keyReleased(QKeyEvent *event, bool post) if (!event->isAccepted()) QQuickItemKeyFilter::keyReleased(event, post); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void QQuickKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) { Q_D(QQuickKeysAttached); @@ -1424,7 +1424,7 @@ QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const } return QQuickItemKeyFilter::inputMethodQuery(query); } -#endif // QT_NO_IM +#endif // im QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj) { @@ -1675,7 +1675,7 @@ void QQuickEnterKeyAttached::setType(Qt::EnterKeyType type) { if (keyType != type) { keyType = type; -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (itemPrivate && itemPrivate->activeFocus) QGuiApplication::inputMethod()->update(Qt::ImEnterKeyType); #endif @@ -2366,7 +2366,7 @@ bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item) if (item == item->window()->contentItem()) return true; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (QObject *acc = qmlAttachedPropertiesObject(item, false)) { int role = acc->property("role").toInt(); if (role == QAccessible::EditableText @@ -2855,7 +2855,7 @@ void QQuickItemPrivate::addChild(QQuickItem *child) childItems.append(child); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); // if the added child has a cursor and we do not currently have any children @@ -2883,7 +2883,7 @@ void QQuickItemPrivate::removeChild(QQuickItem *child) childItems.removeOne(child); Q_ASSERT(!childItems.contains(child)); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); // turn it off, if nothing else is using it @@ -2958,7 +2958,7 @@ void QQuickItemPrivate::derefWindow() if (polishScheduled) c->itemsToPolish.removeOne(q); c->removeGrabber(q); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) if (c->cursorItem == q) { c->cursorItem = 0; window->unsetCursor(); @@ -3842,7 +3842,7 @@ void QQuickItem::keyReleaseEvent(QKeyEvent *event) event->ignore(); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! This event handler can be reimplemented in a subclass to receive input method events for an item. The event information is provided by the @@ -3852,7 +3852,7 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event) { event->ignore(); } -#endif // QT_NO_IM +#endif // im /*! This event handler can be reimplemented in a subclass to receive focus-in @@ -3861,7 +3861,7 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event) */ void QQuickItem::focusInEvent(QFocusEvent * /*event*/) { -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (QAccessible::isActive()) { if (QObject *acc = QQuickAccessibleAttached::findAccessible(this)) { QAccessibleEvent ev(acc, QAccessible::Focus); @@ -3939,7 +3939,7 @@ void QQuickItem::touchUngrabEvent() // XXX todo } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) /*! This event handler can be reimplemented in a subclass to receive wheel events for an item. The event information is provided by the @@ -3997,7 +3997,7 @@ void QQuickItem::hoverLeaveEvent(QHoverEvent *event) Q_UNUSED(event); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! This event handler can be reimplemented in a subclass to receive drag-enter events for an item. The event information is provided by the @@ -4057,7 +4057,7 @@ void QQuickItem::dropEvent(QDropEvent *event) { Q_UNUSED(event); } -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop /*! Reimplement this method to filter the mouse events that are received by @@ -4088,7 +4088,7 @@ void QQuickItem::windowDeactivateEvent() } } -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! This method is only relevant for input items. @@ -4146,7 +4146,7 @@ QVariant QQuickItem::inputMethodQuery(Qt::InputMethodQuery query) const return v; } -#endif // QT_NO_IM +#endif // im QQuickAnchorLine QQuickItemPrivate::left() const { @@ -4991,7 +4991,7 @@ void QQuickItemPrivate::deliverKeyEvent(QKeyEvent *e) } } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e) { Q_Q(QQuickItem); @@ -5017,7 +5017,7 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e) extra->keyHandler->inputMethodEvent(e, true); } } -#endif // QT_NO_IM +#endif // im /*! Called when \a change occurs for this item. @@ -5038,7 +5038,7 @@ void QQuickItem::itemChange(ItemChange change, const ItemChangeData &value) emit windowChanged(value.window); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! Notify input method on updated query values if needed. \a queries indicates the changed attributes. @@ -5048,7 +5048,7 @@ void QQuickItem::updateInputMethod(Qt::InputMethodQueries queries) if (hasActiveFocus()) QGuiApplication::inputMethod()->update(queries); } -#endif // QT_NO_IM +#endif // im /*! \internal */ // XXX todo - do we want/need this anymore? @@ -5790,7 +5790,7 @@ bool QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible) } itemChange(QQuickItem::ItemVisibleHasChanged, effectiveVisible); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (isAccessible) { QAccessibleEvent ev(q, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide); QAccessible::updateAccessibility(&ev); @@ -7074,7 +7074,7 @@ void QQuickItem::setAcceptHoverEvents(bool enabled) void QQuickItemPrivate::setHasCursorInChild(bool hasCursor) { -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) Q_Q(QQuickItem); // if we're asked to turn it off (because of an unsetcursor call, or a node @@ -7123,7 +7123,7 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover) } } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) /*! Returns the cursor shape for this item. @@ -7609,7 +7609,7 @@ bool QQuickItem::event(QEvent *ev) updatePolish(); break; #endif -#ifndef QT_NO_IM +#if QT_CONFIG(im) case QEvent::InputMethodQuery: { QInputMethodQueryEvent *query = static_cast(ev); Qt::InputMethodQueries queries = query->queries(); @@ -7626,7 +7626,7 @@ bool QQuickItem::event(QEvent *ev) case QEvent::InputMethod: inputMethodEvent(static_cast(ev)); break; -#endif // QT_NO_IM +#endif // im case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: @@ -7670,12 +7670,12 @@ bool QQuickItem::event(QEvent *ev) case QEvent::MouseButtonDblClick: mouseDoubleClickEvent(static_cast(ev)); break; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) case QEvent::Wheel: wheelEvent(static_cast(ev)); break; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: dragEnterEvent(static_cast(ev)); break; @@ -7688,12 +7688,12 @@ bool QQuickItem::event(QEvent *ev) case QEvent::Drop: dropEvent(static_cast(ev)); break; -#endif // QT_NO_DRAGANDDROP -#ifndef QT_NO_GESTURES +#endif // draganddrop +#if QT_CONFIG(gestures) case QEvent::NativeGesture: ev->ignore(); break; -#endif // QT_NO_GESTURES +#endif // gestures default: return QObject::event(ev); } @@ -8291,7 +8291,7 @@ QQuickItemPrivate::ExtraData::ExtraData() } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessible::Role QQuickItemPrivate::accessibleRole() const { Q_Q(const QQuickItem); diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h index b1b1d627b1..c9494d91bd 100644 --- a/src/quick/items/qquickitem.h +++ b/src/quick/items/qquickitem.h @@ -153,7 +153,7 @@ class Q_QUICK_EXPORT QQuickItem : public QObject, public QQmlParserStatus public: enum Flag { ItemClipsChildrenToShape = 0x01, -#ifndef QT_NO_IM +#if QT_CONFIG(im) ItemAcceptsInputMethod = 0x02, #endif ItemIsFocusScope = 0x04, @@ -292,7 +292,7 @@ public: bool acceptHoverEvents() const; void setAcceptHoverEvents(bool enabled); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QCursor cursor() const; void setCursor(const QCursor &cursor); void unsetCursor(); @@ -340,7 +340,7 @@ public: Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true); Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const; -#ifndef QT_NO_IM +#if QT_CONFIG(im) virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; #endif @@ -393,7 +393,7 @@ protected: bool isComponentComplete() const; virtual void itemChange(ItemChange, const ItemChangeData &); -#ifndef QT_NO_IM +#if QT_CONFIG(im) void updateInputMethod(Qt::InputMethodQueries queries = Qt::ImQueryInput); #endif @@ -406,7 +406,7 @@ protected: virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); -#ifndef QT_NO_IM +#if QT_CONFIG(im) virtual void inputMethodEvent(QInputMethodEvent *); #endif virtual void focusInEvent(QFocusEvent *); @@ -417,14 +417,14 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseUngrabEvent(); // XXX todo - params? virtual void touchUngrabEvent(); -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) virtual void wheelEvent(QWheelEvent *event); #endif virtual void touchEvent(QTouchEvent *event); virtual void hoverEnterEvent(QHoverEvent *event); virtual void hoverMoveEvent(QHoverEvent *event); virtual void hoverLeaveEvent(QHoverEvent *event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *); virtual void dragMoveEvent(QDragMoveEvent *); virtual void dragLeaveEvent(QDragLeaveEvent *); diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 4bff293657..45674a106d 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -347,7 +347,7 @@ public: #if QT_CONFIG(quick_shadereffect) mutable QQuickItemLayer *layer; #endif -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QCursor cursor; #endif QPointF userTransformOriginPoint; @@ -534,7 +534,7 @@ public: virtual void implicitWidthChanged(); virtual void implicitHeightChanged(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) virtual QAccessible::Role accessibleRole() const; #endif @@ -556,7 +556,7 @@ public: virtual void transformChanged(); void deliverKeyEvent(QKeyEvent *); -#ifndef QT_NO_IM +#if QT_CONFIG(im) void deliverInputMethodEvent(QInputMethodEvent *); #endif @@ -618,7 +618,7 @@ public: virtual void keyPressed(QKeyEvent *event, bool post); virtual void keyReleased(QKeyEvent *event, bool post); -#ifndef QT_NO_IM +#if QT_CONFIG(im) virtual void inputMethodEvent(QInputMethodEvent *event, bool post); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; #endif @@ -857,7 +857,7 @@ Q_SIGNALS: private: void keyPressed(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; void keyReleased(QKeyEvent *event, bool post) Q_DECL_OVERRIDE; -#ifndef QT_NO_IM +#if QT_CONFIG(im) void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE; QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; #endif diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 0705d9b504..8dd4a96b62 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -96,7 +96,7 @@ #include "qquickspritesequence_p.h" #include "qquickanimatedsprite_p.h" #endif -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include "qquickopenglinfo_p.h" #endif #include "qquickgraphicsinfo_p.h" @@ -278,7 +278,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType("QtQuick",2,0,"PathInterpolator"); #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) qmlRegisterType("QtQuick", 2, 0, "DropArea"); qmlRegisterType(); qmlRegisterType(); @@ -289,7 +289,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType("QtQuick", 2, 0, "TouchPoint"); qmlRegisterType(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) qmlRegisterUncreatableType("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties")); #endif @@ -325,7 +325,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType(uri, 2, 4, "ShaderEffect"); #endif -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) qmlRegisterUncreatableType(uri, 2, 4,"OpenGLInfo", QQuickOpenGLInfo::tr("OpenGLInfo is only available via attached properties")); #endif qmlRegisterType(uri, 2, 5,"PinchArea"); diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 6bd83dd808..5e30bf9e0a 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -61,10 +61,10 @@ QQuickMouseAreaPrivate::QQuickMouseAreaPrivate() : enabled(true), scrollGestureEnabled(true), hovered(false), longPress(false), moved(false), stealMouse(false), doubleClick(false), preventStealing(false), propagateComposedEvents(false), overThreshold(false), pressed(0) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) , drag(0) #endif -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) , cursor(0) #endif { @@ -72,10 +72,10 @@ QQuickMouseAreaPrivate::QQuickMouseAreaPrivate() QQuickMouseAreaPrivate::~QQuickMouseAreaPrivate() { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) delete drag; #endif -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) delete cursor; #endif } @@ -435,7 +435,7 @@ QQuickMouseArea::QQuickMouseArea(QQuickItem *parent) { Q_D(QQuickMouseArea); d->init(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) // Explcitly call setCursor on QQuickItem since // it internally keeps a boolean hasCursor that doesn't // get set to true unless you call setCursor @@ -679,7 +679,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event) } else { d->longPress = false; d->saveEvent(event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -705,7 +705,7 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) // ### can GV handle this for us? setHovered(contains(d->lastPos)); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->drag && d->drag->target()) { if (!d->moved) { d->targetStartPos = d->drag->target()->parentItem() @@ -788,7 +788,7 @@ void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event) setPressed(event->button(), false, event->source()); if (!d->pressed) { // no other buttons are pressed -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -866,7 +866,7 @@ void QQuickMouseArea::hoverLeaveEvent(QHoverEvent *event) setHovered(false); } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void QQuickMouseArea::wheelEvent(QWheelEvent *event) { Q_D(QQuickMouseArea); @@ -897,7 +897,7 @@ void QQuickMouseArea::ungrabMouse() d->overThreshold = false; setKeepMouseGrab(false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->drag) d->drag->setActive(false); #endif @@ -980,7 +980,7 @@ bool QQuickMouseArea::childMouseEventFilter(QQuickItem *i, QEvent *e) Q_D(QQuickMouseArea); if (!d->pressed && (!d->enabled || !isVisible() -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) || !d->drag || !d->drag->filterChildren() #endif ) @@ -1003,7 +1003,7 @@ void QQuickMouseArea::timerEvent(QTimerEvent *event) Q_D(QQuickMouseArea); if (event->timerId() == d->pressAndHoldTimer.timerId()) { d->pressAndHoldTimer.stop(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool dragged = d->drag && d->drag->active(); #else bool dragged = false; @@ -1179,7 +1179,7 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS { Q_D(QQuickMouseArea); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) bool dragged = d->drag && d->drag->active(); #else bool dragged = false; @@ -1276,7 +1276,7 @@ bool QQuickMouseArea::setPressed(Qt::MouseButton button, bool p, Qt::MouseEventS \sa Qt::CursorShape */ -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) Qt::CursorShape QQuickMouseArea::cursorShape() const { return cursor().shape(); @@ -1343,7 +1343,7 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape) */ -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QQuickDrag *QQuickMouseArea::drag() { Q_D(QQuickMouseArea); diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h index 5cd86541d4..d90c8e1baa 100644 --- a/src/quick/items/qquickmousearea_p.h +++ b/src/quick/items/qquickmousearea_p.h @@ -75,12 +75,12 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedButtonsChanged) Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_PROPERTY(QQuickDrag *drag READ drag CONSTANT) //### add flicking to QQuickDrag or add a QQuickFlick ??? #endif Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged) Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged) -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET unsetCursor NOTIFY cursorShapeChanged) #endif Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION 1) @@ -110,7 +110,7 @@ public: bool hoverEnabled() const; void setHoverEnabled(bool h); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QQuickDrag *drag(); #endif @@ -120,7 +120,7 @@ public: bool propagateComposedEvents() const; void setPropagateComposedEvents(bool propagate); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) Qt::CursorShape cursorShape() const; void setCursorShape(Qt::CursorShape shape); #endif @@ -133,7 +133,7 @@ Q_SIGNALS: void pressedButtonsChanged(); void acceptedButtonsChanged(); void hoverEnabledChanged(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursorShapeChanged(); #endif void positionChanged(QQuickMouseEvent *mouse); @@ -166,7 +166,7 @@ protected: void hoverEnterEvent(QHoverEvent *event) Q_DECL_OVERRIDE; void hoverMoveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; void hoverLeaveEvent(QHoverEvent *event) Q_DECL_OVERRIDE; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE; #endif bool childMouseEventFilter(QQuickItem *i, QEvent *e) Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h index b59e02910f..456b1866a3 100644 --- a/src/quick/items/qquickmousearea_p_p.h +++ b/src/quick/items/qquickmousearea_p_p.h @@ -95,7 +95,7 @@ public: bool propagateComposedEvents : 1; bool overThreshold : 1; Qt::MouseButtons pressed; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QQuickDrag *drag; #endif QPointF startScene; @@ -106,7 +106,7 @@ public: Qt::MouseButtons lastButtons; Qt::KeyboardModifiers lastModifiers; QBasicTimer pressAndHoldTimer; -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QCursor *cursor; #endif QQuickMouseEvent quickMouseEvent; diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp index 1ef8de753d..c5155c9c35 100644 --- a/src/quick/items/qquickpainteditem.cpp +++ b/src/quick/items/qquickpainteditem.cpp @@ -662,7 +662,7 @@ QSGTextureProvider *QQuickPaintedItem::textureProvider() const return QQuickItem::textureProvider(); Q_D(const QQuickPaintedItem); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickWindow *w = window(); if (!w || !w->openglContext() || QThread::currentThread() != w->openglContext()->thread()) { qWarning("QQuickPaintedItem::textureProvider: can only be queried on the rendering thread of an exposed window"); diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp index fd8971c845..6295aa1932 100644 --- a/src/quick/items/qquickpincharea.cpp +++ b/src/quick/items/qquickpincharea.cpp @@ -682,7 +682,7 @@ bool QQuickPinchArea::event(QEvent *event) return QQuickItem::event(event); switch (event->type()) { -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) case QEvent::NativeGesture: { QNativeGestureEvent *gesture = static_cast(event); switch (gesture->gestureType()) { @@ -775,7 +775,7 @@ bool QQuickPinchArea::event(QEvent *event) return QQuickItem::event(event); } } break; -#endif // QT_NO_GESTURES +#endif // gestures case QEvent::Wheel: event->ignore(); return false; diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 74aa2da9e0..13e13890b7 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -44,7 +44,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #if QT_CONFIG(quick_shadereffect) @@ -62,7 +62,7 @@ #include QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); #endif /*! @@ -227,7 +227,7 @@ void QQuickRenderControl::initialize(QOpenGLContext *gl) { Q_D(QQuickRenderControl); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!d->window) { qWarning("QQuickRenderControl::initialize called with no associated window"); return; @@ -379,7 +379,7 @@ QImage QQuickRenderControl::grab() QImage grabContent; if (d->window->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) render(); grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), false, false); #endif diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 5670696ce2..7926607e33 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -40,7 +40,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #endif #include @@ -499,14 +499,14 @@ QSGContextFactoryInterface::Flags qsg_backend_flags(); QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent) : QQuickItem(*new QQuickShaderEffectPrivate, parent), -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_glImpl(nullptr), #endif m_impl(nullptr) { setFlag(QQuickItem::ItemHasContents); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!qsg_backend_flags().testFlag(QSGContextFactoryInterface::SupportsShaderEffectNode)) m_glImpl = new QQuickOpenGLShaderEffect(this, this); @@ -539,7 +539,7 @@ QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent) QByteArray QQuickShaderEffect::fragmentShader() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->fragmentShader(); #endif @@ -548,7 +548,7 @@ QByteArray QQuickShaderEffect::fragmentShader() const void QQuickShaderEffect::setFragmentShader(const QByteArray &code) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setFragmentShader(code); return; @@ -578,7 +578,7 @@ void QQuickShaderEffect::setFragmentShader(const QByteArray &code) QByteArray QQuickShaderEffect::vertexShader() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->vertexShader(); #endif @@ -587,7 +587,7 @@ QByteArray QQuickShaderEffect::vertexShader() const void QQuickShaderEffect::setVertexShader(const QByteArray &code) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setVertexShader(code); return; @@ -607,7 +607,7 @@ void QQuickShaderEffect::setVertexShader(const QByteArray &code) bool QQuickShaderEffect::blending() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->blending(); #endif @@ -616,7 +616,7 @@ bool QQuickShaderEffect::blending() const void QQuickShaderEffect::setBlending(bool enable) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setBlending(enable); return; @@ -640,7 +640,7 @@ void QQuickShaderEffect::setBlending(bool enable) QVariant QQuickShaderEffect::mesh() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->mesh(); #endif @@ -649,7 +649,7 @@ QVariant QQuickShaderEffect::mesh() const void QQuickShaderEffect::setMesh(const QVariant &mesh) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setMesh(mesh); return; @@ -674,7 +674,7 @@ void QQuickShaderEffect::setMesh(const QVariant &mesh) QQuickShaderEffect::CullMode QQuickShaderEffect::cullMode() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->cullMode(); #endif @@ -683,7 +683,7 @@ QQuickShaderEffect::CullMode QQuickShaderEffect::cullMode() const void QQuickShaderEffect::setCullMode(CullMode face) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setCullMode(face); return; @@ -715,7 +715,7 @@ void QQuickShaderEffect::setCullMode(CullMode face) bool QQuickShaderEffect::supportsAtlasTextures() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->supportsAtlasTextures(); #endif @@ -724,7 +724,7 @@ bool QQuickShaderEffect::supportsAtlasTextures() const void QQuickShaderEffect::setSupportsAtlasTextures(bool supports) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->setSupportsAtlasTextures(supports); return; @@ -771,7 +771,7 @@ void QQuickShaderEffect::setSupportsAtlasTextures(bool supports) QString QQuickShaderEffect::log() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->log(); #endif @@ -780,7 +780,7 @@ QString QQuickShaderEffect::log() const QQuickShaderEffect::Status QQuickShaderEffect::status() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->status(); #endif @@ -789,7 +789,7 @@ QQuickShaderEffect::Status QQuickShaderEffect::status() const bool QQuickShaderEffect::event(QEvent *e) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->handleEvent(e); return QQuickItem::event(e); @@ -801,7 +801,7 @@ bool QQuickShaderEffect::event(QEvent *e) void QQuickShaderEffect::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->handleGeometryChanged(newGeometry, oldGeometry); QQuickItem::geometryChanged(newGeometry, oldGeometry); @@ -814,7 +814,7 @@ void QQuickShaderEffect::geometryChanged(const QRectF &newGeometry, const QRectF QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->handleUpdatePaintNode(oldNode, updatePaintNodeData); #endif @@ -823,7 +823,7 @@ QSGNode *QQuickShaderEffect::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa void QQuickShaderEffect::componentComplete() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->maybeUpdateShaders(); QQuickItem::componentComplete(); @@ -836,7 +836,7 @@ void QQuickShaderEffect::componentComplete() void QQuickShaderEffect::itemChange(ItemChange change, const ItemChangeData &value) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) { m_glImpl->handleItemChange(change, value); QQuickItem::itemChange(change, value); @@ -854,7 +854,7 @@ bool QQuickShaderEffect::isComponentComplete() const QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_glImpl) return m_glImpl->parseLog(); #endif @@ -864,7 +864,7 @@ QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests void QQuickShaderEffectPrivate::updatePolish() { Q_Q(QQuickShaderEffect); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (q->m_glImpl) { q->m_glImpl->maybeUpdateShaders(); return; diff --git a/src/quick/items/qquickshadereffect_p.h b/src/quick/items/qquickshadereffect_p.h index 2b7ff4cf6e..7885daffbb 100644 --- a/src/quick/items/qquickshadereffect_p.h +++ b/src/quick/items/qquickshadereffect_p.h @@ -135,7 +135,7 @@ protected: void itemChange(ItemChange change, const ItemChangeData &value) override; private: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QQuickOpenGLShaderEffect *m_glImpl; #endif QQuickGenericShaderEffect *m_impl; diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 2bfb4501fc..e37a7e6d5e 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1819,7 +1819,7 @@ bool QQuickTextPrivate::setHAlign(QQuickText::HAlignment alignment, bool forceAl bool QQuickTextPrivate::determineHorizontalAlignment() { if (hAlignImplicit) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool alignToRight = text.isEmpty() ? QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText; #else bool alignToRight = rightToLeftText; @@ -2713,12 +2713,12 @@ QString QQuickText::hoveredLink() const if (d->extra.isAllocated()) return d->extra->hoveredLink; } else { -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) if (QQuickWindow *wnd = window()) { QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0)); return d->anchorAt(pos); } -#endif // QT_NO_CURSOR +#endif // cursor } return QString(); } diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index ef7485a8e9..887cc6fea7 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -79,9 +79,6 @@ const int textCursorWidth = 1; QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE) -#ifndef QT_NO_CONTEXTMENU -#endif - // could go into QTextCursor... static QTextLine currentTextLine(const QTextCursor &cursor) { @@ -99,7 +96,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor) QQuickTextControlPrivate::QQuickTextControlPrivate() : doc(0), -#ifndef QT_NO_IM +#if QT_CONFIG(im) preeditCursor(0), #endif interactionFlags(Qt::TextEditorInteraction), @@ -123,7 +120,7 @@ QQuickTextControlPrivate::QQuickTextControlPrivate() bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e) { -#ifdef QT_NO_SHORTCUT +#if !QT_CONFIG(shortcut) Q_UNUSED(e); #endif @@ -139,7 +136,7 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e) if (false) { } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (e == QKeySequence::MoveToNextChar) { op = QTextCursor::Right; } @@ -232,7 +229,7 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e) else if (e == QKeySequence::MoveToEndOfDocument) { op = QTextCursor::End; } -#endif // QT_NO_SHORTCUT +#endif // shortcut else { return false; } @@ -290,7 +287,7 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString & { Q_Q(QQuickTextControl); -#ifndef QT_NO_IM +#if QT_CONFIG(im) cancelPreedit(); #endif @@ -326,7 +323,7 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString & formatCursor.setCharFormat(charFormatForInsertion); formatCursor.endEditBlock(); } else { -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) doc->setHtml(text); #else doc->setPlainText(text); @@ -407,7 +404,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged / { Q_Q(QQuickTextControl); if (forceEmitSelectionChanged) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (hasFocus) qGuiApp->inputMethod()->update(Qt::ImCurrentSelection); #endif @@ -429,7 +426,7 @@ void QQuickTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged / lastSelectionEnd = selectionEnd; if (!forceEmitSelectionChanged) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (hasFocus) qGuiApp->inputMethod()->update(Qt::ImCurrentSelection); #endif @@ -443,7 +440,7 @@ void QQuickTextControlPrivate::_q_updateCurrentCharFormatAndSelection() selectionChanged(); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void QQuickTextControlPrivate::setClipboardSelection() { QClipboard *clipboard = QGuiApplication::clipboard(); @@ -544,7 +541,7 @@ void QQuickTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, } if (interactionFlags & Qt::TextSelectableByMouse) { -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) setClipboardSelection(); #endif selectionChanged(true); @@ -574,7 +571,7 @@ void QQuickTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition } if (interactionFlags & Qt::TextSelectableByMouse) { -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) setClipboardSelection(); #endif selectionChanged(true); @@ -656,7 +653,7 @@ void QQuickTextControl::updateCursorRectangle(bool force) void QQuickTextControl::setTextCursor(const QTextCursor &cursor) { Q_D(QQuickTextControl); -#ifndef QT_NO_IM +#if QT_CONFIG(im) d->commitPreedit(); #endif d->cursorIsFocusIndicator = false; @@ -677,7 +674,7 @@ QTextCursor QQuickTextControl::textCursor() const return d->cursor; } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void QQuickTextControl::cut() { @@ -759,7 +756,7 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix) QHoverEvent *ev = static_cast(e); d->hoverEvent(ev, matrix.map(ev->posF())); break; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) case QEvent::InputMethod: d->inputMethodEvent(static_cast(e)); break; @@ -795,7 +792,7 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix) break; } } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) } else if (ke == QKeySequence::Copy || ke == QKeySequence::Paste || ke == QKeySequence::Cut @@ -873,20 +870,20 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) return; } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (e == QKeySequence::SelectAll) { e->accept(); q->selectAll(); return; } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) else if (e == QKeySequence::Copy) { e->accept(); q->copy(); return; } #endif -#endif // QT_NO_SHORTCUT +#endif // shortcut if (interactionFlags & Qt::TextSelectableByKeyboard && cursorMoveKeyEvent(e)) @@ -924,7 +921,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) } goto accept; } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) else if (e == QKeySequence::InsertParagraphSeparator) { cursor.insertBlock(); e->accept(); @@ -937,14 +934,14 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) #endif if (false) { } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) else if (e == QKeySequence::Undo) { q->undo(); } else if (e == QKeySequence::Redo) { q->redo(); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) else if (e == QKeySequence::Cut) { q->cut(); } @@ -975,7 +972,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cursor.removeSelectedText(); } -#endif // QT_NO_SHORTCUT +#endif // shortcut else { goto process; } @@ -1019,7 +1016,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const const QTextLayout *layout = block.layout(); const QPointF layoutPos = q->blockBoundingRect(block).topLeft(); int relativePos = position - block.position(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditCursor != 0) { int preeditPos = layout->preeditAreaPosition(); if (relativePos == preeditPos) @@ -1083,7 +1080,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po const QTextCursor oldSelection = cursor; const int oldCursorPos = cursor.position(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) commitPreedit(); #endif @@ -1157,7 +1154,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (isPreediting()) { // note: oldCursorPos not including preedit int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit); @@ -1183,7 +1180,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou extendBlockwiseSelection(newCursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(newCursorPos, mouseX); -#ifndef QT_NO_IM +#if QT_CONFIG(im) else if (!isPreediting()) setCursorPosition(newCursorPos, QTextCursor::KeepAnchor); #endif @@ -1194,7 +1191,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou q->updateCursorRectangle(true); } _q_updateCurrentCharFormatAndSelection(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (qGuiApp) qGuiApp->inputMethod()->update(Qt::ImQueryInput); #endif @@ -1221,7 +1218,7 @@ void QQuickTextControlPrivate::mouseReleaseEvent(QMouseEvent *e, const QPointF & if (mousePressed) { mousePressed = false; -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) setClipboardSelection(); selectionChanged(true); } else if (e->button() == Qt::MidButton @@ -1270,7 +1267,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin Q_Q(QQuickTextControl); if (e->button() == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) commitPreedit(); #endif @@ -1291,7 +1288,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin tripleClickTimer.start(QGuiApplication::styleHints()->mouseDoubleClickInterval(), q); if (doEmit) { selectionChanged(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) setClipboardSelection(); #endif emit q->cursorPositionChanged(); @@ -1304,7 +1301,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, const QPointF &pos) { -#if !defined(QT_NO_IM) +#if QT_CONFIG(im) Q_Q(QQuickTextControl); Q_UNUSED(e); @@ -1328,7 +1325,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons return false; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) { Q_Q(QQuickTextControl); @@ -1481,7 +1478,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, QVar return QVariant(); } } -#endif // QT_NO_IM +#endif // im void QQuickTextControlPrivate::focusEvent(QFocusEvent *e) { @@ -1611,7 +1608,7 @@ void QQuickTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::M bool QQuickTextControl::canPaste() const { -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) Q_D(const QQuickTextControl); if (d->interactionFlags & Qt::TextEditable) { const QMimeData *md = QGuiApplication::clipboard()->mimeData(); @@ -1661,7 +1658,7 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source) bool hasData = false; QTextDocumentFragment fragment; -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) { // x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore). QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext"))); @@ -1680,7 +1677,7 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source) } #else fragment = QTextDocumentFragment::fromPlainText(source->text()); -#endif // QT_NO_TEXTHTMLPARSER +#endif // texthtmlparser if (hasData) d->cursor.insertFragment(fragment); @@ -1751,7 +1748,7 @@ void QQuickTextControlPrivate::activateLinkUnderCursor(QString href) emit q_func()->linkActivated(href); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool QQuickTextControlPrivate::isPreediting() const { QTextLayout *layout = cursor.block().layout(); @@ -1789,7 +1786,7 @@ void QQuickTextControlPrivate::cancelPreedit() QInputMethodEvent event; QCoreApplication::sendEvent(q->parent(), &event); } -#endif // QT_NO_IM +#endif // im void QQuickTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags) { @@ -1813,7 +1810,7 @@ QString QQuickTextControl::toPlainText() const return document()->toPlainText(); } -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) QString QQuickTextControl::toHtml() const { return document()->toHtml(); @@ -1840,7 +1837,7 @@ QRectF QQuickTextControl::blockBoundingRect(const QTextBlock &block) const QString QQuickTextControl::preeditText() const { -#ifndef QT_NO_IM +#if QT_CONFIG(im) Q_D(const QQuickTextControl); QTextLayout *layout = d->cursor.block().layout(); if (!layout) @@ -1857,7 +1854,7 @@ QStringList QQuickTextEditMimeData::formats() const { if (!fragment.isEmpty()) return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html") -#ifndef QT_NO_TEXTODFWRITER +#if QT_CONFIG(textodfwriter) << QString::fromLatin1("application/vnd.oasis.opendocument.text") #endif ; @@ -1875,10 +1872,10 @@ QVariant QQuickTextEditMimeData::retrieveData(const QString &mimeType, QVariant: void QQuickTextEditMimeData::setup() const { QQuickTextEditMimeData *that = const_cast(this); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) that->setData(QLatin1String("text/html"), fragment.toHtml("utf-8").toUtf8()); #endif -#ifndef QT_NO_TEXTODFWRITER +#if QT_CONFIG(textodfwriter) { QBuffer buffer; QTextDocumentWriter writer(&buffer, "ODF"); diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h index 602e457cb8..7992d2943b 100644 --- a/src/quick/items/qquicktextcontrol_p.h +++ b/src/quick/items/qquicktextcontrol_p.h @@ -89,7 +89,7 @@ public: QString toPlainText() const; -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) QString toHtml() const; #endif @@ -129,7 +129,7 @@ public Q_SLOTS: void setPlainText(const QString &text); void setHtml(const QString &text); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void cut(); void copy(); void paste(QClipboard::Mode mode = QClipboard::Clipboard); @@ -164,7 +164,7 @@ public: virtual void processEvent(QEvent *e, const QMatrix &matrix); void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const; Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h index 0f78feb5de..0582e6d113 100644 --- a/src/quick/items/qquicktextcontrol_p_p.h +++ b/src/quick/items/qquicktextcontrol_p_p.h @@ -90,7 +90,7 @@ public: void _q_updateCurrentCharFormatAndSelection(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void setClipboardSelection(); #endif @@ -114,14 +114,14 @@ public: void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos); bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos); void focusEvent(QFocusEvent *e); -#ifndef QT_NO_IM +#if QT_CONFIG(im) void inputMethodEvent(QInputMethodEvent *); #endif void hoverEvent(QHoverEvent *e, const QPointF &pos); void activateLinkUnderCursor(QString href = QString()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool isPreediting() const; void commitPreedit(); void cancelPreedit(); @@ -143,7 +143,7 @@ public: QBasicTimer cursorBlinkTimer; QBasicTimer tripleClickTimer; -#ifndef QT_NO_IM +#if QT_CONFIG(im) int preeditCursor; #endif diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp index 1dc54eb107..e7492b97ae 100644 --- a/src/quick/items/qquicktextdocument.cpp +++ b/src/quick/items/qquicktextdocument.cpp @@ -230,7 +230,7 @@ void QQuickTextDocumentWithImageResources::setText(const QString &text) { clearResources(); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) setHtml(text); #else setPlainText(text); diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 3389a608bf..b99e53b6c8 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -190,7 +190,7 @@ QString QQuickTextEdit::text() const Q_D(const QQuickTextEdit); if (!d->textCached && isComponentComplete()) { QQuickTextEditPrivate *d = const_cast(d_func()); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) if (d->richText) d->text = d->control->toHtml(); else @@ -381,7 +381,7 @@ void QQuickTextEdit::setText(const QString &text) if (!isComponentComplete()) { d->text = text; } else if (d->richText) { -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) d->control->setHtml(text); #else d->control->setPlainText(text); @@ -458,7 +458,7 @@ void QQuickTextEdit::setTextFormat(TextFormat format) bool wasRich = d->richText; d->richText = format == RichText || (format == AutoText && (wasRich || Qt::mightBeRichText(text()))); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) if (isComponentComplete()) { if (wasRich && !d->richText) { d->control->setPlainText(!d->textCached ? d->control->toHtml() : d->text); @@ -540,7 +540,7 @@ void QQuickTextEdit::setFont(const QFont &font) } updateSize(); updateWholeDocument(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImFont); #endif } @@ -738,7 +738,7 @@ bool QQuickTextEditPrivate::determineHorizontalAlignment() Q_Q(QQuickTextEdit); if (hAlignImplicit && q->isComponentComplete()) { Qt::LayoutDirection direction = contentDirection; -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (direction == Qt::LayoutDirectionAuto) { const QString preeditText = control->textCursor().block().layout()->preeditAreaText(); direction = textDirection(preeditText); @@ -764,7 +764,7 @@ void QQuickTextEditPrivate::mirrorChange() } } -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints QQuickTextEditPrivate::effectiveInputMethodHints() const { return inputMethodHints | Qt::ImhMultiLine; @@ -1012,7 +1012,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const y -= d->yoff; int r = d->document->documentLayout()->hitTest(QPointF(x, y), Qt::FuzzyHit); -#ifndef QT_NO_IM +#if QT_CONFIG(im) QTextCursor cursor = d->control->textCursor(); if (r > cursor.position()) { // The cursor position includes positions within the preedit text, but only positions in the @@ -1261,7 +1261,7 @@ int QQuickTextEdit::selectionEnd() const QString QQuickTextEdit::selectedText() const { Q_D(const QQuickTextEdit); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) return d->richText ? d->control->textCursor().selectedText() : d->control->textCursor().selection().toPlainText(); @@ -1379,17 +1379,17 @@ void QQuickTextEdit::setTextMargin(qreal margin) Qt::InputMethodHints QQuickTextEdit::inputMethodHints() const { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) return Qt::ImhNone; #else Q_D(const QQuickTextEdit); return d->inputMethodHints; -#endif // QT_NO_IM +#endif // im } void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints) { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) Q_UNUSED(hints); #else Q_D(QQuickTextEdit); @@ -1400,7 +1400,7 @@ void QQuickTextEdit::setInputMethodHints(Qt::InputMethodHints hints) d->inputMethodHints = hints; updateInputMethod(Qt::ImHints); emit inputMethodHintsChanged(); -#endif // QT_NO_IM +#endif // im } void QQuickTextEdit::geometryChanged(const QRectF &newGeometry, @@ -1427,7 +1427,7 @@ void QQuickTextEdit::componentComplete() QQuickImplicitSizeItem::componentComplete(); d->document->setBaseUrl(baseUrl()); -#ifndef QT_NO_TEXTHTML_PARSER +#if QT_CONFIG(texthtmlparser) if (d->richText) d->control->setHtml(d->text); else @@ -1554,7 +1554,7 @@ void QQuickTextEdit::setReadOnly(bool r) if (r == isReadOnly()) return; -#ifndef QT_NO_IM +#if QT_CONFIG(im) setFlag(QQuickItem::ItemAcceptsInputMethod, !r); #endif Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse; @@ -1569,7 +1569,7 @@ void QQuickTextEdit::setReadOnly(bool r) d->control->setTextInteractionFlags(flags); d->control->moveCursor(QTextCursor::End); -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImEnabled); #endif q_canPasteChanged(); @@ -1748,7 +1748,7 @@ bool QQuickTextEdit::isRightToLeft(int start, int end) } } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) /*! \qmlmethod QtQuick::TextEdit::cut() @@ -1781,7 +1781,7 @@ void QQuickTextEdit::paste() Q_D(QQuickTextEdit); d->control->paste(); } -#endif // QT_NO_CLIPBOARD +#endif // clipboard /*! @@ -1822,7 +1822,7 @@ void QQuickTextEdit::mousePressEvent(QMouseEvent *event) bool hadActiveFocus = hasActiveFocus(); forceActiveFocus(Qt::MouseFocusReason); // re-open input panel on press if already focused -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) qGuiApp->inputMethod()->show(); #else @@ -1870,7 +1870,7 @@ void QQuickTextEdit::mouseMoveEvent(QMouseEvent *event) QQuickImplicitSizeItem::mouseMoveEvent(event); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! \overload Handles the given input method \a event. @@ -1923,7 +1923,7 @@ QVariant QQuickTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const { return inputMethodQuery(property, QVariant()); } -#endif // QT_NO_IM +#endif // im void QQuickTextEdit::triggerPreprocess() { @@ -2197,12 +2197,12 @@ bool QQuickTextEdit::canRedo() const */ bool QQuickTextEdit::isInputMethodComposing() const { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) return false; #else Q_D(const QQuickTextEdit); return d->control->hasImState(); -#endif // QT_NO_IM +#endif // im } QQuickTextEditPrivate::ExtraData::ExtraData() @@ -2223,14 +2223,14 @@ void QQuickTextEditPrivate::init() { Q_Q(QQuickTextEdit); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) if (QGuiApplication::clipboard()->supportsSelection()) q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton); else #endif q->setAcceptedMouseButtons(Qt::LeftButton); -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->setFlag(QQuickItem::ItemAcceptsInputMethod); #endif q->setFlag(QQuickItem::ItemHasContents); @@ -2255,7 +2255,7 @@ void QQuickTextEditPrivate::init() qmlobject_connect(control, QQuickTextControl, SIGNAL(overwriteModeChanged(bool)), q, QQuickTextEdit, SIGNAL(overwriteModeChanged(bool))); qmlobject_connect(control, QQuickTextControl, SIGNAL(textChanged()), q, QQuickTextEdit, SLOT(q_textChanged())); qmlobject_connect(control, QQuickTextControl, SIGNAL(preeditTextChanged()), q, QQuickTextEdit, SIGNAL(preeditTextChanged())); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()), q, QQuickTextEdit, SLOT(q_canPasteChanged())); #endif qmlobject_connect(document, QQuickTextDocumentWithImageResources, SIGNAL(undoAvailable(bool)), q, QQuickTextEdit, SIGNAL(canUndoChanged())); @@ -2341,7 +2341,7 @@ void QQuickTextEdit::q_contentsChange(int pos, int charsRemoved, int charsAdded) void QQuickTextEdit::moveCursorDelegate() { Q_D(QQuickTextEdit); -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(); #endif emit cursorRectangleChanged(); @@ -2582,7 +2582,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption() else opt.setAlignment(Qt::Alignment(vAlign)); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (contentDirection == Qt::LayoutDirectionAuto) { opt.setTextDirection(qGuiApp->inputMethod()->inputDirection()); } else @@ -2627,14 +2627,14 @@ void QQuickTextEditPrivate::handleFocusEvent(QFocusEvent *event) control->processEvent(event, QPointF(-xoff, -yoff)); if (focus) { q->q_updateAlignment(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (focusOnPress && !q->isReadOnly()) qGuiApp->inputMethod()->show(); q->connect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), q, SLOT(q_updateAlignment())); #endif } else { -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), q, SLOT(q_updateAlignment())); #endif @@ -2685,7 +2685,7 @@ QString QQuickTextEdit::getText(int start, int end) const QTextCursor cursor(d->document); cursor.setPosition(start, QTextCursor::MoveAnchor); cursor.setPosition(end, QTextCursor::KeepAnchor); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) return d->richText ? cursor.selectedText() : cursor.selection().toPlainText(); @@ -2714,7 +2714,7 @@ QString QQuickTextEdit::getFormattedText(int start, int end) const cursor.setPosition(end, QTextCursor::KeepAnchor); if (d->richText) { -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) return cursor.selection().toHtml(); #else return cursor.selection().toPlainText(); @@ -2738,7 +2738,7 @@ void QQuickTextEdit::insert(int position, const QString &text) cursor.setPosition(position); d->richText = d->richText || (d->format == AutoText && Qt::mightBeRichText(text)); if (d->richText) { -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) cursor.insertHtml(text); #else cursor.insertText(text); @@ -2831,12 +2831,12 @@ QString QQuickTextEdit::hoveredLink() const if (const_cast(d)->isLinkHoveredConnected()) { return d->control->hoveredLink(); } else { -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) if (QQuickWindow *wnd = window()) { QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0)); return d->control->anchorAt(pos); } -#endif // QT_NO_CURSOR +#endif // cursor } return QString(); } @@ -2881,7 +2881,7 @@ void QQuickTextEdit::append(const QString &text) if (!d->document->isEmpty()) cursor.insertBlock(); -#ifndef QT_NO_TEXTHTMLPARSER +#if QT_CONFIG(texthtmlparser) if (d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text))) { cursor.insertHtml(text); } else { @@ -2889,7 +2889,7 @@ void QQuickTextEdit::append(const QString &text) } #else cursor.insertText(text); -#endif // QT_NO_TEXTHTMLPARSER +#endif // texthtmlparser cursor.endEditBlock(); d->control->updateCursorRectangle(false); diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index 42c9064860..c8d3515be1 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -242,7 +242,7 @@ public: QRectF cursorRectangle() const; -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_REVISION(4) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif @@ -347,7 +347,7 @@ public Q_SLOTS: void select(int start, int end); void deselect(); bool isRightToLeft(int start, int end); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void cut(); void copy(); void paste(); @@ -399,7 +399,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; -#ifndef QT_NO_IM +#if QT_CONFIG(im) void inputMethodEvent(QInputMethodEvent *e) Q_DECL_OVERRIDE; #endif QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index 1613dd7676..03bce00cb0 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -119,7 +119,7 @@ public: #endif , contentDirection(Qt::LayoutDirectionAuto) , mouseSelectionMode(QQuickTextEdit::SelectCharacters) -#ifndef QT_NO_IM +#if QT_CONFIG(im) , inputMethodHints(Qt::ImhNone) #endif , updateType(UpdatePaintNode) @@ -156,7 +156,7 @@ public: void addCurrentTextNodeToRoot(QQuickTextNodeEngine *, QSGTransformNode *, QQuickTextNode*, TextNodeIterator&, int startPos); QQuickTextNode* createTextNode(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints effectiveInputMethodHints() const; #endif @@ -208,7 +208,7 @@ public: QQuickTextEdit::RenderType renderType; Qt::LayoutDirection contentDirection; QQuickTextEdit::SelectionMode mouseSelectionMode; -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints inputMethodHints; #endif UpdateType updateType; diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index dc4aecbbeb..96a46df2f4 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -57,7 +57,7 @@ #include #include -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "qaccessible.h" #include "qquickaccessibleattached_p.h" #endif @@ -142,7 +142,7 @@ void QQuickTextInput::setText(const QString &s) if (s == text()) return; -#ifndef QT_NO_IM +#if QT_CONFIG(im) d->cancelPreedit(); #endif d->internalSetText(s, -1, false); @@ -400,7 +400,7 @@ void QQuickTextInput::setFont(const QFont &font) if (oldFont != d->font) { d->updateLayout(); updateCursorRectangle(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImCursorRectangle | Qt::ImFont | Qt::ImAnchorRectangle); #endif } @@ -575,7 +575,7 @@ bool QQuickTextInputPrivate::setHAlign(QQuickTextInput::HAlignment alignment, bo Qt::LayoutDirection QQuickTextInputPrivate::textDirection() const { QString text = m_text; -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (text.isEmpty()) text = m_textLayout.preeditAreaText(); #endif @@ -602,7 +602,7 @@ Qt::LayoutDirection QQuickTextInputPrivate::layoutDirection() const Qt::LayoutDirection direction = m_layoutDirection; if (direction == Qt::LayoutDirectionAuto) { direction = textDirection(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (direction == Qt::LayoutDirectionAuto) direction = QGuiApplication::inputMethod()->inputDirection(); #endif @@ -615,7 +615,7 @@ bool QQuickTextInputPrivate::determineHorizontalAlignment() if (hAlignImplicit) { // if no explicit alignment has been set, follow the natural layout direction of the text Qt::LayoutDirection direction = textDirection(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (direction == Qt::LayoutDirectionAuto) direction = QGuiApplication::inputMethod()->inputDirection(); #endif @@ -707,12 +707,12 @@ void QQuickTextInput::setReadOnly(bool ro) if (d->m_readOnly == ro) return; -#ifndef QT_NO_IM +#if QT_CONFIG(im) setFlag(QQuickItem::ItemAcceptsInputMethod, !ro); #endif d->m_readOnly = ro; d->setCursorPosition(d->end()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImEnabled); #endif q_canPasteChanged(); @@ -830,7 +830,7 @@ QRectF QQuickTextInput::cursorRectangle() const Q_D(const QQuickTextInput); int c = d->m_cursor; -#ifndef QT_NO_IM +#if QT_CONFIG(im) c += d->m_preeditCursor; #endif if (d->m_echoMode == NoEcho) @@ -994,17 +994,17 @@ void QQuickTextInput::setAutoScroll(bool b) QValidator* QQuickTextInput::validator() const { -#ifdef QT_NO_VALIDATOR +#if !QT_CONFIG(validator) return 0; #else Q_D(const QQuickTextInput); return d->m_validator; -#endif // QT_NO_VALIDATOR +#endif // validator } void QQuickTextInput::setValidator(QValidator* v) { -#ifdef QT_NO_VALIDATOR +#if !QT_CONFIG(validator) Q_UNUSED(v); #else Q_D(QQuickTextInput); @@ -1029,16 +1029,16 @@ void QQuickTextInput::setValidator(QValidator* v) d->checkIsValid(); emit validatorChanged(); -#endif // QT_NO_VALIDATOR +#endif // validator } -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) void QQuickTextInput::q_validatorChanged() { Q_D(QQuickTextInput); d->checkIsValid(); } -#endif // QT_NO_VALIDATOR +#endif // validator QRectF QQuickTextInputPrivate::anchorRectangle() const { @@ -1056,7 +1056,7 @@ QRectF QQuickTextInputPrivate::anchorRectangle() const else a = m_selstart == m_cursor ? m_selend : m_selstart; if (a >= 0) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) a += m_preeditCursor; #endif if (m_echoMode == QQuickTextInput::NoEcho) @@ -1151,7 +1151,7 @@ bool QQuickTextInput::hasAcceptableInput() const The corresponding handler is \c onEditingFinished. */ -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const { Qt::InputMethodHints hints = inputMethodHints; @@ -1192,7 +1192,7 @@ void QQuickTextInput::setEchoMode(QQuickTextInput::EchoMode echo) d->cancelPasswordEchoTimer(); d->m_echoMode = echo; d->m_passwordEchoEditing = false; -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImHints); #endif d->updateDisplayText(); @@ -1249,17 +1249,17 @@ void QQuickTextInput::setEchoMode(QQuickTextInput::EchoMode echo) Qt::InputMethodHints QQuickTextInput::inputMethodHints() const { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) return Qt::ImhNone; #else Q_D(const QQuickTextInput); return d->inputMethodHints; -#endif // QT_NO_IM +#endif // im } void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints) { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) Q_UNUSED(hints); #else Q_D(QQuickTextInput); @@ -1270,7 +1270,7 @@ void QQuickTextInput::setInputMethodHints(Qt::InputMethodHints hints) d->inputMethodHints = hints; updateInputMethod(Qt::ImHints); emit inputMethodHintsChanged(); -#endif // QT_NO_IM +#endif // im } /*! @@ -1319,7 +1319,7 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const Q_D(const QQuickTextInput); if (d->m_echoMode == NoEcho) pos = 0; -#ifndef QT_NO_IM +#if QT_CONFIG(im) else if (pos > d->m_cursor) pos += d->preeditAreaText().length(); #endif @@ -1389,7 +1389,7 @@ void QQuickTextInput::positionAt(QQmlV4Function *args) const int pos = d->positionAt(x, y, position); const int cursor = d->m_cursor; if (pos > cursor) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) const int preeditLength = d->preeditAreaText().length(); pos = pos > cursor + preeditLength ? pos - preeditLength @@ -1470,7 +1470,7 @@ void QQuickTextInput::keyPressEvent(QKeyEvent* ev) QQuickImplicitSizeItem::keyPressEvent(ev); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void QQuickTextInput::inputMethodEvent(QInputMethodEvent *ev) { Q_D(QQuickTextInput); @@ -1493,7 +1493,7 @@ void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event) Q_D(QQuickTextInput); if (d->selectByMouse && event->button() == Qt::LeftButton) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) d->commitPreedit(); #endif int cursor = d->positionAt(event->localPos()); @@ -1549,7 +1549,7 @@ void QQuickTextInput::mouseMoveEvent(QMouseEvent *event) if (qAbs(int(event->localPos().x() - d->pressPos.x())) > QGuiApplication::styleHints()->startDragDistance()) setKeepMouseGrab(true); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (d->composeMode()) { // start selection int startPos = d->positionAt(d->pressPos); @@ -1576,7 +1576,7 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event) d->selectPressed = false; setKeepMouseGrab(false); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) if (QGuiApplication::clipboard()->supportsSelection()) { if (event->button() == Qt::LeftButton) { d->copy(QClipboard::Selection); @@ -1596,7 +1596,7 @@ void QQuickTextInput::mouseReleaseEvent(QMouseEvent *event) bool QQuickTextInputPrivate::sendMouseEventToInputContext(QMouseEvent *event) { -#if !defined QT_NO_IM +#if QT_CONFIG(im) if (composeMode()) { int tmp_cursor = positionAt(event->localPos()); int mousePos = tmp_cursor - m_cursor; @@ -1623,7 +1623,7 @@ void QQuickTextInput::mouseUngrabEvent() bool QQuickTextInput::event(QEvent* ev) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) Q_D(QQuickTextInput); if (ev->type() == QEvent::ShortcutOverride) { if (d->m_readOnly) @@ -1723,7 +1723,7 @@ void QQuickTextInputPrivate::ensureVisible(int position, int preeditCursor, int // left hscroll = width - widthUsed; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditLength > 0) { // check to ensure long pre-edit text doesn't push the cursor // off to the left @@ -1740,7 +1740,7 @@ void QQuickTextInputPrivate::ensureVisible(int position, int preeditCursor, int void QQuickTextInputPrivate::updateHorizontalScroll() { if (autoScroll && m_echoMode != QQuickTextInput::NoEcho) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) const int preeditLength = m_textLayout.preeditAreaText().length(); ensureVisible(m_cursor, m_preeditCursor, preeditLength); #else @@ -1754,7 +1754,7 @@ void QQuickTextInputPrivate::updateHorizontalScroll() void QQuickTextInputPrivate::updateVerticalScroll() { Q_Q(QQuickTextInput); -#ifndef QT_NO_IM +#if QT_CONFIG(im) const int preeditLength = m_textLayout.preeditAreaText().length(); #endif const qreal height = qMax(0, q->height() - q->topPadding() - q->bottomPadding()); @@ -1766,7 +1766,7 @@ void QQuickTextInputPrivate::updateVerticalScroll() vscroll = -QQuickTextUtil::alignedY( heightUsed, height, vAlign & ~(Qt::AlignAbsolute|Qt::AlignHorizontal_Mask)); } else { -#ifndef QT_NO_IM +#if QT_CONFIG(im) QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength); #else QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor); @@ -1786,7 +1786,7 @@ void QQuickTextInputPrivate::updateVerticalScroll() // right vscroll = heightUsed - height; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditLength > 0) { // check to ensure long pre-edit text doesn't push the cursor // off the top @@ -1827,7 +1827,7 @@ void QQuickTextInput::ensureActiveFocus() { bool hadActiveFocus = hasActiveFocus(); forceActiveFocus(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) Q_D(QQuickTextInput); // re-open input panel on press if already focused if (hasActiveFocus() && hadActiveFocus && !d->m_readOnly) @@ -1877,7 +1877,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData } if (!d->m_textLayout.text().isEmpty() -#ifndef QT_NO_IM +#if QT_CONFIG(im) || !d->m_textLayout.preeditAreaText().isEmpty() #endif ) { @@ -1900,7 +1900,7 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData return node; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property) const { return inputMethodQuery(property, QVariant()); @@ -1957,7 +1957,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property, QVaria return QQuickItem::inputMethodQuery(property); } } -#endif // QT_NO_IM +#endif // im /*! \qmlmethod QtQuick::TextInput::deselect() @@ -1997,7 +1997,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end) } } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) /*! \qmlmethod QtQuick::TextInput::cut() @@ -2042,7 +2042,7 @@ void QQuickTextInput::paste() if (!d->m_readOnly) d->paste(); } -#endif // QT_NO_CLIPBOARD +#endif // clipboard /*! \qmlmethod QtQuick::TextInput::undo() @@ -2416,7 +2416,7 @@ void QQuickTextInput::setPersistentSelection(bool on) */ bool QQuickTextInput::canPaste() const { -#if !defined(QT_NO_CLIPBOARD) +#if QT_CONFIG(clipboard) Q_D(const QQuickTextInput); if (!d->canPasteValid) { if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData()) @@ -2597,7 +2597,7 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event) } if (focus) { q->q_updateAlignment(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (focusOnPress && !m_readOnly) qGuiApp->inputMethod()->show(); q->connect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), @@ -2617,7 +2617,7 @@ void QQuickTextInputPrivate::handleFocusEvent(QFocusEvent *event) if (hasAcceptableInput(m_text) == AcceptableInput || fixup()) emit q->editingFinished(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->disconnect(QGuiApplication::inputMethod(), SIGNAL(inputDirectionChanged(Qt::LayoutDirection)), q, SLOT(q_updateAlignment())); #endif @@ -2645,7 +2645,7 @@ void QQuickTextInput::focusOutEvent(QFocusEvent *event) */ bool QQuickTextInput::isInputMethodComposing() const { -#ifdef QT_NO_IM +#if !QT_CONFIG(im) return false; #else Q_D(const QQuickTextInput); @@ -2670,21 +2670,21 @@ QQuickTextInputPrivate::ExtraData::ExtraData() void QQuickTextInputPrivate::init() { Q_Q(QQuickTextInput); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) if (QGuiApplication::clipboard()->supportsSelection()) q->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton); else #endif q->setAcceptedMouseButtons(Qt::LeftButton); -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->setFlag(QQuickItem::ItemAcceptsInputMethod); #endif q->setFlag(QQuickItem::ItemHasContents); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) qmlobject_connect(QGuiApplication::clipboard(), QClipboard, SIGNAL(dataChanged()), q, QQuickTextInput, SLOT(q_canPasteChanged())); -#endif // QT_NO_CLIPBOARD +#endif // clipboard lastSelectionStart = 0; lastSelectionEnd = 0; @@ -2723,7 +2723,7 @@ void QQuickTextInput::updateCursorRectangle(bool scroll) d->cursorItem->setPosition(r.topLeft()); d->cursorItem->setHeight(r.height()); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle); #endif } @@ -2783,7 +2783,7 @@ void QQuickTextInput::q_canPasteChanged() { Q_D(QQuickTextInput); bool old = d->canPaste; -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) if (const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData()) d->canPaste = !d->m_readOnly && mimeData->hasText(); else @@ -2877,7 +2877,7 @@ qreal QQuickTextInputPrivate::getImplicitWidth() const option.setAlignment(Qt::Alignment(q->effectiveHAlign())); layout.setTextOption(option); layout.setFont(font); -#ifndef QT_NO_IM +#if QT_CONFIG(im) layout.setPreeditArea(m_textLayout.preeditAreaPosition(), m_textLayout.preeditAreaText()); #endif layout.beginLayout(); @@ -3054,7 +3054,7 @@ void QQuickTextInputPrivate::updateBaselineOffset() q->setBaselineOffset(fm.ascent() + yoff + q->topPadding()); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) /*! \internal @@ -3091,9 +3091,9 @@ void QQuickTextInputPrivate::paste(QClipboard::Mode clipboardMode) } } -#endif // !QT_NO_CLIPBOARD +#endif // clipboard -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! \internal */ @@ -3125,7 +3125,7 @@ void QQuickTextInputPrivate::cancelPreedit() QInputMethodEvent ev; QCoreApplication::sendEvent(q, &ev); } -#endif // QT_NO_IM +#endif // im /*! \internal @@ -3225,7 +3225,7 @@ void QQuickTextInputPrivate::clear() void QQuickTextInputPrivate::setSelection(int start, int length) { Q_Q(QQuickTextInput); -#ifndef QT_NO_IM +#if QT_CONFIG(im) commitPreedit(); #endif @@ -3257,7 +3257,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length) } emit q->selectionChanged(); emitCursorPositionChanged(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->updateInputMethod(Qt::ImCursorRectangle | Qt::ImAnchorRectangle | Qt::ImCursorPosition | Qt::ImAnchorPosition | Qt::ImCurrentSelection); #endif @@ -3287,7 +3287,7 @@ void QQuickTextInputPrivate::updatePasswordEchoEditing(bool editing) */ bool QQuickTextInputPrivate::fixup() // this function assumes that validate currently returns != Acceptable { -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) if (m_validator) { QString textCopy = m_text; int cursorCopy = m_cursor; @@ -3311,7 +3311,7 @@ bool QQuickTextInputPrivate::fixup() // this function assumes that validate curr void QQuickTextInputPrivate::moveCursor(int pos, bool mark) { Q_Q(QQuickTextInput); -#ifndef QT_NO_IM +#if QT_CONFIG(im) commitPreedit(); #endif @@ -3339,12 +3339,12 @@ void QQuickTextInputPrivate::moveCursor(int pos, bool mark) emit q->selectionChanged(); } emitCursorPositionChanged(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) q->updateInputMethod(); #endif } -#ifndef QT_NO_IM +#if QT_CONFIG(im) /*! \internal @@ -3461,7 +3461,7 @@ void QQuickTextInputPrivate::processInputMethodEvent(QInputMethodEvent *event) | Qt::ImCurrentSelection); } } -#endif // QT_NO_IM +#endif // im /*! \internal @@ -3501,7 +3501,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo Q_Q(QQuickTextInput); Q_UNUSED(update) -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool inputMethodAttributesChanged = m_textDirty || m_selDirty; #endif bool alignmentChanged = false; @@ -3513,7 +3513,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo bool wasAcceptable = m_acceptableInput; m_validInput = true; m_acceptableInput = true; -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) if (m_validator) { QString textCopy = m_text; int cursorCopy = m_cursor; @@ -3563,7 +3563,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo if (m_textDirty) { textChanged = true; m_textDirty = false; -#ifndef QT_NO_IM +#if QT_CONFIG(im) m_preeditDirty = false; #endif alignmentChanged = determineHorizontalAlignment(); @@ -3575,7 +3575,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo if (m_acceptableInput != wasAcceptable) emit q->acceptableInputChanged(); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (m_preeditDirty) { m_preeditDirty = false; if (determineHorizontalAlignment()) { @@ -3590,7 +3590,7 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo emit q->selectionChanged(); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) inputMethodAttributesChanged |= (m_cursor != m_lastCursorPos); if (inputMethodAttributesChanged) q->updateInputMethod(); @@ -3624,7 +3624,7 @@ void QQuickTextInputPrivate::internalSetText(const QString &txt, int pos, bool e m_textDirty = (oldText != m_text); bool changed = finishChange(-1, true, edited); -#ifdef QT_NO_ACCESSIBILITY +#if !QT_CONFIG(accessibility) Q_UNUSED(changed) #else Q_Q(QQuickTextInput); @@ -3969,7 +3969,7 @@ bool QQuickTextInputPrivate::isValidInput(QChar key, QChar mask) const */ QQuickTextInputPrivate::ValidatorState QQuickTextInputPrivate::hasAcceptableInput(const QString &str) const { -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) QString textCopy = str; int cursorCopy = m_cursor; if (m_validator) { @@ -4279,7 +4279,7 @@ bool QQuickTextInputPrivate::emitCursorPositionChanged() } } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (QAccessible::isActive()) { if (QObject *acc = QQuickAccessibleAttached::findAccessible(q, QAccessible::EditableText)) { QAccessibleTextCursorEvent ev(acc, m_cursor); @@ -4390,7 +4390,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) if (false) { } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) else if (event == QKeySequence::Undo) { q->undo(); } @@ -4400,7 +4400,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) else if (event == QKeySequence::SelectAll) { selectAll(); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) else if (event == QKeySequence::Copy) { copy(); } @@ -4417,7 +4417,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) if (!m_readOnly) deleteEndOfLine(); } -#endif //QT_NO_CLIPBOARD +#endif // clipboard else if (event == QKeySequence::MoveToStartOfLine || event == QKeySequence::MoveToStartOfBlock) { home(0); } @@ -4489,13 +4489,13 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) } else if (event == QKeySequence::DeleteCompleteLine) { if (!m_readOnly) { selectAll(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) copy(); #endif del(); } } -#endif // QT_NO_SHORTCUT +#endif // shortcut else { bool handled = false; if (event->modifiers() & Qt::ControlModifier) { diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index d0461f551e..f4545e1574 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -266,7 +266,7 @@ public: bool hasAcceptableInput() const; -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; Q_REVISION(3) Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const; #endif @@ -372,7 +372,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; void keyPressEvent(QKeyEvent* ev) Q_DECL_OVERRIDE; -#ifndef QT_NO_IM +#if QT_CONFIG(im) void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE; #endif void mouseUngrabEvent() Q_DECL_OVERRIDE; @@ -389,7 +389,7 @@ public Q_SLOTS: void select(int start, int end); void deselect(); bool isRightToLeft(int start, int end); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void cut(); void copy(); void paste(); @@ -409,7 +409,7 @@ private Q_SLOTS: void q_updateAlignment(); void triggerPreprocess(); -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) void q_validatorChanged(); #endif diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index 93a8778c40..d1aaefa6a7 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -104,7 +104,7 @@ public: , selectionColor(QRgb(0xFF000080)) , selectedTextColor(QRgb(0xFFFFFFFF)) , m_cursor(0) -#ifndef QT_NO_IM +#if QT_CONFIG(im) , m_preeditCursor(0) #endif , m_blinkEnabled(false) @@ -114,7 +114,7 @@ public: , m_undoState(0) , m_selstart(0) , m_selend(0) -#ifndef QT_NO_IM +#if QT_CONFIG(im) , inputMethodHints(Qt::ImhNone) #endif , hAlign(QQuickTextInput::AlignLeft) @@ -148,7 +148,7 @@ public: , m_separator(0) , m_readOnly(0) , m_textDirty(0) -#ifndef QT_NO_IM +#if QT_CONFIG(im) , m_preeditDirty(0) #endif , m_selDirty(0) @@ -176,7 +176,7 @@ public: bool setHAlign(QQuickTextInput::HAlignment, bool forceAlign = false); void mirrorChange() Q_DECL_OVERRIDE; bool sendMouseEventToInputContext(QMouseEvent *event); -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints effectiveInputMethodHints() const; #endif void handleFocusEvent(QFocusEvent *event); @@ -211,7 +211,7 @@ public: QPointF tripleClickStartPoint; QPointer cursorComponent; -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) QPointer m_validator; #endif @@ -240,7 +240,7 @@ public: int lastSelectionStart; int lastSelectionEnd; int m_cursor; -#ifndef QT_NO_IM +#if QT_CONFIG(im) int m_preeditCursor; #endif bool m_blinkEnabled; @@ -257,7 +257,7 @@ public: UpdatePaintNode }; -#ifndef QT_NO_IM +#if QT_CONFIG(im) Qt::InputMethodHints inputMethodHints; #endif QQuickTextInput::HAlignment hAlign; @@ -290,7 +290,7 @@ public: bool m_separator : 1; bool m_readOnly : 1; bool m_textDirty : 1; -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool m_preeditDirty : 1; #endif bool m_selDirty : 1; @@ -362,12 +362,12 @@ public: QString realText() const; -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copy(QClipboard::Mode mode = QClipboard::Clipboard) const; void paste(QClipboard::Mode mode = QClipboard::Clipboard); #endif -#ifndef QT_NO_IM +#if QT_CONFIG(im) void commitPreedit(); void cancelPreedit(); #endif @@ -419,7 +419,7 @@ public: } // input methods -#ifndef QT_NO_IM +#if QT_CONFIG(im) bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); } QString preeditAreaText() const { return m_textLayout.preeditAreaText(); } @@ -441,7 +441,7 @@ public: } } -#ifndef QT_NO_IM +#if QT_CONFIG(im) void processInputMethodEvent(QInputMethodEvent *event); #endif void processKeyEvent(QKeyEvent* ev); @@ -496,7 +496,7 @@ private: void deleteEndOfLine(); enum ValidatorState { -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) InvalidInput = QValidator::Invalid, IntermediateInput = QValidator::Intermediate, AcceptableInput = QValidator::Acceptable diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index e6ac9b603e..cf4e71adf5 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -237,7 +237,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay engine.setAnchorColor(anchorColor); engine.setPosition(position); -#ifndef QT_NO_IM +#if QT_CONFIG(im) int preeditLength = textLayout->preeditAreaText().length(); int preeditPosition = textLayout->preeditAreaPosition(); #endif @@ -256,7 +256,7 @@ void QQuickTextNode::addTextLayout(const QPointF &position, QTextLayout *textLay int length = line.textLength(); int end = start + length; -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditPosition >= 0 && preeditPosition >= start && preeditPosition < end) { diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 538356e679..c179ab7163 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -950,7 +950,7 @@ void QQuickTextNodeEngine::mergeFormats(QTextLayout *textLayout, QVarLengthArray void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QTextBlock &block, const QPointF &position, const QColor &textColor, const QColor &anchorColor, int selectionStart, int selectionEnd) { Q_ASSERT(textDocument); -#ifndef QT_NO_IM +#if QT_CONFIG(im) int preeditLength = block.isValid() ? block.layout()->preeditAreaText().length() : 0; int preeditPosition = block.isValid() ? block.layout()->preeditAreaPosition() : -1; #endif @@ -1070,7 +1070,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText setTextColor(textColor); int fragmentEnd = textPos + fragment.length(); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditPosition >= 0 && (preeditPosition + block.position()) >= textPos && (preeditPosition + block.position()) <= fragmentEnd) { @@ -1092,7 +1092,7 @@ void QQuickTextNodeEngine::addTextBlock(QTextDocument *textDocument, const QText ++blockIterator; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (preeditLength >= 0 && textPos <= block.position() + preeditPosition) { setPosition(blockPosition); textPos = block.position() + preeditPosition; diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 1297dded8c..ef079fdf92 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -74,7 +74,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #endif @@ -95,7 +95,7 @@ bool QQuickWindowPrivate::defaultAlphaBuffer = false; void QQuickWindowPrivate::updateFocusItemTransform() { -#ifndef QT_NO_IM +#if QT_CONFIG(im) Q_Q(QQuickWindow); QQuickItem *focus = q->activeFocusItem(); if (focus && QGuiApplication::focusObject() == focus) { @@ -172,7 +172,7 @@ private: #include "qquickwindow.moc" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) /*! Returns an accessibility interface for this window, or 0 if such an interface cannot be created. @@ -256,7 +256,7 @@ void QQuickWindow::focusInEvent(QFocusEvent *ev) d->updateFocusItemTransform(); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) static bool transformDirtyOnItemOrAncestor(const QQuickItem *item) { while (item) { @@ -297,7 +297,7 @@ void QQuickWindowPrivate::polishItems() if (recursionSafeguard == 0) qWarning("QQuickWindow: possible QQuickItem::polish() loop"); -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (QQuickItem *focusItem = q_func()->activeFocusItem()) { // If the current focus item, or any of its anchestors, has changed location // inside the window, we need inform IM about it. This to ensure that overlays @@ -471,10 +471,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size) QQuickWindowPrivate::QQuickWindowPrivate() : contentItem(0) , activeFocusItem(0) -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) , cursorItem(0) #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) , dragGrabber(0) #endif , touchMouseId(-1) @@ -500,7 +500,7 @@ QQuickWindowPrivate::QQuickWindowPrivate() , vaoHelper(0) , incubationController(0) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) dragGrabber = new QQuickDragGrabber; #endif } @@ -894,7 +894,7 @@ void QQuickWindowPrivate::setFocusInScope(QQuickItem *scope, QQuickItem *item, Q } if (oldActiveFocusItem) { -#ifndef QT_NO_IM +#if QT_CONFIG(im) QGuiApplication::inputMethod()->commit(); #endif @@ -1000,7 +1000,7 @@ void QQuickWindowPrivate::clearFocusInScope(QQuickItem *scope, QQuickItem *item, oldActiveFocusItem = activeFocusItem; newActiveFocusItem = scope; -#ifndef QT_NO_IM +#if QT_CONFIG(im) QGuiApplication::inputMethod()->commit(); #endif @@ -1276,7 +1276,7 @@ QQuickWindow::~QQuickWindow() } delete d->incubationController; d->incubationController = 0; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) delete d->dragGrabber; d->dragGrabber = 0; #endif delete d->contentItem; d->contentItem = 0; @@ -1545,7 +1545,7 @@ bool QQuickWindow::event(QEvent *e) d->clearHover(); d->lastMousePosition = QPointF(); break; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: case QEvent::DragLeave: case QEvent::DragMove: @@ -1565,7 +1565,7 @@ bool QQuickWindow::event(QEvent *e) e->setAccepted(qev.isAccepted()); } break; case QEvent::FocusAboutToChange: -#ifndef QT_NO_IM +#if QT_CONFIG(im) if (d->activeFocusItem) qGuiApp->inputMethod()->commit(); #endif @@ -1577,7 +1577,7 @@ bool QQuickWindow::event(QEvent *e) d->windowManager->handleUpdateRequest(this); break; } -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) case QEvent::NativeGesture: d->deliverNativeGestureEvent(d->contentItem, static_cast(e)); break; @@ -1774,7 +1774,7 @@ bool QQuickWindowPrivate::deliverHoverEvent(QQuickItem *item, const QPointF &sce return false; } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event) { QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); @@ -1828,9 +1828,9 @@ void QQuickWindow::wheelEvent(QWheelEvent *event) d->deliverWheelEvent(d->contentItem, event); d->lastWheelEventAccepted = event->isAccepted(); } -#endif // QT_NO_WHEELEVENT +#endif // wheelevent -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) bool QQuickWindowPrivate::deliverNativeGestureEvent(QQuickItem *item, QNativeGestureEvent *event) { QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); @@ -1862,7 +1862,7 @@ bool QQuickWindowPrivate::deliverNativeGestureEvent(QQuickItem *item, QNativeGes return false; } -#endif // QT_NO_GESTURES +#endif // gestures bool QQuickWindowPrivate::deliverTouchCancelEvent(QTouchEvent *event) { @@ -2043,7 +2043,7 @@ void QQuickWindowPrivate::handleMouseEvent(QMouseEvent *event) qCDebug(DBG_HOVER_TRACE) << this; - #ifndef QT_NO_CURSOR + #if QT_CONFIG(cursor) updateCursor(event->windowPos()); #endif @@ -2358,7 +2358,7 @@ bool QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem *item, QQuickPo return eventAccepted; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QEvent *event) { grabber->resetTarget(); @@ -2479,9 +2479,9 @@ bool QQuickWindowPrivate::deliverDragEvent(QQuickDragGrabber *grabber, QQuickIte return accepted; } -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void QQuickWindowPrivate::updateCursor(const QPointF &scenePos) { Q_Q(QQuickWindow); @@ -3184,7 +3184,7 @@ void QQuickWindow::maybeUpdate() void QQuickWindow::cleanupSceneGraph() { Q_D(QQuickWindow); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) delete d->vaoHelper; d->vaoHelper = 0; #endif @@ -3223,7 +3223,7 @@ void QQuickWindow::setTransientParent_helper(QQuickWindow *window) QOpenGLContext *QQuickWindow::openglContext() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_D(const QQuickWindow); if (d->context && d->context->isValid()) { QSGRendererInterface *rif = d->context->sceneGraphContext()->rendererInterface(d->context); @@ -3351,7 +3351,7 @@ bool QQuickWindow::isSceneGraphInitialized() const The corresponding handler is \c onClosing. */ -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! Sets the render target for this window to be \a fbo. @@ -3439,7 +3439,7 @@ QSize QQuickWindow::renderTargetSize() const -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! Returns the render target for this window. @@ -3478,7 +3478,7 @@ QImage QQuickWindow::grabWindow() return d->windowManager->grab(this); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!isVisible() && !d->renderControl) { auto openglRenderContext = static_cast(d->context); if (!openglRenderContext->openglContext()) { @@ -3836,7 +3836,7 @@ QSGTexture *QQuickWindow::createTextureFromImage(const QImage &image, CreateText */ QSGTexture *QQuickWindow::createTextureFromId(uint id, const QSize &size, CreateTextureOptions options) const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (openglContext()) { QSGPlainTexture *texture = new QSGPlainTexture(); texture->setTextureId(id); @@ -3919,7 +3919,7 @@ void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha) { QQuickWindowPrivate::defaultAlphaBuffer = useAlpha; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! \since 5.2 diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index cfadadec2d..c1f690f325 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -114,19 +114,19 @@ public: bool sendEvent(QQuickItem *, QEvent *); QImage grabWindow(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void setRenderTarget(QOpenGLFramebufferObject *fbo); QOpenGLFramebufferObject *renderTarget() const; #endif void setRenderTarget(uint fboId, const QSize &size); uint renderTargetId() const; QSize renderTargetSize() const; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void resetOpenGLState(); #endif QQmlIncubationController *incubationController() const; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleInterface *accessibleRoot() const Q_DECL_OVERRIDE; #endif @@ -208,7 +208,7 @@ protected: void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE; #endif diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 3328eb65c4..32a6939868 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -125,10 +125,10 @@ public: void deliverKeyEvent(QKeyEvent *e); // Keeps track of the item currently receiving mouse events -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) QQuickItem *cursorItem; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QQuickDragGrabber *dragGrabber; #endif int touchMouseId; @@ -146,10 +146,10 @@ public: static QMouseEvent *cloneMouseEvent(QMouseEvent *event, QPointF *transformedLocalPos = 0); void deliverMouseEvent(QQuickPointerMouseEvent *pointerEvent); bool sendFilteredMouseEvent(QQuickItem *, QQuickItem *, QEvent *, QSet *); -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) bool deliverWheelEvent(QQuickItem *, QWheelEvent *); #endif -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) bool deliverNativeGestureEvent(QQuickItem *, QNativeGestureEvent *); #endif @@ -179,11 +179,11 @@ public: Qt::KeyboardModifiers modifiers, ulong timestamp, bool accepted); bool clearHover(ulong timestamp = 0); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void deliverDragEvent(QQuickDragGrabber *, QEvent *); bool deliverDragEvent(QQuickDragGrabber *, QQuickItem *, QDragMoveEvent *); #endif -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void updateCursor(const QPointF &scenePos); QQuickItem *findCursorItem(QQuickItem *item, const QPointF &scenePos); #endif diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp index 9a50250ebb..1f9305ccba 100644 --- a/src/quick/qtquick2.cpp +++ b/src/quick/qtquick2.cpp @@ -196,7 +196,7 @@ void QQmlQtQuick2Module::defineModule() QQuickValueTypes::registerValueTypes(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessible::installFactory(&qQuickAccessibleFactory); #endif diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp index b43a2bc2ba..a278c6079b 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.cpp +++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp @@ -39,7 +39,7 @@ #include "qsggeometry.h" #include "qsggeometry_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include # include @@ -441,7 +441,7 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, Q_UNUSED(m_reserved_bits); Q_ASSERT(m_attributes.count > 0); Q_ASSERT(m_attributes.stride > 0); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_ASSERT_X(indexType != GL_UNSIGNED_INT || static_cast(QOpenGLContext::currentContext()->functions()) ->hasOpenGLExtension(QOpenGLExtensions::ElementIndexUint), diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp index 13598bbe1d..d2d27cd9aa 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp @@ -40,7 +40,7 @@ #include "qsgmaterial.h" #include "qsgrenderer_p.h" #include "qsgmaterialshader_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include # include @@ -64,7 +64,7 @@ void qsg_set_material_failure() qsg_material_failure = true; } #endif -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) const char *QSGMaterialShaderPrivate::loadShaderSource(QOpenGLShader::ShaderType type) const { const QStringList files = m_sourceFiles[type]; @@ -227,7 +227,7 @@ QSGMaterialShader::~QSGMaterialShader() defines the attribute register position in the vertex shader. */ -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! \fn const char *QSGMaterialShader::vertexShader() const @@ -320,7 +320,7 @@ void QSGMaterialShader::updateState(const RenderState & /* state */, QSGMaterial { } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! Sets the GLSL source file for the shader stage \a type to \a sourceFile. The default implementation of the vertexShader() and fragmentShader() functions @@ -550,7 +550,7 @@ QRect QSGMaterialShader::RenderState::deviceRect() const return static_cast(m_data)->deviceRect(); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! Returns the QOpenGLContext that is being used for rendering diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h index 114651653f..c002cd5d5e 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterial.h +++ b/src/quick/scenegraph/coreapi/qsgmaterial.h @@ -41,7 +41,7 @@ #define QSGMATERIAL_H #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif #include @@ -84,7 +84,7 @@ public: QRect deviceRect() const; float determinant() const; float devicePixelRatio() const; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext *context() const; #endif private: @@ -101,7 +101,7 @@ public: // First time a material is used, oldMaterial is null. virtual void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); virtual char const *const *attributeNames() const = 0; // Array must end with null. -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) inline QOpenGLShaderProgram *program() { return &m_program; } #endif protected: @@ -110,19 +110,19 @@ protected: friend class QSGDefaultRenderContext; friend class QSGBatchRenderer::ShaderManager; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void setShaderSourceFile(QOpenGLShader::ShaderType type, const QString &sourceFile); void setShaderSourceFiles(QOpenGLShader::ShaderType type, const QStringList &sourceFiles); virtual void compile(); #endif virtual void initialize() { } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) virtual const char *vertexShader() const; virtual const char *fragmentShader() const; #endif private: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLShaderProgram m_program; #endif QScopedPointer d_ptr; diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h index 0dbce010db..47f5e5de09 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h +++ b/src/quick/scenegraph/coreapi/qsgmaterialshader_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class Q_QUICK_PRIVATE_EXPORT QSGMaterialShaderPrivate { public: -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) const char *loadShaderSource(QOpenGLShader::ShaderType type) const; QHash m_sourceFiles; diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 34cdfc0a6d..e5d464930c 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -39,7 +39,7 @@ #include "qsgrenderer_p.h" #include "qsgnodeupdater_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include # include @@ -67,7 +67,7 @@ int qt_sg_envInt(const char *name, int defaultValue) void QSGBindable::clear(QSGAbstractRenderer::ClearMode mode) const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) GLuint bits = 0; if (mode & QSGAbstractRenderer::ClearColorBuffer) bits |= GL_COLOR_BUFFER_BIT; if (mode & QSGAbstractRenderer::ClearDepthBuffer) bits |= GL_DEPTH_BUFFER_BIT; @@ -81,11 +81,11 @@ void QSGBindable::clear(QSGAbstractRenderer::ClearMode mode) const // Reactivate the color buffer after switching to the stencil. void QSGBindable::reactivate() const { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext::currentContext()->functions()->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); #endif } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QSGBindableFboId::QSGBindableFboId(GLuint id) : m_id(id) { @@ -181,7 +181,7 @@ bool QSGRenderer::isMirrored() const void QSGRenderer::renderScene(uint fboId) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (fboId) { QSGBindableFboId bindable(fboId); renderScene(bindable); @@ -223,7 +223,7 @@ void QSGRenderer::renderScene(const QSGBindable &bindable) Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRendererFrame, QQuickProfiler::SceneGraphRendererBinding); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Sanity check that attribute registers are disabled if (qsg_sanity_check) { GLint count = 0; diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h index 94b78a85b4..26e29d414d 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h @@ -133,7 +133,7 @@ public: virtual void clear(QSGAbstractRenderer::ClearMode mode) const; virtual void reactivate() const; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class QSGBindableFboId : public QSGBindable { public: diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 84ca09285a..412023564f 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -73,7 +73,7 @@ QSGDistanceFieldGlyphCache::QSGDistanceFieldGlyphCache(QSGDistanceFieldGlyphCach // this allows us to call pathForGlyph once and reuse the result. m_referenceFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(m_doubleGlyphResolution) * QT_DISTANCEFIELD_SCALE(m_doubleGlyphResolution)); Q_ASSERT(m_referenceFont.isValid()); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_coreProfile = (c->format().profile() == QSurfaceFormat::CoreProfile); #else Q_UNUSED(c) diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 7fab9aeae8..635308c38a 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -45,7 +45,7 @@ // Built-in adaptations #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #endif @@ -62,7 +62,7 @@ QSGContextPlugin::~QSGContextPlugin() { } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QSGContextFactoryInterface_iid, QLatin1String("/scenegraph"))) #endif @@ -128,7 +128,7 @@ QSGAdaptationBackendData *contextFactory() if (requestedBackend.isEmpty() && qEnvironmentVariableIsSet("QT_QUICK_BACKEND")) requestedBackend = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND")); -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) // If this is a build without OpenGL, and no backend has been set // default to the software renderer if (requestedBackend.isEmpty()) @@ -148,7 +148,7 @@ QSGAdaptationBackendData *contextFactory() } } -#ifndef QT_NO_LIBRARY +#if QT_CONFIG(library) // Then try the plugins. if (!backendData->factory) { const int index = loader()->indexOf(requestedBackend); @@ -165,7 +165,7 @@ QSGAdaptationBackendData *contextFactory() qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath))); } } -#endif // QT_NO_LIBRARY +#endif // library } } @@ -185,7 +185,7 @@ QSGContext *QSGContext::createDefaultContext() QSGAdaptationBackendData *backendData = contextFactory(); if (backendData->factory) return backendData->factory->create(backendData->name); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) return new QSGDefaultContext(); #else return nullptr; diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 5bd1adc1f7..ec874f6ff0 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -58,7 +58,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #if QT_CONFIG(quick_shadereffect) @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE extern bool qsg_useConsistentTiming(); extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) /*! expectations for this manager to work: - one opengl context to render multiple windows @@ -119,7 +119,7 @@ void QSGRenderLoop::cleanup() void QSGRenderLoop::postJob(QQuickWindow *window, QRunnable *job) { Q_ASSERT(job); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_ASSERT(window); if (window->openglContext()) { window->openglContext()->makeCurrent(window); @@ -131,7 +131,7 @@ void QSGRenderLoop::postJob(QQuickWindow *window, QRunnable *job) #endif delete job; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class QSGGuiThreadRenderLoop : public QSGRenderLoop { Q_OBJECT @@ -182,7 +182,7 @@ QSGRenderLoop *QSGRenderLoop::instance() const_cast(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true); s_instance = QSGContext::createWindowManager(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!s_instance) { enum RenderLoopType { @@ -272,7 +272,7 @@ void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window, if (!signalEmitted) qFatal("%s", qPrintable(untranslatedMessage)); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QSGGuiThreadRenderLoop::QSGGuiThreadRenderLoop() : gl(0) { diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp index 79e43e3820..9ca9cdb107 100644 --- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp +++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp @@ -40,7 +40,7 @@ #include "qsgdistancefieldutil_p.h" #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif #include diff --git a/src/quick/scenegraph/util/qsgengine.cpp b/src/quick/scenegraph/util/qsgengine.cpp index ad1fcfa470..09e4cdf5a7 100644 --- a/src/quick/scenegraph/util/qsgengine.cpp +++ b/src/quick/scenegraph/util/qsgengine.cpp @@ -44,7 +44,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #endif @@ -116,7 +116,7 @@ QSGEngine::~QSGEngine() void QSGEngine::initialize(QOpenGLContext *context) { Q_D(QSGEngine); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (context && QOpenGLContext::currentContext() != context) { qWarning("WARNING: The context must be current before calling QSGEngine::initialize."); return; @@ -125,7 +125,7 @@ void QSGEngine::initialize(QOpenGLContext *context) if (d->sgRenderContext && !d->sgRenderContext->isValid()) { d->sgRenderContext->setAttachToGraphicsContext(false); d->sgRenderContext->initialize(context); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (context) connect(context, &QOpenGLContext::aboutToBeDestroyed, this, &QSGEngine::invalidate); #endif diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp index 2ce27275cd..8ab7669891 100644 --- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp @@ -39,7 +39,7 @@ #include "qsgflatcolormaterial.h" #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif @@ -57,7 +57,7 @@ public: private: virtual void initialize(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) int m_matrix_id; int m_color_id; #endif @@ -68,7 +68,7 @@ QSGMaterialType FlatColorMaterialShader::type; FlatColorMaterialShader::FlatColorMaterialShader() : QSGMaterialShader(*new QSGMaterialShaderPrivate) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/flatcolor.frag")); #endif @@ -76,7 +76,7 @@ FlatColorMaterialShader::FlatColorMaterialShader() void FlatColorMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type()); QSGFlatColorMaterial *oldMaterial = static_cast(oldEffect); QSGFlatColorMaterial *newMaterial = static_cast(newEffect); @@ -109,7 +109,7 @@ char const *const *FlatColorMaterialShader::attributeNames() const void FlatColorMaterialShader::initialize() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_matrix_id = program()->uniformLocation("matrix"); m_color_id = program()->uniformLocation("color"); #endif diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h index d07a68e850..8f42599832 100644 --- a/src/quick/scenegraph/util/qsgsimplematerial.h +++ b/src/quick/scenegraph/util/qsgsimplematerial.h @@ -50,7 +50,7 @@ class QSGSimpleMaterialShader : public QSGMaterialShader public: void initialize() { QSGMaterialShader::initialize(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_id_matrix = program()->uniformLocation(uniformMatrixName()); if (m_id_matrix < 0) { qFatal("QSGSimpleMaterialShader does not implement 'uniform highp mat4 %s;' in its vertex shader", @@ -197,7 +197,7 @@ QSGMaterialType QSGSimpleMaterial::m_type; template Q_INLINE_TEMPLATE void QSGSimpleMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (state.isMatrixDirty()) program()->setUniformValue(m_id_matrix, state.combinedMatrix()); if (state.isOpacityDirty() && m_id_opacity >= 0) diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 436f97b1ff..47248f2f37 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -45,7 +45,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include # include @@ -70,7 +70,7 @@ #include #endif -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) static QElapsedTimer qsg_renderer_timer; #endif @@ -86,7 +86,7 @@ static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK" QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 @@ -284,7 +284,7 @@ Q_GLOBAL_STATIC(QMutex, qsg_valid_texture_mutex) bool qsg_safeguard_texture(QSGTexture *texture) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QMutexLocker locker(qsg_valid_texture_mutex()); if (!qsg_valid_texture_set()->contains(texture)) { qWarning() << "Invalid texture accessed:" << (void *) texture; @@ -527,7 +527,7 @@ QSGTexture::WrapMode QSGTexture::verticalWrapMode() const */ void QSGTexture::updateBindOptions(bool force) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_D(QSGTexture); QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); force |= isAtlasTexture(); @@ -582,7 +582,7 @@ QSGPlainTexture::QSGPlainTexture() QSGPlainTexture::~QSGPlainTexture() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_texture_id && m_owns_texture && QOpenGLContext::currentContext()) QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id); #endif @@ -617,7 +617,7 @@ int QSGPlainTexture::textureId() const // or ~QSGPlainTexture so just keep it minimal here. return 0; } else if (m_texture_id == 0){ -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Generate a texture id for use later and return it. QOpenGLContext::currentContext()->functions()->glGenTextures(1, &const_cast(this)->m_texture_id); #endif @@ -629,7 +629,7 @@ int QSGPlainTexture::textureId() const void QSGPlainTexture::setTextureId(int id) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (m_texture_id && m_owns_texture) QOpenGLContext::currentContext()->functions()->glDeleteTextures(1, &m_texture_id); #endif @@ -643,7 +643,7 @@ void QSGPlainTexture::setTextureId(int id) void QSGPlainTexture::bind() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLFunctions *funcs = context->functions(); if (!m_dirty_texture) { diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h index a0d7eb41e3..13c862eb88 100644 --- a/src/quick/scenegraph/util/qsgtexture_p.h +++ b/src/quick/scenegraph/util/qsgtexture_p.h @@ -53,7 +53,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif #include "qsgtexture.h" diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index 119828bc81..9326ea640d 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -39,14 +39,14 @@ #include "qsgtexturematerial_p.h" #include "qsgtexture_p.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include # include #endif QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) inline static bool isPowerOfTwo(int x) { // Assumption: x >= 1 @@ -59,7 +59,7 @@ QSGMaterialType QSGOpaqueTextureMaterialShader::type; QSGOpaqueTextureMaterialShader::QSGOpaqueTextureMaterialShader() : QSGMaterialShader() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/opaquetexture.frag")); #endif @@ -73,7 +73,7 @@ char const *const *QSGOpaqueTextureMaterialShader::attributeNames() const void QSGOpaqueTextureMaterialShader::initialize() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_matrix_id = program()->uniformLocation("qt_Matrix"); #endif } @@ -95,7 +95,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa t->setHorizontalWrapMode(tx->horizontalWrapMode()); t->setVerticalWrapMode(tx->verticalWrapMode()); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) bool npotSupported = const_cast(state.context()) ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat); if (!npotSupported) { @@ -115,7 +115,7 @@ void QSGOpaqueTextureMaterialShader::updateState(const RenderState &state, QSGMa t->bind(); else t->updateBindOptions(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (state.isMatrixDirty()) program()->setUniformValue(m_matrix_id, state.combinedMatrix()); #endif @@ -379,7 +379,7 @@ QSGMaterialShader *QSGTextureMaterial::createShader() const QSGTextureMaterialShader::QSGTextureMaterialShader() : QSGOpaqueTextureMaterialShader() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/texture.frag")); #endif } @@ -387,7 +387,7 @@ QSGTextureMaterialShader::QSGTextureMaterialShader() void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) { Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type()); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (state.isOpacityDirty()) program()->setUniformValue(m_opacity_id, state.opacity()); #endif @@ -397,7 +397,7 @@ void QSGTextureMaterialShader::updateState(const RenderState &state, QSGMaterial void QSGTextureMaterialShader::initialize() { QSGOpaqueTextureMaterialShader::initialize(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_opacity_id = program()->uniformLocation("opacity"); #endif } diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp index 847ec289d8..8c305d7fd4 100644 --- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qsgvertexcolormaterial.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) # include #endif QT_BEGIN_NAMESPACE @@ -55,7 +55,7 @@ public: private: virtual void initialize(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) int m_matrix_id; int m_opacity_id; #endif @@ -66,7 +66,7 @@ QSGMaterialType QSGVertexColorMaterialShader::type; QSGVertexColorMaterialShader::QSGVertexColorMaterialShader() : QSGMaterialShader() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qt-project.org/scenegraph/shaders/vertexcolor.frag")); #endif @@ -74,7 +74,7 @@ QSGVertexColorMaterialShader::QSGVertexColorMaterialShader() void QSGVertexColorMaterialShader::updateState(const RenderState &state, QSGMaterial * /*newEffect*/, QSGMaterial *) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (state.isOpacityDirty()) program()->setUniformValue(m_opacity_id, state.opacity()); @@ -93,7 +93,7 @@ char const *const *QSGVertexColorMaterialShader::attributeNames() const void QSGVertexColorMaterialShader::initialize() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) m_matrix_id = program()->uniformLocation("matrix"); m_opacity_id = program()->uniformLocation("opacity"); #endif diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 64e849d322..e891ebab72 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -277,7 +277,7 @@ public: private: QSGOpacityNode *m_opacityNode; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob { public: diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 7692cc79f9..5a723e4432 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -783,7 +783,7 @@ public: return new QQuickApplication(parent); } -#ifndef QT_NO_IM +#if QT_CONFIG(im) QInputMethod *inputMethod() { QInputMethod *im = qGuiApp->inputMethod(); diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp index 7e2973a78b..c1bc3d60b8 100644 --- a/src/quick/util/qquickutilmodule.cpp +++ b/src/quick/util/qquickutilmodule.cpp @@ -67,7 +67,7 @@ Q_DECLARE_METATYPE(QKeySequence::StandardKey) void QQuickUtilModule::defineModule() { -#ifndef QT_NO_IM +#if QT_CONFIG(im) qmlRegisterUncreatableType("QtQuick",2,0,"InputMethod", QInputMethod::tr("InputMethod is an abstract class")); #endif @@ -94,7 +94,7 @@ void QQuickUtilModule::defineModule() qmlRegisterType("QtQuick",2,0,"Transition"); qmlRegisterType("QtQuick",2,0,"Vector3dAnimation"); -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) qmlRegisterType(); qmlRegisterType("QtQuick",2,0,"IntValidator"); qmlRegisterType("QtQuick",2,0,"DoubleValidator"); diff --git a/src/quick/util/qquickvalidator.cpp b/src/quick/util/qquickvalidator.cpp index 67cb6a6c05..015a376603 100644 --- a/src/quick/util/qquickvalidator.cpp +++ b/src/quick/util/qquickvalidator.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) /*! \qmltype IntValidator @@ -221,7 +221,7 @@ void QQuickDoubleValidator::resetLocaleName() By default, this property contains a regular expression with the pattern .* that matches any string. */ -#endif // QT_NO_VALIDATOR +#endif // validator QT_END_NAMESPACE diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h index 97adfb742a..ba188e947a 100644 --- a/src/quick/util/qquickvalidator_p.h +++ b/src/quick/util/qquickvalidator_p.h @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator { Q_OBJECT @@ -90,7 +90,7 @@ Q_SIGNALS: QT_END_NAMESPACE -#ifndef QT_NO_VALIDATOR +#if QT_CONFIG(validator) QML_DECLARE_TYPE(QValidator) QML_DECLARE_TYPE(QQuickIntValidator) QML_DECLARE_TYPE(QQuickDoubleValidator) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 1d617f5098..ed7f7a0ca6 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -59,7 +59,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include @@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); #endif @@ -108,7 +108,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e) useSoftwareRenderer = true; if (!useSoftwareRenderer) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)) setRenderToTexture(); else @@ -121,7 +121,7 @@ void QQuickWidgetPrivate::init(QQmlEngine* e) if (!engine.isNull() && !engine.data()->incubationController()) engine.data()->setIncubationController(offscreenWindow->incubationController()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) q->setAcceptDrops(true); #endif @@ -143,7 +143,7 @@ void QQuickWidgetPrivate::ensureEngine() const void QQuickWidgetPrivate::invalidateRenderControl() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!useSoftwareRenderer) { if (!context) // this is not an error, could be called before creating the context, or multiple times return; @@ -183,7 +183,7 @@ QQuickWidgetPrivate::QQuickWidgetPrivate() , offscreenWindow(0) , offscreenSurface(0) , renderControl(0) -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) , fbo(0) , resolvedFbo(0) , context(0) @@ -206,7 +206,7 @@ QQuickWidgetPrivate::~QQuickWidgetPrivate() delete renderControl; delete offscreenWindow; } else { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // context and offscreenSurface are current at this stage, if the context was created. Q_ASSERT(!context || (QOpenGLContext::currentContext() == context && context->surface() == offscreenSurface)); delete renderControl; // always delete the rendercontrol first @@ -258,7 +258,7 @@ void QQuickWidgetPrivate::itemGeometryChanged(QQuickItem *resizeItem, QQuickGeom void QQuickWidgetPrivate::render(bool needsSync) { if (!useSoftwareRenderer) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // createFramebufferObject() bails out when the size is empty. In this case // we cannot render either. if (!fbo) @@ -327,7 +327,7 @@ void QQuickWidgetPrivate::renderSceneGraph() render(true); -#ifndef QT_NO_GRAPHICSVIEW +#if QT_CONFIG(graphicsview) if (q->window()->graphicsProxyWidget()) QWidgetPrivate::nearestGraphicsProxyWidget(q)->update(); else @@ -343,7 +343,7 @@ void QQuickWidgetPrivate::renderSceneGraph() QImage QQuickWidgetPrivate::grabFramebuffer() { if (!useSoftwareRenderer) { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (!context) return QImage(); @@ -835,7 +835,7 @@ void QQuickWidgetPrivate::handleContextCreationFailure(const QSurfaceFormat &for // Never called by Software Rendering backend void QQuickWidgetPrivate::createContext() { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_Q(QQuickWidget); // On hide-show we may invalidate() (when !isPersistentSceneGraph) but our @@ -886,7 +886,7 @@ void QQuickWidgetPrivate::destroyContext() { delete offscreenSurface; offscreenSurface = 0; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) delete context; context = 0; #endif @@ -914,7 +914,7 @@ void QQuickWidget::createFramebufferObject() return; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext *context = d->offscreenWindow->openglContext(); if (!context) { @@ -995,7 +995,7 @@ void QQuickWidget::destroyFramebufferObject() return; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) delete d->fbo; d->fbo = 0; delete d->resolvedFbo; @@ -1078,7 +1078,7 @@ void QQuickWidgetPrivate::setRootObject(QObject *obj) } } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) GLuint QQuickWidgetPrivate::textureId() const { Q_Q(const QQuickWidget); @@ -1180,7 +1180,7 @@ void QQuickWidget::resizeEvent(QResizeEvent *e) createFramebufferObject(); } } else { -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (d->context) { // Bail out when receiving a resize after scenegraph invalidation. This can happen // during hide - resize - show sequences and also during application exit. @@ -1335,7 +1335,7 @@ void QQuickWidget::mouseReleaseEvent(QMouseEvent *e) e->setAccepted(mappedEvent.isAccepted()); } -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) /*! \reimp */ void QQuickWidget::wheelEvent(QWheelEvent *e) { @@ -1408,14 +1408,14 @@ bool QQuickWidget::event(QEvent *e) d->offscreenWindow->setScreen(newScreen); if (d->offscreenSurface) d->offscreenSurface->setScreen(newScreen); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (d->context) d->context->setScreen(newScreen); #endif } if (d->useSoftwareRenderer -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) || d->fbo #endif ) { @@ -1442,7 +1442,7 @@ bool QQuickWidget::event(QEvent *e) return QWidget::event(e); } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QQuickWidget::dragEnterEvent(QDragEnterEvent *e) @@ -1477,7 +1477,7 @@ void QQuickWidget::dropEvent(QDropEvent *e) d->offscreenWindow->event(e); } -#endif // QT_NO_DRAGANDDROP +#endif // draganddrop // TODO: try to separate the two cases of // 1. render() unconditionally without sync diff --git a/src/quickwidgets/qquickwidget.h b/src/quickwidgets/qquickwidget.h index 56e6b01ac5..2d159778ed 100644 --- a/src/quickwidgets/qquickwidget.h +++ b/src/quickwidgets/qquickwidget.h @@ -131,11 +131,11 @@ protected: void focusInEvent(QFocusEvent * event) override; void focusOutEvent(QFocusEvent * event) override; -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) void wheelEvent(QWheelEvent *) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *) override; void dragMoveEvent(QDragMoveEvent *) override; void dragLeaveEvent(QDragLeaveEvent *) override; diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 0ba86172e6..559321cd51 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -101,7 +101,7 @@ public: QObject *focusObject() Q_DECL_OVERRIDE; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) GLuint textureId() const Q_DECL_OVERRIDE; QImage grabFramebuffer() Q_DECL_OVERRIDE; #else @@ -126,7 +126,7 @@ public: QOffscreenSurface *offscreenSurface; QQuickRenderControl *renderControl; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLFramebufferObject *fbo; QOpenGLFramebufferObject *resolvedFbo; QOpenGLContext *context; diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index c4b17aa60a..692e70d7da 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -618,7 +618,7 @@ void tst_QQmlProfilerService::scenegraphData() // if the clocks are acting up. qint64 contextFrameTime = -1; qint64 renderFrameTime = -1; -#ifndef QT_NO_OPENGL //Software renderer doesn't have context frames +#if QT_CONFIG(opengl) //Software renderer doesn't have context frames foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.messageType == QQmlProfilerDefinitions::SceneGraphFrame) { if (msg.detailType == QQmlProfilerDefinitions::SceneGraphContextFrame) { diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp index a401e04020..98b92e5fab 100644 --- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp +++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp @@ -96,7 +96,7 @@ void tst_qqmlapplicationengine::application() Note that checking the output means that on builds with extra debugging, this might fail with a false positive. Also the testapp is automatically built and installed in shadow builds, so it does NOT use testData */ -#ifndef QT_NO_PROCESS +#if QT_CONFIG(process) QDir::setCurrent(buildDir); QProcess *testProcess = new QProcess(this); QStringList args; @@ -114,9 +114,9 @@ void tst_qqmlapplicationengine::application() QVERIFY(QString(test_stderr).endsWith(QString(test_stderr_target))); delete testProcess; QDir::setCurrent(srcDir); -#else // !QT_NO_PROCESS +#else // process QSKIP("No process support"); -#endif // QT_NO_PROCESS +#endif // process } void tst_qqmlapplicationengine::applicationProperties() diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 9e915ac451..163ce11cb8 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -323,7 +323,7 @@ void tst_qqmlvaluetypes::locale() QScopedPointer object(component.create()); QVERIFY(!object.isNull()); -#ifndef QT_NO_IM +#if QT_CONFIG(im) QVERIFY(QQml_guiProvider()->inputMethod()); QInputMethod *inputMethod = qobject_cast(QQml_guiProvider()->inputMethod()); QLocale locale = inputMethod->locale(); @@ -350,7 +350,7 @@ void tst_qqmlvaluetypes::locale() } QCOMPARE(weekDays, locale.weekdays()); QCOMPARE(object->property("zeroDigit").toString().at(0), locale.zeroDigit()); -#endif // QT_NO_IM +#endif // im } } diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index 872a71011d..1ca809c05f 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -103,7 +103,7 @@ tst_examples::tst_examples() excludedFiles << "views/visualdatamodel/slideshow.qml"; #endif -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) //No support for Particles excludedFiles << "examples/qml/dynamicscene/dynamicscene.qml"; excludedFiles << "examples/quick/animation/basics/color-animation.qml"; diff --git a/tests/auto/quick/nokeywords/tst_nokeywords.cpp b/tests/auto/quick/nokeywords/tst_nokeywords.cpp index 6c94b484ae..ad77743ddd 100644 --- a/tests/auto/quick/nokeywords/tst_nokeywords.cpp +++ b/tests/auto/quick/nokeywords/tst_nokeywords.cpp @@ -48,7 +48,7 @@ #include #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index 5d242fab9e..71b0160c8e 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -76,7 +76,7 @@ private slots: void statusChanges_data(); void sourceSizeChanges(); void progressAndStatusChanges(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void borderImageMesh(); #endif @@ -583,7 +583,7 @@ void tst_qquickborderimage::progressAndStatusChanges() delete obj; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickborderimage::borderImageMesh() { QQuickView *window = new QQuickView; diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index b774481592..942e99018f 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -1225,7 +1225,7 @@ void tst_qquickflickable::flickOnRelease() QTRY_VERIFY(!flickable->isMoving()); #ifdef Q_OS_MAC -# ifndef QT_NO_OPENGL +# if QT_CONFIG(opengl) QEXPECT_FAIL("", "QTBUG-26094 stopping on a full pixel doesn't work on OS X", Continue); # endif #endif diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp index 256fa43d2e..650892d650 100644 --- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp +++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp @@ -35,7 +35,7 @@ #include "../../shared/util.h" -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #endif @@ -67,7 +67,7 @@ void tst_QQuickGraphicsInfo::testProperties() QCOMPARE(obj->property("api").toInt(), expectedAPI); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (expectedAPI == QSGRendererInterface::OpenGL) { QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL)); QVERIFY(view.openglContext()); diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index 78322b44a1..cc74b7e07d 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -3133,7 +3133,7 @@ void tst_QQuickItem::parentLoop() { QQuickView *window = new QQuickView(0); -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression msgRegexp = QRegularExpression("QQuickItem::setParentItem: Parent QQuickItem\\(.*\\) is already part of the subtree of QQuickItem\\(.*\\)"); QTest::ignoreMessage(QtWarningMsg, msgRegexp); #endif @@ -3304,7 +3304,7 @@ void tst_QQuickItem::grab() QVERIFY(root); QQuickItem *item = root->findChild("myItem"); QVERIFY(item); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) { // Default size (item is 100x100) QSharedPointer result = item->grabToImage(); QSignalSpy spy(result.data(), SIGNAL(ready())); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 2576a1b0fc..44310008d6 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -61,7 +61,7 @@ private slots: void initTestCase() Q_DECL_OVERRIDE; void layerEnabled(); void layerSmooth(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void layerMipmap(); void layerEffect(); #endif @@ -105,7 +105,7 @@ tst_QQuickItemLayer::tst_QQuickItemLayer() void tst_QQuickItemLayer::initTestCase() { QQmlDataTest::initTestCase(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QWindow window; QOpenGLContext context; window.setSurfaceType(QWindow::OpenGLSurface); @@ -177,7 +177,7 @@ void tst_QQuickItemLayer::layerEnabled() QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1)); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // The test draws a one pixel wide line and scales it down by more than a a factor 2 // If mipmpping works, the pixels should be gray, not white or black diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index f22528a8a0..e1f903123b 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -59,7 +59,7 @@ static bool initView(QQuickView &v, const QUrl &url, bool moveMouseOut, QByteArr const QSize size = v.size(); const QPoint offset = QPoint(size.width() / 2, size.height() / 2); v.setFramePosition(screenGeometry.center() - offset); -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. if (moveMouseOut) QCursor::setPos(v.geometry().topRight() + QPoint(100, 100)); #else @@ -116,7 +116,7 @@ private slots: void pressedMultipleButtons_data(); void pressedMultipleButtons(); void changeAxis(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursorShape(); #endif void moveAndReleaseWithoutPress(); @@ -1692,7 +1692,7 @@ void tst_QQuickMouseArea::changeAxis() QCOMPARE(blackRect->y(), 94.0); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_QQuickMouseArea::cursorShape() { QQmlEngine engine; diff --git a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp index 44d7b40ed9..1716bdeafb 100644 --- a/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp +++ b/tests/auto/quick/qquickpainteditem/tst_qquickpainteditem.cpp @@ -32,7 +32,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #else #include @@ -73,7 +73,7 @@ public: ++paintRequests; clipRect = painter->clipBoundingRect(); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) { paintNode = static_cast(QQuickPaintedItem::updatePaintNode(oldNode, data)); diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp index 80c6c9e553..e854a109a1 100644 --- a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp +++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp @@ -35,7 +35,7 @@ #include "testhttpserver.h" #include -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) #include #include #endif @@ -57,7 +57,7 @@ private slots: void massive(); void cancelcrash(); void shrinkcache(); -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void networkCrash(); #endif void lockingCrash(); @@ -105,7 +105,7 @@ void tst_qquickpixmapcache::initTestCase() QVERIFY2(server.listen(), qPrintable(server.errorString())); -#ifndef QT_NO_BEARERMANAGEMENT +#if QT_CONFIG(bearermanagement) // This avoids a race condition/deadlock bug in network config // manager when it is accessed by the HTTP server thread before // anything else. Bug report can be found at: @@ -372,7 +372,7 @@ void tst_qquickpixmapcache::shrinkcache() } } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) void createNetworkServer(TestHTTPServer *server) { @@ -382,7 +382,7 @@ void createNetworkServer(TestHTTPServer *server) eventLoop.exec(); } -#ifndef QT_NO_CONCURRENT +#if QT_CONFIG(concurrent) // QT-3957 void tst_qquickpixmapcache::networkCrash() { diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 5d30cc8c94..765523316f 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -143,7 +143,7 @@ private slots: void cursorDelegateHeight(); void navigation(); void readOnly(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void canPaste(); void canPasteEmpty(); @@ -153,7 +153,7 @@ private slots: void inputMethodUpdate(); void openInputPanel(); void geometrySignals(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void pastingRichText_QTBUG_14003(); #endif void implicitSize_data(); @@ -2924,7 +2924,7 @@ void tst_qquicktextedit::navigation() QCOMPARE(input->hasActiveFocus(), false); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3001,7 +3001,7 @@ void tst_qquicktextedit::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -3019,7 +3019,7 @@ void tst_qquicktextedit::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -3037,7 +3037,7 @@ void tst_qquicktextedit::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3339,7 +3339,7 @@ void tst_qquicktextedit::geometrySignals() delete o; } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextedit::pastingRichText_QTBUG_14003() { QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }"; diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp index 8dc3053d89..1451f8e2fc 100644 --- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp @@ -145,7 +145,7 @@ private slots: void cursorRectangle(); void navigation(); void navigation_RTL(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void copyAndPaste(); void copyAndPasteKeySequence(); void canPasteEmpty(); @@ -2532,7 +2532,7 @@ void tst_qquicktextinput::navigation_RTL() QVERIFY(input->hasActiveFocus()); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2630,7 +2630,7 @@ void tst_qquicktextinput::copyAndPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::copyAndPasteKeySequence() { if (!PlatformQuirks::isClipboardAvailable()) @@ -2698,7 +2698,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPasteEmpty() { QGuiApplication::clipboard()->clear(); @@ -2714,7 +2714,7 @@ void tst_qquicktextinput::canPasteEmpty() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::canPaste() { QGuiApplication::clipboard()->setText("Some text"); @@ -2730,7 +2730,7 @@ void tst_qquicktextinput::canPaste() } #endif -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_qquicktextinput::middleClickPaste() { if (!PlatformQuirks::isClipboardAvailable()) @@ -3052,7 +3052,7 @@ void tst_qquicktextinput::cursorRectangle_data() << false; } -#ifndef QT_NO_IM +#if QT_CONFIG(im) #define COMPARE_INPUT_METHOD_QUERY(type, input, property, method, result) \ QCOMPARE((type) input->inputMethodQuery(property).method(), result); #else diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index acccac8eca..8d021d92da 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -284,7 +284,7 @@ public: private slots: void cleanup(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void openglContextCreatedSignal(); #endif void aboutToStopSignal(); @@ -350,7 +350,7 @@ private slots: void qobjectEventFilter_key(); void qobjectEventFilter_mouse(); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void cursor(); #endif @@ -373,14 +373,14 @@ private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) Q_DECLARE_METATYPE(QOpenGLContext *); #endif void tst_qquickwindow::cleanup() { QVERIFY(QGuiApplication::topLevelWindows().isEmpty()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void tst_qquickwindow::openglContextCreatedSignal() { qRegisterMetaType(); @@ -1327,7 +1327,7 @@ void tst_qquickwindow::headless() if (isGL) QVERIFY(!window->isSceneGraphInitialized()); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (QGuiApplication::platformName() == QLatin1String("windows") && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) { QSKIP("Crashes on Windows/ANGLE, QTBUG-42967"); @@ -1515,7 +1515,7 @@ void tst_qquickwindow::ownershipRootItem() QVERIFY(!accessor->isRootItemDestroyed()); } -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) void tst_qquickwindow::cursor() { QQuickWindow window; @@ -1688,7 +1688,7 @@ void tst_qquickwindow::hideThenDelete() QTest::qWaitForWindowExposed(&window); const bool threaded = QQuickWindowPrivate::get(&window)->context->thread() != QGuiApplication::instance()->thread(); const bool isGL = window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (isGL) openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); #endif @@ -1717,7 +1717,7 @@ void tst_qquickwindow::hideThenDelete() } QVERIFY(sgInvalidated->size() > 0); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (openglDestroyed) QVERIFY(openglDestroyed->size() > 0); #endif @@ -2128,7 +2128,7 @@ void tst_qquickwindow::defaultSurfaceFormat() QCOMPARE(format.profile(), reqFmt.profile()); QCOMPARE(int(format.options()), int(reqFmt.options())); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Depth and stencil should be >= what has been requested. For real. But use // the context since the window's surface format is only partially updated // on most platforms. @@ -2183,7 +2183,7 @@ public: } static int deleted; }; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) class GlRenderJob : public QRunnable { public: @@ -2254,7 +2254,7 @@ void tst_qquickwindow::testRenderJob() QTRY_COMPARE(RenderJob::deleted, 1); QCOMPARE(completedJobs.size(), 1); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (window.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL) { // Do a synchronized GL job. GLubyte readPixel[4] = {0, 0, 0, 0}; diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index f6d624d871..2cd3a041c8 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -28,7 +28,7 @@ #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #include #include @@ -37,7 +37,7 @@ #include #include -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) #include #endif @@ -105,7 +105,7 @@ private slots: void render_data(); void render(); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) void hideWithOtherContext(); #endif void createTextureFromImage_data(); @@ -130,7 +130,7 @@ void tst_SceneGraph::initTestCase() QSGRenderLoop *loop = QSGRenderLoop::instance(); qDebug() << "RenderLoop: " << loop; -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext context; context.setFormat(loop->sceneGraphContext()->defaultSurfaceFormat()); context.create(); @@ -222,7 +222,7 @@ void tst_SceneGraph::manyWindows_data() QTest::newRow("rects,subwindow,sharing") << QStringLiteral("manyWindows_rects.qml") << false << true; } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) struct ShareContextResetter { public: ~ShareContextResetter() { qt_gl_set_global_share_context(0); } @@ -234,7 +234,7 @@ void tst_SceneGraph::manyWindows() QFETCH(QString, file); QFETCH(bool, toplevel); QFETCH(bool, shared); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) QOpenGLContext sharedGLContext; ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure. if (shared) { @@ -479,7 +479,7 @@ void tst_SceneGraph::render() } } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Testcase for QTBUG-34898. We make another context current on another surface // in the GUI thread and hide the QQuickWindow while the other context is // current on the other window. diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp index ab58aee648..cb2b8be97a 100644 --- a/tests/auto/quick/shared/viewtestutil.cpp +++ b/tests/auto/quick/shared/viewtestutil.cpp @@ -61,7 +61,7 @@ void QQuickViewTestUtil::centerOnScreen(QQuickView *window) void QQuickViewTestUtil::moveMouseAway(QQuickView *window) { -#ifndef QT_NO_CURSOR // Get the cursor out of the way. +#if QT_CONFIG(cursor) // Get the cursor out of the way. QCursor::setPos(window->geometry().topRight() + QPoint(100, 100)); #else Q_UNUSED(window) diff --git a/tests/auto/shared/platformquirks.h b/tests/auto/shared/platformquirks.h index 5e4929230a..5252e8cfe2 100644 --- a/tests/auto/shared/platformquirks.h +++ b/tests/auto/shared/platformquirks.h @@ -39,7 +39,7 @@ struct PlatformQuirks { static inline bool isClipboardAvailable() { -#if defined(QT_NO_CLIPBOARD) +#if !QT_CONFIG(clipboard) return false; #elif defined(Q_OS_OSX) PasteboardRef pasteboard; diff --git a/tests/benchmarks/qml/compilation/tst_compilation.cpp b/tests/benchmarks/qml/compilation/tst_compilation.cpp index 690e193b53..61339c6f60 100644 --- a/tests/benchmarks/qml/compilation/tst_compilation.cpp +++ b/tests/benchmarks/qml/compilation/tst_compilation.cpp @@ -75,7 +75,7 @@ void tst_compilation::boomblock() QQmlComponent c(&engine); c.setData(data, QUrl()); } -#ifdef QT_NO_OPENGL +#if !QT_CONFIG(opengl) QSKIP("boomblock imports Particles which requires OpenGL Support"); #endif QBENCHMARK { diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 071908e78e..31fd9b383f 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -215,7 +215,7 @@ public Q_SLOTS: returnCode = retCode; } -#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL) +#if defined(QT_GUI_LIB) && QT_CONFIG(opengl) void onOpenGlContextCreated(QOpenGLContext *context); #endif }; @@ -237,7 +237,7 @@ void LoadWatcher::contain(QObject *o, const QUrl &containPath) void LoadWatcher::checkForWindow(QObject *o) { -#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL) +#if defined(QT_GUI_LIB) && QT_CONFIG(opengl) if (verboseMode && o->isWindowType() && o->inherits("QQuickWindow")) { connect(o, SIGNAL(openglContextCreated(QOpenGLContext*)), this, SLOT(onOpenGlContextCreated(QOpenGLContext*))); @@ -247,7 +247,7 @@ void LoadWatcher::checkForWindow(QObject *o) #endif // QT_GUI_LIB && !QT_NO_OPENGL } -#if defined(QT_GUI_LIB) && !defined(QT_NO_OPENGL) +#if defined(QT_GUI_LIB) && QT_CONFIG(opengl) void LoadWatcher::onOpenGlContextCreated(QOpenGLContext *context) { context->makeCurrent(qobject_cast(sender())); @@ -524,7 +524,7 @@ int main(int argc, char *argv[]) if (quietMode && verboseMode) verboseMode = false; -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) //qt_ translations loaded by QQmlApplicationEngine QString sysLocale = QLocale::system().name(); @@ -569,7 +569,7 @@ int main(int argc, char *argv[]) for (const QString &path : qAsConst(files)) { //QUrl::fromUserInput doesn't treat no scheme as relative file paths -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression urlRe("[[:word:]]+://.*"); if (urlRe.match(path).hasMatch()) { //Treat as a URL QUrl url = QUrl::fromUserInput(path); diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp index 6fee013c62..01a279afbf 100644 --- a/tools/qmleasing/splineeditor.cpp +++ b/tools/qmleasing/splineeditor.cpp @@ -224,7 +224,7 @@ void SplineEditor::mouseReleaseEvent(QMouseEvent *e) } } -#ifndef QT_NO_CONTEXTMENU +#if QT_CONFIG(contextmenu) void SplineEditor::contextMenuEvent(QContextMenuEvent *e) { int index = findControlPoint(e->pos()); @@ -244,7 +244,7 @@ void SplineEditor::contextMenuEvent(QContextMenuEvent *e) addPoint(e->pos()); } } -#endif // QT_NO_CONTEXTMENU +#endif // contextmenu void SplineEditor::invalidate() { diff --git a/tools/qmleasing/splineeditor.h b/tools/qmleasing/splineeditor.h index 243e199cd0..414b787bc3 100644 --- a/tools/qmleasing/splineeditor.h +++ b/tools/qmleasing/splineeditor.h @@ -79,9 +79,9 @@ protected: void mousePressEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); -#ifndef QT_NO_CONTEXTMENU +#if QT_CONFIG(contextmenu) void contextMenuEvent(QContextMenuEvent *); -#endif // QT_NO_CONTEXTMENU +#endif // contextmenu void invalidate(); void invalidateSmoothList(); diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index db0af1d071..1e8d91a95b 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -289,7 +289,7 @@ static bool checkVersion(const QUrl &url) static void displayFileDialog(Options *options) { -#if defined(QT_WIDGETS_LIB) && !defined(QT_NO_FILEDIALOG) +#if defined(QT_WIDGETS_LIB) && QT_CONFIG(filedialog) QString fileName = QFileDialog::getOpenFileName(0, "Open QML file", QString(), "QML Files (*.qml)"); if (!fileName.isEmpty()) { QFileInfo fi(fileName); @@ -301,7 +301,7 @@ static void displayFileDialog(Options *options) #endif } -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) static void loadTranslationFile(QTranslator &translator, const QString& directory) { translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); @@ -361,7 +361,7 @@ static void usage() puts(" "); exit(1); } -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) // Listen on GL context creation of the QQuickWindow in order to print diagnostic output. class DiagnosticGlContextCreationListener : public QObject { Q_OBJECT @@ -405,7 +405,7 @@ static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *windo if (verbose) { newTitle += QLatin1String(" [Qt ") + QLatin1String(QT_VERSION_STR) + QLatin1Char(' ') + QGuiApplication::platformName() + QLatin1Char(' '); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL ? QLatin1String("GL") : QLatin1String("GLES"); #endif @@ -509,7 +509,7 @@ int main(int argc, char ** argv) } } -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) QTranslator translator; QTranslator qtTranslator; QString sysLocale = QLocale::system().name(); @@ -545,7 +545,7 @@ int main(int argc, char ** argv) if (!options.url.isEmpty()) { if (!options.versionDetection || checkVersion(options.url)) { -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) QTranslator translator; #endif @@ -559,7 +559,7 @@ int main(int argc, char ** argv) engine.addPluginPath(pluginPaths.at(i)); if (options.url.isLocalFile()) { QFileInfo fi(options.url.toLocalFile()); -#ifndef QT_NO_TRANSLATION +#if QT_CONFIG(translation) loadTranslationFile(translator, fi.path()); #endif loadDummyDataFiles(engine, fi.path()); @@ -598,7 +598,7 @@ int main(int argc, char ** argv) if (window) { setWindowTitle(options.verbose, topLevel, window.data()); -#ifndef QT_NO_OPENGL +#if QT_CONFIG(opengl) if (options.verbose) new DiagnosticGlContextCreationListener(window.data()); #endif -- cgit v1.2.3 From 550290250a99f38f6ff0a891d6e75e21deec8cbf Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Nov 2016 12:53:04 +0100 Subject: Fix caching of the current qmlContext in QQmlObjectCreator A context is not a QV4::Object, just a QV4::Managed. Testing for Object here lead to us creating a new QV4::QmlContext every time this method got called instead of sharing it. Reduces memory consumption and improves the performance of some of the creation benchmarks in qmlbench by ~20%. Change-Id: I20c0ad52133aa0cb40c9d2551fd635bef8b7d90a Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlobjectcreator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 2218f277d6..004e18576b 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1016,7 +1016,7 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() { - if (!_qmlContext->objectValue()) + if (!_qmlContext->isManaged()) _qmlContext->setM(v4->rootContext()->newQmlContext(context, _scopeObject)); return _qmlContext->d(); -- cgit v1.2.3 From 58d0fc4dcf99b867d1f0bd67327105983ec36e07 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 25 Nov 2016 11:24:25 +0100 Subject: V4: Help the C++ compiler to do more DSE by inlining more code The JS stack allocation initializes the contents, but in most cases the caller will immediately store a value in that stack slot. When the allocation code is inlined, the compiler can use dead store elimination to remove the unnecessary initialization code. Change-Id: I0495417adc7c1c8764f845032611bd506a8b7df9 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4engine_p.h | 3 ++- src/qml/jsruntime/qv4global_p.h | 6 +++++ src/qml/jsruntime/qv4scopedvalue_p.h | 37 ++++++++++++++++------------- src/qml/jsruntime/qv4value_p.h | 46 ++++++++++++++++++------------------ 4 files changed, 52 insertions(+), 40 deletions(-) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 25d6fc1970..d20402b369 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -128,7 +128,8 @@ public: --jsStackTop; return jsStackTop->heapObject(); } - Value *jsAlloca(int nValues) { + + QML_NEARLY_ALWAYS_INLINE Value *jsAlloca(int nValues) { Value *ptr = jsStackTop; jsStackTop = ptr + nValues; for (int i = 0; i < nValues; ++i) diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 184375a9b6..c37ad1668d 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -58,6 +58,12 @@ #include #include +#ifdef QT_NO_DEBUG +#define QML_NEARLY_ALWAYS_INLINE Q_ALWAYS_INLINE +#else +#define QML_NEARLY_ALWAYS_INLINE inline +#endif + #ifdef V4_BOOTSTRAP #include #else diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 5022d7c3bc..164fbb2997 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -97,7 +97,7 @@ struct Scope { engine->jsStackTop = mark; } - Value *alloc(int nValues) const { + QML_NEARLY_ALWAYS_INLINE Value *alloc(int nValues) const { return engine->jsAlloca(nValues); } @@ -189,63 +189,70 @@ struct Scoped { enum ConvertType { Convert }; - inline void setPointer(const Managed *p) { + QML_NEARLY_ALWAYS_INLINE void setPointer(const Managed *p) { ptr->setM(p ? p->m() : 0); } - Scoped(const Scope &scope) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope) { ptr = scope.engine->jsAlloca(1); } - Scoped(const Scope &scope, const Value &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v) { ptr = scope.engine->jsAlloca(1); setPointer(v.as()); } - Scoped(const Scope &scope, Heap::Base *o) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, Heap::Base *o) { Value v; v = o; ptr = scope.engine->jsAlloca(1); setPointer(v.as()); } - Scoped(const Scope &scope, const ScopedValue &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ScopedValue &v) { ptr = scope.engine->jsAlloca(1); setPointer(v.ptr->as()); } - Scoped(const Scope &scope, const Value &v, ConvertType) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value &v, ConvertType) { ptr = scope.engine->jsAlloca(1); ptr->setRawValue(value_convert(scope.engine, v)); } - Scoped(const Scope &scope, const Value *v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const Value *v) { ptr = scope.engine->jsAlloca(1); setPointer(v ? v->as() : 0); } - Scoped(const Scope &scope, T *t) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, T *t) { ptr = scope.engine->jsAlloca(1); setPointer(t); } - Scoped(const Scope &scope, typename T::Data *t) + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const T *t) + { + ptr = scope.engine->jsAlloca(1); + setPointer(t); + } + + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, typename T::Data *t) { ptr = scope.engine->jsAlloca(1); *ptr = t; } - Scoped(const Scope &scope, const ReturnedValue &v) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v) { ptr = scope.engine->jsAlloca(1); setPointer(QV4::Value::fromReturnedValue(v).as()); } - Scoped(const Scope &scope, const ReturnedValue &v, ConvertType) + QML_NEARLY_ALWAYS_INLINE Scoped(const Scope &scope, const ReturnedValue &v, ConvertType) { ptr = scope.engine->jsAlloca(1); ptr->setRawValue(value_convert(scope.engine, QV4::Value::fromReturnedValue(v))); @@ -312,8 +319,8 @@ struct Scoped return ptr; } - ReturnedValue asReturnedValue() const { - return ptr->m() ? ptr->rawValue() : Encode::undefined(); + QML_NEARLY_ALWAYS_INLINE ReturnedValue asReturnedValue() const { + return ptr->rawValue(); } Value *ptr; @@ -358,8 +365,6 @@ struct ScopedProperty ScopedProperty(Scope &scope) { property = reinterpret_cast(scope.alloc(sizeof(Property) / sizeof(Value))); - property->value = Encode::undefined(); - property->set = Encode::undefined(); } Property *operator->() { return property; } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 6d5cff4ecc..29d8f196ee 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -160,9 +160,9 @@ private: quint64 _val; 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; } + QML_NEARLY_ALWAYS_INLINE quint64 &rawValueRef() { return _val; } + QML_NEARLY_ALWAYS_INLINE quint64 rawValue() const { return _val; } + QML_NEARLY_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; } #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN static inline int valueOffset() { return 0; } @@ -171,23 +171,23 @@ public: static inline int valueOffset() { return 4; } static inline int tagOffset() { return 0; } #endif - Q_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; } - Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); } - Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; } + QML_NEARLY_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; } + QML_NEARLY_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); } + QML_NEARLY_ALWAYS_INLINE quint32 tag() const { return _val >> 32; } #if defined(QV4_USE_64_BIT_VALUE_ENCODING) - Q_ALWAYS_INLINE Heap::Base *m() const + QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const { Heap::Base *b; memcpy(&b, &_val, 8); return b; } - Q_ALWAYS_INLINE void setM(Heap::Base *b) + QML_NEARLY_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 + QML_NEARLY_ALWAYS_INLINE Heap::Base *m() const { Q_STATIC_ASSERT(sizeof(Heap::Base*) == sizeof(quint32)); Heap::Base *b; @@ -195,7 +195,7 @@ public: memcpy(&b, &v, 4); return b; } - Q_ALWAYS_INLINE void setM(Heap::Base *b) + QML_NEARLY_ALWAYS_INLINE void setM(Heap::Base *b) { quint32 v; memcpy(&v, &b, 4); @@ -203,32 +203,32 @@ public: } #endif - Q_ALWAYS_INLINE int int_32() const + QML_NEARLY_ALWAYS_INLINE int int_32() const { return int(value()); } - Q_ALWAYS_INLINE void setInt_32(int i) + QML_NEARLY_ALWAYS_INLINE void setInt_32(int i) { setTagValue(Integer_Type_Internal, quint32(i)); } - Q_ALWAYS_INLINE uint uint_32() const { return value(); } + QML_NEARLY_ALWAYS_INLINE uint uint_32() const { return value(); } - Q_ALWAYS_INLINE void setEmpty() + QML_NEARLY_ALWAYS_INLINE void setEmpty() { setTagValue(Empty_Type_Internal, value()); } - Q_ALWAYS_INLINE void setEmpty(int i) + QML_NEARLY_ALWAYS_INLINE void setEmpty(int i) { setTagValue(Empty_Type_Internal, quint32(i)); } - Q_ALWAYS_INLINE void setEmpty(quint32 i) + QML_NEARLY_ALWAYS_INLINE void setEmpty(quint32 i) { setTagValue(Empty_Type_Internal, i); } - Q_ALWAYS_INLINE quint32 emptyValue() + QML_NEARLY_ALWAYS_INLINE quint32 emptyValue() { Q_ASSERT(isEmpty()); return quint32(value()); @@ -326,7 +326,7 @@ public: } inline bool isNaN() const { return (tag() & QV4::Value::NotDouble_Mask) == QV4::Value::NaN_Mask; } #endif - Q_ALWAYS_INLINE double doubleValue() const { + QML_NEARLY_ALWAYS_INLINE double doubleValue() const { Q_ASSERT(isDouble()); double d; quint64 v = _val; @@ -336,7 +336,7 @@ public: memcpy(&d, &v, 8); return d; } - Q_ALWAYS_INLINE void setDouble(double d) { + QML_NEARLY_ALWAYS_INLINE void setDouble(double d) { memcpy(&_val, &d, 8); #ifdef QV4_USE_64_BIT_VALUE_ENCODING _val ^= NaNEncodeMask; @@ -371,22 +371,22 @@ public: return int_32(); } - Q_ALWAYS_INLINE String *stringValue() const { + QML_NEARLY_ALWAYS_INLINE String *stringValue() const { if (!isString()) return nullptr; return m() ? reinterpret_cast(const_cast(this)) : 0; } - Q_ALWAYS_INLINE Object *objectValue() const { + QML_NEARLY_ALWAYS_INLINE Object *objectValue() const { if (!isObject()) return nullptr; return m() ? reinterpret_cast(const_cast(this)) : 0; } - Q_ALWAYS_INLINE Managed *managed() const { + QML_NEARLY_ALWAYS_INLINE Managed *managed() const { if (!isManaged()) return nullptr; return m() ? reinterpret_cast(const_cast(this)) : 0; } - Q_ALWAYS_INLINE Heap::Base *heapObject() const { + QML_NEARLY_ALWAYS_INLINE Heap::Base *heapObject() const { return isManaged() ? m() : nullptr; } -- cgit v1.2.3 From 6b641549536d199a0314049a34e61363bd4df7e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Nov 2016 15:39:07 +0100 Subject: Clean up duplicated checks whether a Value is a Managed Change-Id: Ib044be254dbb41bd9fb4a6e0baa3bd3c007e6a2a Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsvalue.cpp | 10 +-- src/qml/jsruntime/qv4dateobject_p.h | 2 +- src/qml/jsruntime/qv4engine_p.h | 3 - src/qml/jsruntime/qv4errorobject_p.h | 2 +- src/qml/jsruntime/qv4functionobject_p.h | 2 +- src/qml/jsruntime/qv4lookup.cpp | 110 ++++++++++++++++---------------- src/qml/jsruntime/qv4managed_p.h | 6 +- src/qml/jsruntime/qv4property_p.h | 4 +- src/qml/jsruntime/qv4string_p.h | 2 +- src/qml/jsruntime/qv4value_p.h | 12 ++-- src/qml/memory/qv4mm.cpp | 16 ++--- 11 files changed, 79 insertions(+), 90 deletions(-) diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index a4a96a96a7..d0a903a52d 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -885,14 +885,16 @@ QJSValue& QJSValue::operator=(const QJSValue& other) static bool js_equal(const QString &string, const QV4::Value &value) { - if (value.isString()) - return string == value.stringValue()->toQString(); + String *s = value.stringValue(); + if (s) + return string == s->toQString(); if (value.isNumber()) return RuntimeHelpers::stringToNumber(string) == value.asDouble(); if (value.isBoolean()) return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue()); - if (value.isObject()) { - Scope scope(value.objectValue()->engine()); + Object *o = value.objectValue(); + if (o) { + Scope scope(o->engine()); ScopedValue p(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); return js_equal(string, p); } diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 2d0648396e..835f6adbe0 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -101,7 +101,7 @@ struct DateObject: Object { template<> inline const DateObject *Value::as() const { - return isManaged() && m() && m()->vtable()->type == Managed::Type_DateObject ? static_cast(this) : 0; + return isManaged() && m()->vtable()->type == Managed::Type_DateObject ? static_cast(this) : 0; } struct DateCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index d20402b369..64bf77b1f5 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -584,9 +584,6 @@ void Heap::Base::mark(QV4::ExecutionEngine *engine) inline void Value::mark(ExecutionEngine *e) { - if (!isManaged()) - return; - Heap::Base *o = heapObject(); if (o) o->mark(e); diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 42a6e0b4b1..2b3ab25e2d 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -178,7 +178,7 @@ struct ErrorObject: Object { template<> inline const ErrorObject *Value::as() const { - return isManaged() && m() && m()->vtable()->isErrorObject ? reinterpret_cast(this) : 0; + return isManaged() && m()->vtable()->isErrorObject ? reinterpret_cast(this) : 0; } struct EvalErrorObject: ErrorObject { diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index e58b83e2c3..3dcc7ab482 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -168,7 +168,7 @@ struct Q_QML_EXPORT FunctionObject: Object { template<> inline const FunctionObject *Value::as() const { - return isManaged() && m() && m()->vtable()->isFunctionObject ? reinterpret_cast(this) : 0; + return isManaged() && m()->vtable()->isFunctionObject ? reinterpret_cast(this) : 0; } diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 84755a6402..5e9d4cf57c 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -345,11 +345,11 @@ ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const V ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass()) + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass) return o->propertyData(l->index)->asReturnedValue(); } return getterTwoClasses(l, engine, object); @@ -357,25 +357,24 @@ ReturnedValue Lookup::getter0(Lookup *l, ExecutionEngine *engine, const Value &o ReturnedValue Lookup::getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass() && - l->classList[1] == o->prototype()->internalClass) - return o->prototype()->propertyData(l->index)->asReturnedValue(); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype->internalClass) + return o->prototype->propertyData(l->index)->asReturnedValue(); } return getterTwoClasses(l, engine, object); } ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass()) { - Heap::Object *p = o->prototype(); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass) { + Heap::Object *p = o->prototype; if (l->classList[1] == p->internalClass) { p = p->prototype; if (l->classList[2] == p->internalClass) @@ -389,13 +388,13 @@ ReturnedValue Lookup::getter2(Lookup *l, ExecutionEngine *engine, const Value &o ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass()) + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass) return o->propertyData(l->index)->asReturnedValue(); - if (l->classList[2] == o->internalClass()) + if (l->classList[2] == o->internalClass) return o->propertyData(l->index2)->asReturnedValue(); } l->getter = getterFallback; @@ -404,15 +403,14 @@ ReturnedValue Lookup::getter0getter0(Lookup *l, ExecutionEngine *engine, const V ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass()) + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass) return o->propertyData(l->index)->asReturnedValue(); - if (l->classList[2] == o->internalClass() && - l->classList[3] == o->prototype()->internalClass) - return o->prototype()->propertyData(l->index2)->asReturnedValue(); + if (l->classList[2] == o->internalClass && l->classList[3] == o->prototype->internalClass) + return o->prototype->propertyData(l->index2)->asReturnedValue(); } l->getter = getterFallback; return getterFallback(l, engine, object); @@ -420,16 +418,16 @@ ReturnedValue Lookup::getter0getter1(Lookup *l, ExecutionEngine *engine, const V ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass() && - l->classList[1] == o->prototype()->internalClass) - return o->prototype()->propertyData(l->index)->asReturnedValue(); - if (l->classList[2] == o->internalClass() && - l->classList[3] == o->prototype()->internalClass) - return o->prototype()->propertyData(l->index2)->asReturnedValue(); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass && + l->classList[1] == o->prototype->internalClass) + return o->prototype->propertyData(l->index)->asReturnedValue(); + if (l->classList[2] == o->internalClass && + l->classList[3] == o->prototype->internalClass) + return o->prototype->propertyData(l->index2)->asReturnedValue(); return getterFallback(l, engine, object); } l->getter = getterFallback; @@ -439,12 +437,12 @@ ReturnedValue Lookup::getter1getter1(Lookup *l, ExecutionEngine *engine, const V ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Object *o = object.objectValue(); - if (l->classList[0] == o->internalClass()) { - Scope scope(o->engine()); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { + if (l->classList[0] == o->internalClass) { + Scope scope(o->internalClass->engine); ScopedFunctionObject getter(scope, o->propertyData(l->index + Object::GetterOffset)); if (!getter) return Encode::undefined(); @@ -461,10 +459,10 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, ExecutionEngine *engine, const ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Heap::Object *o = object.objectValue()->d(); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype->internalClass) { Scope scope(o->internalClass->engine); @@ -484,10 +482,10 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, ExecutionEngine *engine, const ReturnedValue Lookup::getterAccessor2(Lookup *l, ExecutionEngine *engine, const Value &object) { - if (object.isManaged()) { - // we can safely cast to a QV4::Object here. If object is actually a string, - // the internal class won't match - Heap::Object *o = object.objectValue()->d(); + // we can safely cast to a QV4::Object here. If object is actually a string, + // the internal class won't match + Heap::Object *o = static_cast(object.heapObject()); + if (o) { if (l->classList[0] == o->internalClass) { o = o->prototype; if (l->classList[1] == o->internalClass) { diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 28b255bd9a..56a1fcedf5 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -215,14 +215,12 @@ private: template<> inline const Managed *Value::as() const { - if (isManaged()) - return managed(); - return 0; + return managed(); } template<> inline const Object *Value::as() const { - return isManaged() && m() && m()->vtable()->isObject ? objectValue() : 0; + return objectValue(); } } diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index 50e8f0ae7f..5069d7690b 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -87,8 +87,8 @@ struct Property { inline bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const; inline void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs); - inline Heap::FunctionObject *getter() const { return value.isManaged() ? reinterpret_cast(value.heapObject()) : 0; } - inline Heap::FunctionObject *setter() const { return set.isManaged() ? reinterpret_cast(set.heapObject()) : 0; } + inline Heap::FunctionObject *getter() const { return reinterpret_cast(value.heapObject()); } + inline Heap::FunctionObject *setter() const { return reinterpret_cast(set.heapObject()); } inline void setGetter(FunctionObject *g) { value = reinterpret_cast(g); } inline void setSetter(FunctionObject *s) { set = (s ? reinterpret_cast(s) : 0); } diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 23ec3349b9..4890a85724 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -267,7 +267,7 @@ public: template<> inline const String *Value::as() const { - return isManaged() && m() && m()->vtable()->isString ? static_cast(this) : 0; + return isManaged() && m()->vtable()->isString ? static_cast(this) : 0; } #ifndef V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 29d8f196ee..e9a5b569a2 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -374,17 +374,17 @@ public: QML_NEARLY_ALWAYS_INLINE String *stringValue() const { if (!isString()) return nullptr; - return m() ? reinterpret_cast(const_cast(this)) : 0; + return reinterpret_cast(const_cast(this)); } QML_NEARLY_ALWAYS_INLINE Object *objectValue() const { if (!isObject()) return nullptr; - return m() ? reinterpret_cast(const_cast(this)) : 0; + return reinterpret_cast(const_cast(this)); } QML_NEARLY_ALWAYS_INLINE Managed *managed() const { if (!isManaged()) return nullptr; - return m() ? reinterpret_cast(const_cast(this)) : 0; + return reinterpret_cast(const_cast(this)); } QML_NEARLY_ALWAYS_INLINE Heap::Base *heapObject() const { return isManaged() ? m() : nullptr; @@ -420,7 +420,7 @@ public: template const T *as() const { - if (!m() || !isManaged()) + if (!isManaged()) return 0; Q_ASSERT(m()->vtable()); @@ -487,13 +487,13 @@ inline bool Value::isString() const { if (!isManaged()) return false; - return m() && m()->vtable()->isString; + return m()->vtable()->isString; } inline bool Value::isObject() const { if (!isManaged()) return false; - return m() && m()->vtable()->isObject; + return m()->vtable()->isObject; } inline bool Value::isPrimitive() const diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 6ef2380561..606d3ec162 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -421,11 +421,9 @@ void MemoryManager::mark() // managed objects in the loop down there doesn't make then end up as leftovers // on the stack and thus always get collected. for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) { - if (!(*it).isManaged()) + QObjectWrapper *qobjectWrapper = (*it).as(); + if (!qobjectWrapper) continue; - if (!(*it).as()) - continue; - QObjectWrapper *qobjectWrapper = static_cast((*it).managed()); QObject *qobject = qobjectWrapper->object(); if (!qobject) continue; @@ -453,10 +451,8 @@ void MemoryManager::mark() void MemoryManager::sweep(bool lastSweep) { for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) { - if (!(*it).isManaged()) - continue; Managed *m = (*it).managed(); - if (m->markBit()) + if (!m || m->markBit()) continue; // we need to call destroyObject on qobjectwrappers now, so that they can emit the destroyed // signal before we start sweeping the heap @@ -469,10 +465,8 @@ void MemoryManager::sweep(bool lastSweep) // onDestruction handlers may have accessed other QObject wrappers and reset their value, so ensure // that they are all set to undefined. for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) { - if (!(*it).isManaged()) - continue; - Managed *m = (*it).as(); - if (m->markBit()) + Managed *m = (*it).managed(); + if (!m || m->markBit()) continue; (*it) = Primitive::undefinedValue(); } -- cgit v1.2.3 From a36d19546891a808cf71dbb084d6d63870d2b8ec Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Nov 2016 15:49:39 +0100 Subject: Clean up some duplicated methods Change-Id: Iad64dd2c330ca85a28f8f5c776b0ede623203558 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4dateobject.cpp | 7 +++++-- src/qml/jsruntime/qv4jsonobject.cpp | 2 +- src/qml/jsruntime/qv4numberobject.cpp | 2 +- src/qml/jsruntime/qv4object_p.h | 2 +- src/qml/jsruntime/qv4objectproto.cpp | 16 +++++++--------- src/qml/jsruntime/qv4regexpobject.cpp | 4 ++-- src/qml/jsruntime/qv4runtime.cpp | 23 ----------------------- src/qml/jsruntime/qv4runtime_p.h | 3 --- src/qml/jsruntime/qv4stringobject.cpp | 2 +- 9 files changed, 18 insertions(+), 43 deletions(-) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 4f3138a452..5af26f8f36 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1319,14 +1319,17 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) { Scope scope(ctx); - ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject())); + ScopedObject O(scope, ctx->thisObject().toObject(scope.engine)); + if (scope.hasException()) + return Encode::undefined(); + ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT)); if (tv->isNumber() && !std::isfinite(tv->toNumber())) return Encode::null(); ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString"))); - ScopedValue v(scope, O->objectValue()->get(s)); + ScopedValue v(scope, O->get(s)); FunctionObject *toIso = v->as(); if (!toIso) diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 94a6e4daa1..6a01f207c4 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -917,7 +917,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) Value *v = stringify.propertyList + i; *v = o->getIndexed(i); if (v->as() || v->as() || v->isNumber()) - *v = RuntimeHelpers::toString(scope.engine, *v); + *v = v->toString(scope.engine); if (!v->isString()) { v->setM(0); } else { diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 1733df34ae..5b5aa29d55 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -283,7 +283,7 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx) return Encode::undefined(); if (!ctx->argc() || ctx->args()[0].isUndefined()) - return RuntimeHelpers::toString(scope.engine, v); + return Encode(v->toString(scope.engine)); int precision = ctx->args()[0].toInt32(); if (precision < 1 || precision > 21) { diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 00a004ef5f..91d9f03ad1 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -500,7 +500,7 @@ inline void Object::arraySet(uint index, const Value &value) template<> inline const ArrayObject *Value::as() const { - return isManaged() && m() && m()->vtable()->type == Managed::Type_ArrayObject ? static_cast(this) : 0; + return isManaged() && m()->vtable()->type == Managed::Type_ArrayObject ? static_cast(this) : 0; } #ifndef V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 6020c48250..8191083544 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -62,26 +62,24 @@ void Heap::ObjectCtor::init(QV4::ExecutionContext *scope) void ObjectCtor::construct(const Managed *that, Scope &scope, CallData *callData) { const ObjectCtor *ctor = static_cast(that); - ExecutionEngine *v4 = ctor->engine(); if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) { - ScopedObject obj(scope, v4->newObject()); - ScopedObject proto(scope, ctor->get(v4->id_prototype())); + ScopedObject obj(scope, scope.engine->newObject()); + ScopedObject proto(scope, ctor->get(scope.engine->id_prototype())); if (!!proto) obj->setPrototype(proto); scope.result = obj.asReturnedValue(); } else { - scope.result = RuntimeHelpers::toObject(scope.engine, callData->args[0]); + scope.result = callData->args[0].toObject(scope.engine); } } -void ObjectCtor::call(const Managed *m, Scope &scope, CallData *callData) +void ObjectCtor::call(const Managed *, Scope &scope, CallData *callData) { - const ObjectCtor *ctor = static_cast(m); - ExecutionEngine *v4 = ctor->engine(); + ExecutionEngine *v4 = scope.engine; if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) { scope.result = v4->newObject()->asReturnedValue(); } else { - scope.result = RuntimeHelpers::toObject(v4, callData->args[0]); + scope.result = callData->args[0].toObject(v4); } } @@ -398,7 +396,7 @@ ReturnedValue ObjectPrototype::method_toString(CallContext *ctx) } else if (ctx->thisObject().isNull()) { return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue(); } else { - ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject())); + ScopedObject obj(scope, ctx->thisObject().toObject(scope.engine)); QString className = obj->className(); return ctx->d()->engine->newString(QStringLiteral("[object %1]").arg(className))->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 4022d98c3f..c35286bd3a 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -262,7 +262,7 @@ void RegExpCtor::construct(const Managed *, Scope &scope, CallData *callData) bool ignoreCase = false; bool multiLine = false; if (!f->isUndefined()) { - f = RuntimeHelpers::toString(scope.engine, f); + f = f->toString(scope.engine); if (scope.hasException()) { scope.result = Encode::undefined(); return; @@ -356,7 +356,7 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) return ctx->engine()->throwTypeError(); ScopedValue arg(scope, ctx->argument(0)); - arg = RuntimeHelpers::toString(scope.engine, arg); + arg = arg->toString(scope.engine); if (scope.hasException()) return Encode::undefined(); QString s = arg->stringValue()->toQString(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 2026ecdfde..11ab4c85a0 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1367,29 +1367,6 @@ QV4::ReturnedValue Runtime::method_decrement(const Value &value) } } -#ifndef V4_BOOTSTRAP - -QV4::ReturnedValue RuntimeHelpers::toString(ExecutionEngine *engine, const Value &value) -{ - if (value.isString()) - return value.asReturnedValue(); - return RuntimeHelpers::convertToString(engine, value)->asReturnedValue(); -} - -QV4::ReturnedValue RuntimeHelpers::toObject(ExecutionEngine *engine, const Value &value) -{ - if (value.isObject()) - return value.asReturnedValue(); - - Heap::Object *o = RuntimeHelpers::convertToObject(engine, value); - if (!o) // type error - return Encode::undefined(); - - return Encode(o); -} - -#endif // V4_BOOTSTRAP - ReturnedValue Runtime::method_toDouble(const Value &value) { TRACE1(value); diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index a32b3f1663..0d787714cf 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -106,10 +106,7 @@ struct Q_QML_PRIVATE_EXPORT RuntimeHelpers { static double toNumber(const Value &value); static void numberToString(QString *result, double num, int radix = 10); - static ReturnedValue toString(ExecutionEngine *engine, const Value &value); static Heap::String *convertToString(ExecutionEngine *engine, const Value &value); - - static ReturnedValue toObject(ExecutionEngine *engine, const Value &value); static Heap::Object *convertToObject(ExecutionEngine *engine, const Value &value); static Bool equalHelper(const Value &x, const Value &y); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 829ada0c1a..68b693c5a0 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -284,7 +284,7 @@ ReturnedValue StringPrototype::method_concat(CallContext *context) ScopedValue v(scope); for (int i = 0; i < context->argc(); ++i) { - v = RuntimeHelpers::toString(scope.engine, context->args()[i]); + v = context->args()[i].toString(scope.engine); if (scope.hasException()) return Encode::undefined(); Q_ASSERT(v->isString()); -- cgit v1.2.3 From 5d35573a62686aa3b0c45fc032b79670d88ebba9 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 24 Nov 2016 16:05:14 +0100 Subject: Clean up Value::isString()/stringValue() combinations It's enough to just call stringValue(), as that already does the isString() check. Change-Id: I7be0e643a7975c0704b4c9c43b337deb8db9fce0 Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsvalue.cpp | 14 +++--- src/qml/jsruntime/qv4dateobject.cpp | 4 +- src/qml/jsruntime/qv4engine.cpp | 8 ++-- src/qml/jsruntime/qv4globalobject.cpp | 5 ++- src/qml/jsruntime/qv4jsonobject.cpp | 12 ++--- src/qml/jsruntime/qv4regexpobject.cpp | 12 ++--- src/qml/jsruntime/qv4runtime.cpp | 83 ++++++++++++++++++++--------------- src/qml/jsruntime/qv4stringobject.cpp | 12 ++--- src/qml/jsruntime/qv4value.cpp | 30 +++++++------ src/qml/qml/qqmllocale.cpp | 64 +++++++++++++++------------ src/qml/qml/qqmlvmemetaobject.cpp | 6 +-- src/qml/types/qqmllistmodel.cpp | 4 +- 12 files changed, 136 insertions(+), 118 deletions(-) diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index d0a903a52d..b473e96286 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -612,8 +612,8 @@ QVariant QJSValue::toVariant() const if (Object *o = val->as()) return o->engine()->toVariant(*val, /*typeHint*/ -1, /*createJSValueForObjects*/ false); - if (val->isString()) - return QVariant(val->stringValue()->toQString()); + if (String *s = val->stringValue()) + return QVariant(s->toQString()); if (val->isBoolean()) return QVariant(val->booleanValue()); if (val->isNumber()) { @@ -885,15 +885,13 @@ QJSValue& QJSValue::operator=(const QJSValue& other) static bool js_equal(const QString &string, const QV4::Value &value) { - String *s = value.stringValue(); - if (s) + if (String *s = value.stringValue()) return string == s->toQString(); if (value.isNumber()) return RuntimeHelpers::stringToNumber(string) == value.asDouble(); if (value.isBoolean()) return RuntimeHelpers::stringToNumber(string) == double(value.booleanValue()); - Object *o = value.objectValue(); - if (o) { + if (Object *o = value.objectValue()) { Scope scope(o->engine()); ScopedValue p(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); return js_equal(string, p); @@ -981,8 +979,8 @@ bool QJSValue::strictlyEquals(const QJSValue& other) const return *variant == *QJSValuePrivate::getVariant(&other); if (variant->type() == QVariant::Map || variant->type() == QVariant::List) return false; - if (ov->isString()) - return variant->toString() == ov->stringValue()->toQString(); + if (String *s = ov->stringValue()) + return variant->toString() == s->toQString(); return false; } if (!ov) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 5af26f8f36..8cc6a25fea 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -689,8 +689,8 @@ void DateCtor::construct(const Managed *, Scope &scope, CallData *callData) } else { arg = RuntimeHelpers::toPrimitive(arg, PREFERREDTYPE_HINT); - if (arg->isString()) - t = ParseString(arg->stringValue()->toQString()); + if (String *s = arg->stringValue()) + t = ParseString(s->toQString()); else t = TimeClip(arg->toNumber()); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a9284f2e69..634b8a3e6b 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1151,8 +1151,8 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int return value.integerValue(); if (value.isNumber()) return value.asDouble(); - if (value.isString()) { - const QString &str = value.toQString(); + if (String *s = value.stringValue()) { + const QString &str = s->toQString(); // QChars are stored as a strings if (typeHint == QVariant::Char && str.size() == 1) return str.at(0); @@ -1591,8 +1591,8 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data) *reinterpret_cast(data) = (unsigned char)(value->toInt32()); return true; case QMetaType::QChar: - if (value->isString()) { - QString str = value->stringValue()->toQString(); + if (String *s = value->stringValue()) { + QString str = s->toQString(); *reinterpret_cast(data) = str.isEmpty() ? QChar() : str.at(0); } else { *reinterpret_cast(data) = QChar(ushort(value->toUInt16())); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index feb0d90d26..af92ce1ad8 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -357,12 +357,13 @@ void EvalFunction::evalCall(Scope &scope, CallData *callData, bool directCall) c ctx = v4->pushGlobalContext(); } - if (!callData->args[0].isString()) { + String *scode = callData->args[0].stringValue(); + if (!scode) { scope.result = callData->args[0].asReturnedValue(); return; } - const QString code = callData->args[0].stringValue()->toQString(); + const QString code = scode->toQString(); bool inheritContext = !ctx->d()->strictMode; Script script(ctx, code, QStringLiteral("eval code")); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 6a01f207c4..d79e6242ba 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -727,8 +727,8 @@ QString Stringify::Str(const QString &key, const Value &v) return QStringLiteral("null"); if (scope.result.isBoolean()) return scope.result.booleanValue() ? QStringLiteral("true") : QStringLiteral("false"); - if (scope.result.isString()) - return quote(scope.result.stringValue()->toQString()); + if (String *s = scope.result.stringValue()) + return quote(s->toQString()); if (scope.result.isNumber()) { double d = scope.result.toNumber(); @@ -940,8 +940,8 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) if (s->isNumber()) { stringify.gap = QString(qMin(10, (int)s->toInteger()), ' '); - } else if (s->isString()) { - stringify.gap = s->stringValue()->toQString().left(10); + } else if (String *str = s->stringValue()) { + stringify.gap = str->toQString().left(10); } @@ -982,8 +982,8 @@ QJsonValue JsonObject::toJsonValue(const Value &value, V4ObjectSet &visitedObjec return QJsonValue(QJsonValue::Null); else if (value.isUndefined()) return QJsonValue(QJsonValue::Undefined); - else if (value.isString()) - return QJsonValue(value.toQString()); + else if (String *s = value.stringValue()) + return QJsonValue(s->toQString()); Q_ASSERT(value.isObject()); Scope scope(value.as()->engine()); diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index c35286bd3a..218695624b 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -262,12 +262,12 @@ void RegExpCtor::construct(const Managed *, Scope &scope, CallData *callData) bool ignoreCase = false; bool multiLine = false; if (!f->isUndefined()) { - f = f->toString(scope.engine); + ScopedString s(scope, f->toString(scope.engine)); if (scope.hasException()) { scope.result = Encode::undefined(); return; } - QString str = f->stringValue()->toQString(); + QString str = s->toQString(); for (int i = 0; i < str.length(); ++i) { if (str.at(i) == QLatin1Char('g') && !global) { global = true; @@ -356,10 +356,10 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) return ctx->engine()->throwTypeError(); ScopedValue arg(scope, ctx->argument(0)); - arg = arg->toString(scope.engine); + ScopedString str(scope, arg->toString(scope.engine)); if (scope.hasException()) return Encode::undefined(); - QString s = arg->stringValue()->toQString(); + QString s = str->toQString(); int offset = r->global() ? r->lastIndexProperty()->toInt32() : 0; if (offset < 0 || offset > s.length()) { @@ -391,11 +391,11 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) } array->setArrayLengthUnchecked(len); *array->propertyData(Index_ArrayIndex) = Primitive::fromInt32(result); - *array->propertyData(Index_ArrayInput) = arg; + *array->propertyData(Index_ArrayInput) = str; RegExpCtor::Data *dd = regExpCtor->d(); dd->lastMatch = array; - dd->lastInput = arg->stringValue()->d(); + dd->lastInput = str->d(); dd->lastMatchStart = matchOffsets[0]; dd->lastMatchEnd = matchOffsets[1]; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 11ab4c85a0..6d26cd8ad9 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -492,8 +492,8 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const Val else return engine->id_false()->d(); case Value::Managed_Type: - if (value.isString()) - return value.stringValue()->d(); + if (String *s = value.stringValue()) + return s->d(); { Scope scope(engine); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, STRING_HINT)); @@ -523,8 +523,8 @@ static Heap::String *convert_to_string_add(ExecutionEngine *engine, const Value else return engine->id_false()->d(); case Value::Managed_Type: - if (value.isString()) - return value.stringValue()->d(); + if (String *s = value.stringValue()) + return s->d(); { Scope scope(engine); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(value, PREFERREDTYPE_HINT)); @@ -543,19 +543,25 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu ScopedValue pleft(scope, RuntimeHelpers::toPrimitive(left, PREFERREDTYPE_HINT)); ScopedValue pright(scope, RuntimeHelpers::toPrimitive(right, PREFERREDTYPE_HINT)); - if (pleft->isString() || pright->isString()) { - if (!pleft->isString()) + String *sleft = pleft->stringValue(); + String *sright = pright->stringValue(); + if (sleft || sright) { + if (!sleft) { pleft = convert_to_string_add(engine, pleft); - if (!pright->isString()) + sleft = static_cast(pleft.ptr); + } + if (!sright) { pright = convert_to_string_add(engine, pright); + sright = static_cast(pright.ptr); + } if (scope.engine->hasException) return Encode::undefined(); - if (!pleft->stringValue()->d()->length()) - return pright->asReturnedValue(); - if (!pright->stringValue()->d()->length()) - return pleft->asReturnedValue(); + if (!sleft->d()->length()) + return sright->asReturnedValue(); + if (!sright->d()->length()) + return sleft->asReturnedValue(); MemoryManager *mm = engine->memoryManager; - return (mm->alloc(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); + return (mm->alloc(mm, sleft->d(), sright->d()))->asReturnedValue(); } double x = RuntimeHelpers::toNumber(pleft); double y = RuntimeHelpers::toNumber(pright); @@ -566,31 +572,28 @@ QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Valu { Q_ASSERT(left.isString() || right.isString()); - if (left.isString() && right.isString()) { - if (!left.stringValue()->d()->length()) - return right.asReturnedValue(); - if (!right.stringValue()->d()->length()) - return left.asReturnedValue(); - MemoryManager *mm = engine->memoryManager; - return (mm->alloc(mm, left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue(); - } - Scope scope(engine); ScopedValue pleft(scope, left); ScopedValue pright(scope, right); + String *sleft = pleft->stringValue(); + String *sright = pright->stringValue(); - if (!pleft->isString()) - pleft = convert_to_string_add(engine, left); - if (!pright->isString()) - pright = convert_to_string_add(engine, right); + if (!sleft) { + pleft = convert_to_string_add(engine, pleft); + sleft = static_cast(pleft.ptr); + } + if (!sright) { + pright = convert_to_string_add(engine, pright); + sright = static_cast(pright.ptr); + } if (scope.engine->hasException) return Encode::undefined(); - if (!pleft->stringValue()->d()->length()) + if (!sleft->d()->length()) return pright->asReturnedValue(); - if (!pright->stringValue()->d()->length()) + if (!sright->d()->length()) return pleft->asReturnedValue(); MemoryManager *mm = engine->memoryManager; - return (mm->alloc(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue(); + return (mm->alloc(mm, sleft->d(), sright->d()))->asReturnedValue(); } void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value) @@ -787,12 +790,14 @@ QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) return l.integerValue() > r.integerValue(); if (l.isNumber() && r.isNumber()) return l.asDouble() > r.asDouble(); - if (l.isString() && r.isString()) { + String *sl = l.stringValue(); + String *sr = r.stringValue(); + if (sl && sr) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return r.stringValue()->compare(l.stringValue()); + return sr->compare(sl); #endif } @@ -820,12 +825,14 @@ QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) return l.integerValue() < r.integerValue(); if (l.isNumber() && r.isNumber()) return l.asDouble() < r.asDouble(); - if (l.isString() && r.isString()) { + String *sl = l.stringValue(); + String *sr = r.stringValue(); + if (sl && sr) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return l.stringValue()->compare(r.stringValue()); + return sl->compare(sr); #endif } @@ -853,12 +860,14 @@ QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) return l.integerValue() >= r.integerValue(); if (l.isNumber() && r.isNumber()) return l.asDouble() >= r.asDouble(); - if (l.isString() && r.isString()) { + String *sl = l.stringValue(); + String *sr = r.stringValue(); + if (sl && sr) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return !l.stringValue()->compare(r.stringValue()); + return !sl->compare(sr); #endif } @@ -886,12 +895,14 @@ QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) return l.integerValue() <= r.integerValue(); if (l.isNumber() && r.isNumber()) return l.asDouble() <= r.asDouble(); - if (l.isString() && r.isString()) { + String *sl = l.stringValue(); + String *sr = r.stringValue(); + if (sl && sr) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); return false; #else - return !r.stringValue()->compare(l.stringValue()); + return !sr->compare(sl); #endif } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 68b693c5a0..6fbf1c3c85 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -218,8 +218,8 @@ static QString getThisString(ExecutionContext *ctx) { Scope scope(ctx); ScopedValue t(scope, ctx->thisObject()); - if (t->isString()) - return t->stringValue()->toQString(); + if (String *s = t->stringValue()) + return s->toQString(); if (StringObject *thisString = t->as()) return thisString->d()->string->toQString(); if (t->isUndefined() || t->isNull()) { @@ -282,13 +282,13 @@ ReturnedValue StringPrototype::method_concat(CallContext *context) if (scope.engine->hasException) return Encode::undefined(); - ScopedValue v(scope); + ScopedString s(scope); for (int i = 0; i < context->argc(); ++i) { - v = context->args()[i].toString(scope.engine); + s = context->args()[i].toString(scope.engine); if (scope.hasException()) return Encode::undefined(); - Q_ASSERT(v->isString()); - value += v->stringValue()->toQString(); + Q_ASSERT(s->isString()); + value += s->toQString(); } return context->d()->engine->newString(value)->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index 95c95b1974..ea5a3d491f 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -88,8 +88,8 @@ bool Value::toBoolean() const #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - if (isString()) - return stringValue()->toQString().length() > 0; + if (String *s = stringValue()) + return s->toQString().length() > 0; #endif return true; default: // double @@ -114,8 +114,8 @@ double Value::toNumberImpl() const #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - if (isString()) - return RuntimeHelpers::stringToNumber(stringValue()->toQString()); + if (String *s = stringValue()) + return RuntimeHelpers::stringToNumber(s->toQString()); { Q_ASSERT(isObject()); Scope scope(objectValue()->engine()); @@ -150,8 +150,8 @@ QString Value::toQStringNoThrow() const else return QStringLiteral("false"); case Value::Managed_Type: - if (isString()) - return stringValue()->toQString(); + if (String *s = stringValue()) + return s->toQString(); { Q_ASSERT(isObject()); Scope scope(objectValue()->engine()); @@ -203,8 +203,8 @@ QString Value::toQString() const else return QStringLiteral("false"); case Value::Managed_Type: - if (isString()) - return stringValue()->toQString(); + if (String *s = stringValue()) + return s->toQString(); { Q_ASSERT(isObject()); Scope scope(objectValue()->engine()); @@ -228,8 +228,10 @@ QString Value::toQString() const bool Value::sameValue(Value other) const { if (_val == other._val) return true; - if (isString() && other.isString()) - return stringValue()->isEqualTo(other.stringValue()); + String *s = stringValue(); + String *os = other.stringValue(); + if (s && os) + return s->isEqualTo(os); if (isInteger() && other.isDouble()) return int_32() ? (double(int_32()) == other.doubleValue()) : (other._val == 0); if (isDouble() && other.isInteger()) @@ -298,8 +300,8 @@ double Primitive::toInteger(double number) #ifndef V4_BOOTSTRAP Heap::String *Value::toString(ExecutionEngine *e) const { - if (isString()) - return stringValue()->d(); + if (String *s = stringValue()) + return s->d(); return RuntimeHelpers::convertToString(e, *this); } @@ -330,8 +332,8 @@ uint Value::asArrayLength(bool *ok) const } return idx; } - if (isString()) - return stringValue()->toUInt(ok); + if (String *s = stringValue()) + return s->toUInt(ok); uint idx = toUInt32(); double d = toNumber(); diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 6f66475aa5..3876e774c3 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -107,8 +107,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ct QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDt; if (ctx->argc() == 2) { - if (ctx->args()[1].isString()) { - QString format = ctx->args()[1].stringValue()->toQString(); + if (String *s = ctx->args()[1].stringValue()) { + QString format = s->toQString(); formattedDt = r->d()->locale->toString(dt, format); } else if (ctx->args()[1].isNumber()) { quint32 intFormat = ctx->args()[1].toNumber(); @@ -152,8 +152,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedTime; if (ctx->argc() == 2) { - if (ctx->args()[1].isString()) { - QString format = ctx->args()[1].stringValue()->toQString(); + if (String *s = ctx->args()[1].stringValue()) { + QString format = s->toQString(); formattedTime = r->d()->locale->toString(time, format); } else if (ctx->args()[1].isNumber()) { quint32 intFormat = ctx->args()[1].toNumber(); @@ -197,8 +197,8 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDate; if (ctx->argc() == 2) { - if (ctx->args()[1].isString()) { - QString format = ctx->args()[1].stringValue()->toQString(); + if (String *s = ctx->args()[1].stringValue()) { + QString format = s->toQString(); formattedDate = r->d()->locale->toString(date, format); } else if (ctx->args()[1].isNumber()) { quint32 intFormat = ctx->args()[1].toNumber(); @@ -217,11 +217,13 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx) { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->argc() == 1 && ctx->args()[0].isString()) { - QLocale locale; - QString dateString = ctx->args()[0].stringValue()->toQString(); - QDateTime dt = locale.toDateTime(dateString); - return QV4::Encode(engine->newDateObject(dt)); + if (ctx->argc() == 1) { + if (String *s = ctx->args()[0].stringValue()) { + QLocale locale; + QString dateString = s->toQString(); + QDateTime dt = locale.toDateTime(dateString); + return QV4::Encode(engine->newDateObject(dt)); + } } QV4::Scope scope(ctx); @@ -235,8 +237,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext * QDateTime dt; QString dateString = ctx->args()[1].toQStringNoThrow(); if (ctx->argc() == 3) { - if (ctx->args()[2].isString()) { - QString format = ctx->args()[2].stringValue()->toQString(); + if (String *s = ctx->args()[2].stringValue()) { + QString format = s->toQString(); dt = r->d()->locale->toDateTime(dateString, format); } else if (ctx->args()[2].isNumber()) { quint32 intFormat = ctx->args()[2].toNumber(); @@ -256,13 +258,15 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->argc() == 1 && ctx->args()[0].isString()) { - QLocale locale; - QString timeString = ctx->args()[0].stringValue()->toQString(); - QTime time = locale.toTime(timeString); - QDateTime dt = QDateTime::currentDateTime(); - dt.setTime(time); - return QV4::Encode(engine->newDateObject(dt)); + if (ctx->argc() == 1) { + if (String *s = ctx->args()[0].stringValue()) { + QLocale locale; + QString timeString = s->toQString(); + QTime time = locale.toTime(timeString); + QDateTime dt = QDateTime::currentDateTime(); + dt.setTime(time); + return QV4::Encode(engine->newDateObject(dt)); + } } if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0])) @@ -276,8 +280,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte QTime tm; QString dateString = ctx->args()[1].toQStringNoThrow(); if (ctx->argc() == 3) { - if (ctx->args()[2].isString()) { - QString format = ctx->args()[2].stringValue()->toQString(); + if (String *s = ctx->args()[2].stringValue()) { + QString format = s->toQString(); tm = r->d()->locale->toTime(dateString, format); } else if (ctx->args()[2].isNumber()) { quint32 intFormat = ctx->args()[2].toNumber(); @@ -303,11 +307,13 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->argc() == 1 && ctx->args()[0].isString()) { - QLocale locale; - QString dateString = ctx->args()[0].stringValue()->toQString(); - QDate date = locale.toDate(dateString); - return QV4::Encode(engine->newDateObject(QDateTime(date))); + if (ctx->argc() == 1) { + if (String *s = ctx->args()[0].stringValue()) { + QLocale locale; + QString dateString = s->toQString(); + QDate date = locale.toDate(dateString); + return QV4::Encode(engine->newDateObject(QDateTime(date))); + } } if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0])) @@ -321,8 +327,8 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte QDate dt; QString dateString = ctx->args()[1].toQStringNoThrow(); if (ctx->argc() == 3) { - if (ctx->args()[2].isString()) { - QString format = ctx->args()[2].stringValue()->toQString(); + if (String *s = ctx->args()[2].stringValue()) { + QString format = s->toQString(); dt = r->d()->locale->toDate(dateString, format); } else if (ctx->args()[2].isNumber()) { quint32 intFormat = ctx->args()[2].toNumber(); diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index b08a0e5087..d2cbb99b6a 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -489,9 +489,9 @@ QString QQmlVMEMetaObject::readPropertyAsString(int id) QV4::Scope scope(cache->engine); QV4::ScopedValue sv(scope, *(md->data() + id)); - if (!sv->isString()) - return QString(); - return sv->stringValue()->toQString(); + if (QV4::String *s = sv->stringValue()) + return s->toQString(); + return QString(); } QUrl QQmlVMEMetaObject::readPropertyAsUrl(int id) diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 2ba164f721..8574a4784c 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -505,10 +505,10 @@ void ListModel::set(int elementIndex, QV4::Object *object) break; // Add the value now - if (propertyValue->isString()) { + if (QV4::String *s = propertyValue->stringValue()) { const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::String); if (r.type == ListLayout::Role::String) - e->setStringPropertyFast(r, propertyValue->stringValue()->toQString()); + e->setStringPropertyFast(r, s->toQString()); } else if (propertyValue->isNumber()) { const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number); if (r.type == ListLayout::Role::Number) { -- cgit v1.2.3 From 46941afcc10209905a92e6bb8b3eba7c08bf6750 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 25 Nov 2016 10:27:02 +0100 Subject: Cleanup Value::isObject/objectValue usages Try to avoid calling both as objectValue() already checks isObject(). Change-Id: I1d770d4d9dabed4ea4cc3e322b8fdc5a64f5bd2b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 4 +- src/qml/jsruntime/qv4lookup.cpp | 41 ++++++++-------- src/qml/jsruntime/qv4managed_p.h | 5 ++ src/qml/jsruntime/qv4objectiterator.cpp | 19 ++++---- src/qml/jsruntime/qv4runtime.cpp | 85 ++++++++++++++++++--------------- src/qml/jsruntime/qv4value.cpp | 4 +- src/qml/qml/qqmlobjectcreator.cpp | 2 +- 7 files changed, 87 insertions(+), 73 deletions(-) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 634b8a3e6b..5c79c4ea97 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1704,10 +1704,10 @@ bool ExecutionEngine::metaTypeFromJS(const Value *value, int type, void *data) // We have T t, T* is requested, so return &t. *reinterpret_cast(data) = var.data(); return true; - } else if (value->isObject()) { + } else if (Object *o = value->objectValue()) { // Look in the prototype chain. QV4::Scope scope(this); - QV4::ScopedObject proto(scope, value->objectValue()->prototype()); + QV4::ScopedObject proto(scope, o->prototype()); while (proto) { bool canCast = false; if (QV4::VariantObject *vo = proto->as()) { diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 5e9d4cf57c..0b0b2685b3 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -174,15 +174,15 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index) { uint idx = index.asArrayIndex(); - if (idx == UINT_MAX || !object.isObject()) - return indexedGetterFallback(l, object, index); - - Object *o = object.objectValue(); - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { - Heap::SimpleArrayData *s = o->d()->arrayData.cast(); - if (idx < s->len) - if (!s->data(idx).isEmpty()) - return s->data(idx).asReturnedValue(); + if (idx != UINT_MAX) { + if (Object *o = object.objectValue()) { + if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { + Heap::SimpleArrayData *s = o->d()->arrayData.cast(); + if (idx < s->len) + if (!s->data(idx).isEmpty()) + return s->data(idx).asReturnedValue(); + } + } } return indexedGetterFallback(l, object, index); @@ -190,8 +190,7 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, con void Lookup::indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v) { - if (object.isObject()) { - Object *o = object.objectValue(); + if (Object *o = object.objectValue()) { if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex() < UINT_MAX) { l->indexedSetter = indexedSetterObjectInt; indexedSetterObjectInt(l, object, index, v); @@ -228,17 +227,15 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value & void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v) { uint idx = index.asArrayIndex(); - if (idx == UINT_MAX || !object.isObject()) { - indexedSetterGeneric(l, object, index, v); - return; - } - - Object *o = object.objectValue(); - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { - Heap::SimpleArrayData *s = o->d()->arrayData.cast(); - if (idx < s->len) { - s->data(idx) = v; - return; + if (idx != UINT_MAX) { + if (Object *o = object.objectValue()) { + if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { + Heap::SimpleArrayData *s = o->d()->arrayData.cast(); + if (idx < s->len) { + s->data(idx) = v; + return; + } + } } } indexedSetterFallback(l, object, index, v); diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 56a1fcedf5..86caac3ebe 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -206,6 +206,11 @@ public: bool markBit() const { return d()->isMarked(); } static void destroy(Heap::Base *) {} + + Q_ALWAYS_INLINE Heap::Base *heapObject() const { + return m(); + } + private: friend class MemoryManager; friend struct Identifiers; diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 7943a13ac0..59115dfe21 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -70,15 +70,16 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib ScopedString n(scope); while (1) { - if (!current->as()) + Object *co = current->objectValue(); + if (!co) break; while (1) { - current->as()->advanceIterator(this, name, index, pd, attrs); + co->advanceIterator(this, name, index, pd, attrs); if (attrs->isEmpty()) break; // check the property is not already defined earlier in the proto chain - if (current->heapObject() != object->heapObject()) { + if (co->heapObject() != object->heapObject()) { o = object->as(); n = *name; bool shadowed = false; @@ -97,7 +98,7 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib } if (flags & WithProtoChain) - current->setM(current->objectValue()->prototype()); + current->setM(co->prototype()); else current->setM(0); @@ -109,7 +110,8 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib ReturnedValue ObjectIterator::nextPropertyName(Value *value) { - if (!object->as()) + Object *o = object->objectValue(); + if (!o) return Encode::null(); PropertyAttributes attrs; @@ -121,7 +123,7 @@ ReturnedValue ObjectIterator::nextPropertyName(Value *value) if (attrs.isEmpty()) return Encode::null(); - *value = object->objectValue()->getValue(p->value, attrs); + *value = o->getValue(p->value, attrs); if (!!name) return name->asReturnedValue(); @@ -131,7 +133,8 @@ ReturnedValue ObjectIterator::nextPropertyName(Value *value) ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value) { - if (!object->as()) + Object *o = object->objectValue(); + if (!o) return Encode::null(); PropertyAttributes attrs; @@ -143,7 +146,7 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value) if (attrs.isEmpty()) return Encode::null(); - *value = object->objectValue()->getValue(p->value, attrs); + *value = o->getValue(p->value, attrs); if (!!name) return name->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 6d26cd8ad9..944588dd28 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -375,13 +375,14 @@ QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Val QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left, const Value &right) { - if (!right.isObject()) + Object *ro = right.objectValue(); + if (!ro) return engine->throwTypeError(); Scope scope(engine); ScopedString s(scope, left.toString(engine)); if (scope.hasException()) return Encode::undefined(); - bool r = right.objectValue()->hasProperty(s); + bool r = ro->hasProperty(s); return Encode(r); } @@ -753,13 +754,15 @@ uint RuntimeHelpers::equalHelper(const Value &x, const Value &y) #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - if ((x.isNumber() || x.isString()) && y.isObject()) { - Scope scope(y.objectValue()->engine()); - ScopedValue py(scope, RuntimeHelpers::toPrimitive(y, PREFERREDTYPE_HINT)); + Object *xo = x.objectValue(); + Object *yo = y.objectValue(); + if (yo && (x.isNumber() || x.isString())) { + Scope scope(yo->engine()); + ScopedValue py(scope, RuntimeHelpers::objectDefaultValue(yo, PREFERREDTYPE_HINT)); return Runtime::method_compareEqual(x, py); - } else if (x.isObject() && (y.isNumber() || y.isString())) { - Scope scope(x.objectValue()->engine()); - ScopedValue px(scope, RuntimeHelpers::toPrimitive(x, PREFERREDTYPE_HINT)); + } else if (xo && (y.isNumber() || y.isString())) { + Scope scope(xo->engine()); + ScopedValue px(scope, RuntimeHelpers::objectDefaultValue(xo, PREFERREDTYPE_HINT)); return Runtime::method_compareEqual(px, y); } #endif @@ -801,14 +804,16 @@ QV4::Bool Runtime::method_compareGreaterThan(const Value &l, const Value &r) #endif } - if (l.isObject() || r.isObject()) { + Object *ro = r.objectValue(); + Object *lo = l.objectValue(); + if (ro || lo) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); + QV4::ExecutionEngine *e = (lo ? lo : ro)->engine(); QV4::Scope scope(e); - QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); - QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); + QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); + QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); return Runtime::method_compareGreaterThan(pl, pr); #endif } @@ -836,14 +841,16 @@ QV4::Bool Runtime::method_compareLessThan(const Value &l, const Value &r) #endif } - if (l.isObject() || r.isObject()) { + Object *ro = r.objectValue(); + Object *lo = l.objectValue(); + if (ro || lo) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); + QV4::ExecutionEngine *e = (lo ? lo : ro)->engine(); QV4::Scope scope(e); - QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); - QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); + QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); + QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); return Runtime::method_compareLessThan(pl, pr); #endif } @@ -871,14 +878,16 @@ QV4::Bool Runtime::method_compareGreaterEqual(const Value &l, const Value &r) #endif } - if (l.isObject() || r.isObject()) { + Object *ro = r.objectValue(); + Object *lo = l.objectValue(); + if (ro || lo) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); + QV4::ExecutionEngine *e = (lo ? lo : ro)->engine(); QV4::Scope scope(e); - QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); - QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); + QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); + QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); return Runtime::method_compareGreaterEqual(pl, pr); #endif } @@ -906,14 +915,16 @@ QV4::Bool Runtime::method_compareLessEqual(const Value &l, const Value &r) #endif } - if (l.isObject() || r.isObject()) { + Object *ro = r.objectValue(); + Object *lo = l.objectValue(); + if (ro || lo) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else - QV4::ExecutionEngine *e = (l.isObject() ? l.objectValue() : r.objectValue())->engine(); + QV4::ExecutionEngine *e = (lo ? lo : ro)->engine(); QV4::Scope scope(e); - QV4::ScopedValue pl(scope, RuntimeHelpers::toPrimitive(l, QV4::NUMBER_HINT)); - QV4::ScopedValue pr(scope, RuntimeHelpers::toPrimitive(r, QV4::NUMBER_HINT)); + QV4::ScopedValue pl(scope, lo ? RuntimeHelpers::objectDefaultValue(lo, QV4::NUMBER_HINT) : l.asReturnedValue()); + QV4::ScopedValue pr(scope, ro ? RuntimeHelpers::objectDefaultValue(ro, QV4::NUMBER_HINT) : r.asReturnedValue()); return Runtime::method_compareLessEqual(pl, pr); #endif } @@ -1056,13 +1067,12 @@ ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint i Lookup *l = engine->current->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); - if (v.isObject()) { + if (Object *o = v.objectValue()) { Scope scope(engine); - v.objectValue()->call(scope, callData); + o->call(scope, callData); return scope.result.asReturnedValue(); - } else { - return engine->throwTypeError(); } + return engine->throwTypeError(); } ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value &index, CallData *callData) @@ -1085,12 +1095,12 @@ ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, const Value & ReturnedValue Runtime::method_callValue(ExecutionEngine *engine, const Value &func, CallData *callData) { - if (!func.isObject()) - return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); - - Scope scope(engine); - func.objectValue()->call(scope, callData); - return scope.result.asReturnedValue(); + if (Object *o = func.objectValue()) { + Scope scope(engine); + o->call(scope, callData); + return scope.result.asReturnedValue(); + } + return engine->throwTypeError(QStringLiteral("%1 is not a function").arg(func.toQStringNoThrow())); } @@ -1160,14 +1170,13 @@ ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, u Lookup *l = engine->current->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); - if (v.isObject()) { + if (Object *o = v.objectValue()) { Scope scope(engine); ScopedValue result(scope); - v.objectValue()->construct(scope, callData); + o->construct(scope, callData); return scope.result.asReturnedValue(); - } else { - return engine->throwTypeError(); } + return engine->throwTypeError(); } diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index ea5a3d491f..a3cd212d3b 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -307,8 +307,8 @@ Heap::String *Value::toString(ExecutionEngine *e) const Heap::Object *Value::toObject(ExecutionEngine *e) const { - if (isObject()) - return objectValue()->d(); + if (Object *o = objectValue()) + return o->d(); return RuntimeHelpers::convertToObject(e, *this); } diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 115925e34a..d07be77697 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1016,7 +1016,7 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() { - if (!_qmlContext->objectValue()) + if (!_qmlContext->isObject()) _qmlContext->setM(v4->rootContext()->newQmlContext(context, _scopeObject)); return _qmlContext->d(); -- cgit v1.2.3 From 17c7cb2b0dc7f14603932e059013aa8bb39eef27 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Nov 2016 14:16:27 +0100 Subject: Avoid a duplicated wasDeleted() check Change-Id: I30258041ca19cb7d925e4817c8f36577c335282d Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 3 +-- src/qml/jsruntime/qv4qobjectwrapper_p.h | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index d91965a350..80607f4067 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -493,8 +493,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP ReturnedValue QObjectWrapper::wrap_slowPath(ExecutionEngine *engine, QObject *object) { - if (QQmlData::wasDeleted(object)) - return QV4::Encode::null(); + Q_ASSERT(!QQmlData::wasDeleted(object)); QQmlData *ddata = QQmlData::get(object, true); if (!ddata) diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 504f6a69b8..c7c4f4dd77 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -206,14 +206,15 @@ private: inline ReturnedValue QObjectWrapper::wrap(ExecutionEngine *engine, QObject *object) { - if (Q_LIKELY(!QQmlData::wasDeleted(object))) { - QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); - if (Q_LIKELY(priv->declarativeData)) { - auto ddata = static_cast(priv->declarativeData); - if (Q_LIKELY(ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) { - // We own the JS object - return ddata->jsWrapper.value(); - } + if (Q_UNLIKELY(QQmlData::wasDeleted(object))) + return QV4::Encode::null(); + + QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); + if (Q_LIKELY(priv->declarativeData)) { + auto ddata = static_cast(priv->declarativeData); + if (Q_LIKELY(ddata->jsEngineId == engine->m_engineId && !ddata->jsWrapper.isUndefined())) { + // We own the JS object + return ddata->jsWrapper.value(); } } -- cgit v1.2.3 From 005857c492ff2a907987e5aed4c61163a6f3fc44 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 24 Nov 2016 13:30:37 +0100 Subject: V4: Streamline Value::toBoolean and prevent calls to Value::type() Value::type() is not inlined by GCC LTO, and does more work than needed. Change-Id: I0a1f99f48d8e55caf685a9a3aa56dce079c8f1b2 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4value.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index a3cd212d3b..e34ac9c764 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -77,14 +77,13 @@ int Value::toUInt16() const bool Value::toBoolean() const { - switch (type()) { - case Value::Undefined_Type: - case Value::Null_Type: + if (isInteger() || isBoolean()) + return static_cast(int_32()); + + if (isUndefined() || isNull()) return false; - case Value::Boolean_Type: - case Value::Integer_Type: - return (bool)int_32(); - case Value::Managed_Type: + + if (isManaged()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else @@ -92,9 +91,10 @@ bool Value::toBoolean() const return s->toQString().length() > 0; #endif return true; - default: // double - return doubleValue() && !std::isnan(doubleValue()); } + + // double + return doubleValue() && !std::isnan(doubleValue()); } double Value::toInteger() const -- cgit v1.2.3 From 4b210353e6e35368bc2411bc16157c8984cc46cc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Nov 2016 14:19:55 +0100 Subject: qquickwidget.cpp: move QT_END_NAMESPACE to bottom Amends change 62198ab4485e15f350122770d5dfd8de7e59b8f9. Change-Id: I14a18c938126d475f9cec0f940596558b01c33de Reviewed-by: Laszlo Agocs --- src/quickwidgets/qquickwidget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 1d617f5098..67f08abf66 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1589,9 +1589,6 @@ QQuickWindow *QQuickWidget::quickWindow() const return d->offscreenWindow; } -QT_END_NAMESPACE - - void QQuickWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) @@ -1612,3 +1609,5 @@ void QQuickWidget::paintEvent(QPaintEvent *event) } } } + +QT_END_NAMESPACE -- cgit v1.2.3 From fca6857529f9be982a75cd055fdc01e8d34413fb Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 29 Nov 2016 15:35:59 +0100 Subject: Make sure we cannot reload debug connectors on shutdown The various Q_GLOBAL_STATICs involved in the loading of debug plugins may be destroyed in any order. If the connector is unloaded before the services, it might get reloaded when one service calls instance(), trying to deregister itself. Prevent this by clearing all the parameters. Change-Id: Iee4a05e09401be916f0339d72eb8b5f2c9eac55d Reviewed-by: hjk Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmldebugconnector.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp index 23440e7529..dd34bb910f 100644 --- a/src/qml/debugger/qqmldebugconnector.cpp +++ b/src/qml/debugger/qqmldebugconnector.cpp @@ -152,7 +152,10 @@ QQmlDebugConnectorFactory::~QQmlDebugConnectorFactory() { // This is triggered when the plugin is unloaded. QQmlDebugConnectorParams *params = qmlDebugConnectorParams(); - if (params && params->instance) { + if (params) { + params->pluginKey.clear(); + params->arguments.clear(); + params->services.clear(); delete params->instance; params->instance = 0; } -- cgit v1.2.3 From 39496a40748be1d60c909ba679c45c788ec6412f Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 23 Nov 2016 14:31:11 +0100 Subject: QQmlDelegateModel: Avoid allocating unnecessarily Wait for the update request to be posted and take effect before piling another one up. This speeds up qmlbench creation benchmarks a bit (as they make use of Repeater). Results for benchmark/creation/delegates_item on a 5.6 base on a 2011 mbp: Before: Average: 670.4 ops/frame; using 5/5 samples; MedianAll=674; StdDev=6.34, CoV=0.00946 - StdDev (all samples included)=6.34 After: Average: 702 ops/frame; using 5/5 samples; MedianAll=700; StdDev=8.97, CoV=0.0128 - StdDev (all samples included)=8.97 Change-Id: Ic0ef4c1e2d6cb309edeb512cad4280a15abc7a06 Reviewed-by: Gunnar Sletta Reviewed-by: Shawn Rutledge --- src/qml/types/qqmldelegatemodel.cpp | 23 +++++++++++++++-------- src/qml/types/qqmldelegatemodel_p_p.h | 3 ++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 9b58ec35f8..d9a8b1d179 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -213,6 +213,7 @@ QQmlDelegateModelPrivate::QQmlDelegateModelPrivate(QQmlContext *ctxt) , m_reset(false) , m_transaction(false) , m_incubatorCleanupScheduled(false) + , m_waitingToFetchMore(false) , m_cacheItems(0) , m_items(0) , m_persistedItems(0) @@ -227,6 +228,15 @@ QQmlDelegateModelPrivate::~QQmlDelegateModelPrivate() m_cacheMetaType->release(); } +void QQmlDelegateModelPrivate::requestMoreIfNecessary() +{ + Q_Q(QQmlDelegateModel); + if (!m_waitingToFetchMore && m_adaptorModel.canFetchMore()) { + m_waitingToFetchMore = true; + QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest)); + } +} + void QQmlDelegateModelPrivate::init() { Q_Q(QQmlDelegateModel); @@ -334,9 +344,7 @@ void QQmlDelegateModel::componentComplete() &inserts); d->itemsInserted(inserts); d->emitChanges(); - - if (d->m_adaptorModel.canFetchMore()) - QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); + d->requestMoreIfNecessary(); } /*! @@ -375,8 +383,7 @@ void QQmlDelegateModel::setModel(const QVariant &model) if (d->m_complete) { _q_itemsInserted(0, d->m_adaptorModel.count()); - if (d->m_adaptorModel.canFetchMore()) - QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); + d->requestMoreIfNecessary(); } } @@ -922,7 +929,6 @@ void QQmlDelegateModelPrivate::setInitialState(QQDMIncubationTask *incubationTas QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bool asynchronous) { - Q_Q(QQmlDelegateModel); if (!m_delegate || index < 0 || index >= m_compositor.count(group)) { qWarning() << "DelegateModel::item: index out range" << index << m_compositor.count(group); return 0; @@ -989,8 +995,8 @@ QObject *QQmlDelegateModelPrivate::object(Compositor::Group group, int index, bo QQmlContextData::get(m_context)); } - if (index == m_compositor.count(group) - 1 && m_adaptorModel.canFetchMore()) - QCoreApplication::postEvent(q, new QEvent(QEvent::UpdateRequest)); + if (index == m_compositor.count(group) - 1) + requestMoreIfNecessary(); // Remove the temporary reference count. cacheItem->scriptRef -= 1; @@ -1110,6 +1116,7 @@ bool QQmlDelegateModel::event(QEvent *e) { Q_D(QQmlDelegateModel); if (e->type() == QEvent::UpdateRequest) { + d->m_waitingToFetchMore = false; d->m_adaptorModel.fetchMore(); } else if (e->type() == QEvent::User) { d->m_incubatorCleanupScheduled = false; diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 6cb82fddfc..7d97358b3d 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -149,7 +149,6 @@ public: int groups; int index; - Q_SIGNALS: void modelIndexChanged(); @@ -261,6 +260,7 @@ public: void init(); void connectModel(QQmlAdaptorModel *model); + void requestMoreIfNecessary(); QObject *object(Compositor::Group group, int index, bool asynchronous); QQmlDelegateModel::ReleaseFlags release(QObject *object); QString stringValue(Compositor::Group group, int index, const QString &name); @@ -329,6 +329,7 @@ public: bool m_reset : 1; bool m_transaction : 1; bool m_incubatorCleanupScheduled : 1; + bool m_waitingToFetchMore : 1; union { struct { -- cgit v1.2.3 From 3b4f00ecb54432f514f184c251a316896a88f91a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 8 Jul 2016 13:25:02 +0200 Subject: Layouts: Use QQuickItemChangeListener for more things MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signal connections are expensive: even with qmlobject_connect, there's a bunch of memory allocation. By avoiding the signal connections, we can do the same thing essentially, a little faster. This gives me another 15-20 RowLayout instances per frame when testing with RowLayout containing 5 Rectangles on qmlbench (from ~139 to ~155 ops/frame). Change-Id: I4448a28128dc251e40b6b06d642bae716af212f4 Reviewed-by: Jan Arve SƦther --- src/imports/layouts/qquicklayout.cpp | 32 ++++++++++++++---- src/imports/layouts/qquicklayout_p.h | 4 +++ src/imports/layouts/qquicklinearlayout.cpp | 54 ++++++++++-------------------- src/imports/layouts/qquicklinearlayout_p.h | 9 +++-- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp index 07ada75a5f..3786d21727 100644 --- a/src/imports/layouts/qquicklayout.cpp +++ b/src/imports/layouts/qquicklayout.cpp @@ -763,18 +763,14 @@ void QQuickLayout::itemChange(ItemChange change, const ItemChangeData &value) { if (change == ItemChildAddedChange) { QQuickItem *item = value.item; - qmlobject_connect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem())); - qmlobject_connect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem())); qmlobject_connect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); - QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder); + QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); if (isReady()) updateLayoutItems(); } else if (change == ItemChildRemovedChange) { QQuickItem *item = value.item; - qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickLayout, SLOT(invalidateSenderItem())); - qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickLayout, SLOT(invalidateSenderItem())); qmlobject_disconnect(item, QQuickItem, SIGNAL(baselineOffsetChanged(qreal)), this, QQuickLayout, SLOT(invalidateSenderItem())); - QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); if (isReady()) updateLayoutItems(); } @@ -812,6 +808,30 @@ void QQuickLayout::itemSiblingOrderChanged(QQuickItem *item) updateLayoutItems(); } +void QQuickLayout::itemImplicitWidthChanged(QQuickItem *item) +{ + if (!isReady() || item->signalsBlocked()) + return; + invalidate(item); +} + +void QQuickLayout::itemImplicitHeightChanged(QQuickItem *item) +{ + if (!isReady() || item->signalsBlocked()) + return; + invalidate(item); +} + +void QQuickLayout::itemDestroyed(QQuickItem *item) +{ + Q_UNUSED(item); +} + +void QQuickLayout::itemVisibilityChanged(QQuickItem *item) +{ + Q_UNUSED(item); +} + void QQuickLayout::rearrange(const QSizeF &/*size*/) { m_dirty = false; diff --git a/src/imports/layouts/qquicklayout_p.h b/src/imports/layouts/qquicklayout_p.h index c7f04c1fed..eece6f8658 100644 --- a/src/imports/layouts/qquicklayout_p.h +++ b/src/imports/layouts/qquicklayout_p.h @@ -99,6 +99,10 @@ public: /* QQuickItemChangeListener */ void itemSiblingOrderChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemImplicitWidthChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemImplicitHeightChanged(QQuickItem *item) Q_DECL_OVERRIDE; + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; + void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; protected: void updatePolish() Q_DECL_OVERRIDE; diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index 7fad395a29..13fdd496c2 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -303,17 +303,13 @@ QQuickGridLayoutBase::~QQuickGridLayoutBase() { Q_D(QQuickGridLayoutBase); - /* Avoid messy deconstruction, should give: - * Faster deconstruction - * Less risk of signals reaching already deleted objects - */ + // Remove item listeners so we do not act on signalling unnecessarily + // (there is no point, as the layout will be torn down anyway). for (int i = 0; i < itemCount(); ++i) { QQuickItem *item = itemAt(i); - qmlobject_disconnect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed())); - qmlobject_disconnect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged())); - qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitWidthChanged()), this, QQuickGridLayoutBase, SLOT(invalidateSenderItem())); - qmlobject_disconnect(item, QQuickItem, SIGNAL(implicitHeightChanged()), this, QQuickGridLayoutBase, SLOT(invalidateSenderItem())); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder | QQuickItemPrivate::ImplicitWidth | QQuickItemPrivate::ImplicitHeight | QQuickItemPrivate::Destroyed | QQuickItemPrivate::Visibility); } + delete d->styleInfo; } @@ -436,23 +432,6 @@ int QQuickGridLayoutBase::itemCount() const return d->engine.itemCount(); } -void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &value) -{ - if (change == ItemChildAddedChange) { - quickLayoutDebug() << "ItemChildAddedChange"; - QQuickItem *item = value.item; - qmlobject_connect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed())); - qmlobject_connect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged())); - } else if (change == ItemChildRemovedChange) { - quickLayoutDebug() << "ItemChildRemovedChange"; - QQuickItem *item = value.item; - qmlobject_disconnect(item, QQuickItem, SIGNAL(destroyed()), this, QQuickGridLayoutBase, SLOT(onItemDestroyed())); - qmlobject_disconnect(item, QQuickItem, SIGNAL(visibleChanged()), this, QQuickGridLayoutBase, SLOT(onItemVisibleChanged())); - } - - QQuickLayout::itemChange(change, value); -} - void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem) { Q_D(QQuickGridLayoutBase); @@ -461,28 +440,29 @@ void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem) d->engine.removeRows(index, 1, d->orientation); } -void QQuickGridLayoutBase::onItemVisibleChanged() -{ - if (!isReady()) - return; - quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged"; - updateLayoutItems(); -} - -void QQuickGridLayoutBase::onItemDestroyed() +void QQuickGridLayoutBase::itemDestroyed(QQuickItem *item) { if (!isReady()) return; Q_D(QQuickGridLayoutBase); - quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed"; - QQuickItem *inDestruction = static_cast(sender()); - if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(inDestruction)) { + quickLayoutDebug() << "QQuickGridLayoutBase::itemDestroyed"; + if (QQuickGridLayoutItem *gridItem = d->engine.findLayoutItem(item)) { removeGridItem(gridItem); delete gridItem; invalidate(); } } +void QQuickGridLayoutBase::itemVisibilityChanged(QQuickItem *item) +{ + Q_UNUSED(item); + + if (!isReady()) + return; + quickLayoutDebug() << "QQuickGridLayoutBase::itemVisibilityChanged"; + updateLayoutItems(); +} + void QQuickGridLayoutBase::rearrange(const QSizeF &size) { Q_D(QQuickGridLayoutBase); diff --git a/src/imports/layouts/qquicklinearlayout_p.h b/src/imports/layouts/qquicklinearlayout_p.h index 86404f8d79..c289416540 100644 --- a/src/imports/layouts/qquicklinearlayout_p.h +++ b/src/imports/layouts/qquicklinearlayout_p.h @@ -77,6 +77,10 @@ public: Qt::LayoutDirection effectiveLayoutDirection() const; void setAlignment(QQuickItem *item, Qt::Alignment align) Q_DECL_OVERRIDE; + /* QQuickItemChangeListener */ + void itemDestroyed(QQuickItem *item) Q_DECL_OVERRIDE; + void itemVisibilityChanged(QQuickItem *item) Q_DECL_OVERRIDE; + protected: void updateLayoutItems() Q_DECL_OVERRIDE; QQuickItem *itemAt(int index) const Q_DECL_OVERRIDE; @@ -84,15 +88,10 @@ protected: void rearrange(const QSizeF &size) Q_DECL_OVERRIDE; virtual void insertLayoutItems() {} - void itemChange(ItemChange change, const ItemChangeData &data) Q_DECL_OVERRIDE; signals: Q_REVISION(1) void layoutDirectionChanged(); -protected slots: - void onItemVisibleChanged(); - void onItemDestroyed(); - private: void removeGridItem(QGridLayoutItem *gridItem); Q_DECLARE_PRIVATE(QQuickGridLayoutBase) -- cgit v1.2.3 From 6ed23b91b949b7edaf96cdb0f2bba7b21a02de89 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Nov 2016 14:45:46 +0100 Subject: Fix support for namespaced types in property/signal declarations Declarations such as property Namespace.Item foo or property list foo would get rejected by the grammar due to the lack of productions. This is now encapsulated in the UiPropertyType, which used to be merely an identifier but is now changed to produce a UiQualifiedId - the same type that's also used for MyNamespace.Item { ... } object declarations for example. Task-number: QTBUG-10822 Change-Id: Ic3ac1adbe17c83b24b67950c2f089e267b73b99b Reviewed-by: Lars Knoll --- src/qml/compiler/qqmlirbuilder.cpp | 10 +- src/qml/parser/qqmljs.g | 60 +- src/qml/parser/qqmljsast_p.h | 12 +- src/qml/parser/qqmljsgrammar.cpp | 1804 ++++++++++---------- src/qml/parser/qqmljsgrammar_p.h | 12 +- src/qml/parser/qqmljsparser.cpp | 446 ++--- src/qml/parser/qqmljsparser_p.h | 4 +- tests/auto/qml/qmlmin/tst_qmlmin.cpp | 1 - .../data/dynamicObjectProperties.2.qml | 2 +- .../qqmllanguage/data/namespacedPropertyTypes.qml | 8 + tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 10 +- 11 files changed, 1210 insertions(+), 1159 deletions(-) create mode 100644 tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index eb83962630..c0f953ca2c 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -757,7 +757,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) QQmlJS::AST::UiParameterList *p = node->parameters; while (p) { - const QStringRef &memberType = p->type; + const QString memberType = asString(p->type); if (memberType.isEmpty()) { recordError(node->typeToken, QCoreApplication::translate("QQmlParser","Expected parameter type")); @@ -780,10 +780,10 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) // Must be a QML object type. // Lazily determine type during compilation. param->type = QV4::CompiledData::Property::Custom; - param->customTypeNameIndex = registerString(p->type.toString()); + param->customTypeNameIndex = registerString(memberType); } else { QString errStr = QCoreApplication::translate("QQmlParser","Invalid signal parameter type: "); - errStr.append(memberType.toString()); + errStr.append(memberType); recordError(node->typeToken, errStr); return false; } @@ -812,7 +812,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) return false; } } else { - const QStringRef &memberType = node->memberType; + QString memberType = asString(node->memberType); if (memberType == QLatin1String("alias")) { return appendAlias(node); } else { @@ -857,7 +857,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) property->flags |= QV4::CompiledData::Property::IsReadOnly; property->type = type; if (type >= QV4::CompiledData::Property::Custom) - property->customTypeNameIndex = registerString(memberType.toString()); + property->customTypeNameIndex = registerString(memberType); else property->customTypeNameIndex = emptyStringIndex; diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index a3ca9c44d0..9cd212015e 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -916,8 +916,40 @@ case $rule_number: ./ UiPropertyType: T_VAR ; +/. +case $rule_number: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + UiPropertyType: T_RESERVED_WORD ; +/. +case $rule_number: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + UiPropertyType: T_IDENTIFIER ; +/. +case $rule_number: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; +./ + +UiPropertyType: UiPropertyType T_DOT T_IDENTIFIER ; +/. +case $rule_number: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3)); + node->identifierToken = loc(3); + sym(1).Node = node; +} break; +./ UiParameterListOpt: ; /. @@ -936,7 +968,7 @@ case $rule_number: { UiParameterList: UiPropertyType JsIdentifier ; /. case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2)); node->propertyTypeToken = loc(1); node->identifierToken = loc(2); sym(1).Node = node; @@ -946,7 +978,7 @@ case $rule_number: { UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; /. case $rule_number: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4)); node->propertyTypeToken = loc(3); node->commaToken = loc(2); node->identifierToken = loc(4); @@ -958,7 +990,7 @@ UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_AUT UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2)); node->type = AST::UiPublicMember::Signal; node->propertyToken = loc(1); node->typeToken = loc(2); @@ -973,7 +1005,7 @@ UiObjectMember: T_SIGNAL T_IDENTIFIER T_AUTOMATIC_SEMICOLON ; UiObjectMember: T_SIGNAL T_IDENTIFIER T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2)); node->type = AST::UiPublicMember::Signal; node->propertyToken = loc(1); node->typeToken = loc(2); @@ -987,7 +1019,7 @@ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_ UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6)); node->typeModifier = stringRef(2); node->propertyToken = loc(1); node->typeModifierToken = loc(2); @@ -1002,7 +1034,7 @@ UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEMICOLON ; UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3)); node->propertyToken = loc(1); node->typeToken = loc(2); node->identifierToken = loc(3); @@ -1015,7 +1047,7 @@ UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_AUTOMATIC_SEM UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4)); node->isDefaultMember = true; node->defaultToken = loc(1); node->propertyToken = loc(2); @@ -1030,7 +1062,7 @@ UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIde UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_SEMICOLON ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(5), stringRef(7)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7)); node->isDefaultMember = true; node->defaultToken = loc(1); node->typeModifier = stringRef(3); @@ -1046,7 +1078,7 @@ case $rule_number: { UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3), sym(5).Statement); node->propertyToken = loc(1); node->typeToken = loc(2); @@ -1059,7 +1091,7 @@ case $rule_number: { UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement); node->isReadonlyMember = true; node->readonlyToken = loc(1); @@ -1074,7 +1106,7 @@ case $rule_number: { UiObjectMember: T_DEFAULT T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement); node->isDefaultMember = true; node->defaultToken = loc(1); @@ -1089,7 +1121,7 @@ case $rule_number: { UiObjectMember: T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6)); node->typeModifier = stringRef(2); node->propertyToken = loc(1); node->typeModifierToken = loc(2); @@ -1116,7 +1148,7 @@ case $rule_number: { UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3)); node->propertyToken = loc(1); node->typeToken = loc(2); node->identifierToken = loc(3); @@ -1139,7 +1171,7 @@ case $rule_number: { UiObjectMember: T_READONLY T_PROPERTY UiPropertyType JsIdentifier T_COLON UiQualifiedId UiObjectInitializer ; /. case $rule_number: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4)); node->isReadonlyMember = true; node->readonlyToken = loc(1); node->propertyToken = loc(2); diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index 2ca4e883d6..adb87c6c4e 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -2537,11 +2537,11 @@ class QML_PARSER_EXPORT UiParameterList: public Node public: QQMLJS_DECLARE_AST_NODE(UiParameterList) - UiParameterList(const QStringRef &t, const QStringRef &n): + UiParameterList(UiQualifiedId *t, const QStringRef &n): type (t), name (n), next (this) { kind = K; } - UiParameterList(UiParameterList *previous, const QStringRef &t, const QStringRef &n): + UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringRef &n): type (t), name (n) { kind = K; @@ -2565,7 +2565,7 @@ public: } // attributes - QStringRef type; + UiQualifiedId *type; QStringRef name; UiParameterList *next; SourceLocation commaToken; @@ -2578,12 +2578,12 @@ class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember public: QQMLJS_DECLARE_AST_NODE(UiPublicMember) - UiPublicMember(const QStringRef &memberType, + UiPublicMember(UiQualifiedId *memberType, const QStringRef &name) : type(Property), memberType(memberType), name(name), statement(0), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) { kind = K; } - UiPublicMember(const QStringRef &memberType, + UiPublicMember(UiQualifiedId *memberType, const QStringRef &name, Statement *statement) : type(Property), memberType(memberType), name(name), statement(statement), binding(0), isDefaultMember(false), isReadonlyMember(false), parameters(0) @@ -2614,7 +2614,7 @@ public: // attributes enum { Signal, Property } type; QStringRef typeModifier; - QStringRef memberType; + UiQualifiedId *memberType; QStringRef name; Statement *statement; // initialized with a JS expression UiObjectMember *binding; // initialized with a QML object or array. diff --git a/src/qml/parser/qqmljsgrammar.cpp b/src/qml/parser/qqmljsgrammar.cpp index fdcd94b472..b27f4af080 100644 --- a/src/qml/parser/qqmljsgrammar.cpp +++ b/src/qml/parser/qqmljsgrammar.cpp @@ -61,37 +61,38 @@ const short QQmlJSGrammar::lhs [] = { 118, 118, 118, 118, 118, 122, 123, 115, 114, 126, 126, 127, 127, 128, 128, 125, 111, 111, 111, 111, 130, 130, 130, 130, 130, 130, 130, 111, 138, 138, - 138, 139, 139, 140, 140, 111, 111, 111, 111, 111, + 138, 138, 139, 139, 140, 140, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, - 111, 111, 111, 111, 111, 124, 124, 124, 124, 124, - 124, 124, 143, 143, 143, 143, 143, 143, 143, 143, + 111, 111, 111, 111, 111, 111, 124, 124, 124, 124, + 124, 124, 124, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 129, 145, 145, 145, 145, 144, 144, 149, 149, 149, - 147, 147, 150, 150, 150, 150, 153, 153, 153, 153, + 143, 129, 145, 145, 145, 145, 144, 144, 149, 149, + 149, 147, 147, 150, 150, 150, 150, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 154, 154, 120, - 120, 120, 120, 120, 157, 157, 158, 158, 158, 158, - 156, 156, 159, 159, 160, 160, 161, 161, 161, 162, - 162, 162, 162, 162, 162, 162, 162, 162, 162, 163, - 163, 163, 163, 164, 164, 164, 165, 165, 165, 165, - 166, 166, 166, 166, 166, 166, 166, 167, 167, 167, - 167, 167, 167, 168, 168, 168, 168, 168, 169, 169, - 169, 169, 169, 170, 170, 171, 171, 172, 172, 173, - 173, 174, 174, 175, 175, 176, 176, 177, 177, 178, - 178, 179, 179, 180, 180, 181, 181, 148, 148, 182, - 182, 183, 183, 183, 183, 183, 183, 183, 183, 183, - 183, 183, 183, 109, 109, 184, 184, 185, 185, 186, - 186, 108, 108, 108, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 108, 131, 195, 195, 194, - 194, 142, 142, 196, 196, 197, 197, 199, 199, 198, - 200, 203, 201, 201, 204, 202, 202, 132, 133, 133, - 134, 134, 187, 187, 187, 187, 187, 187, 187, 187, - 188, 188, 188, 188, 189, 189, 189, 189, 190, 190, - 135, 136, 205, 205, 208, 208, 206, 206, 209, 207, - 191, 192, 192, 137, 137, 137, 210, 211, 193, 193, - 212, 141, 155, 155, 213, 213, 152, 152, 151, 151, - 214, 112, 112, 215, 215, 110, 110, 146, 146, 216}; + 153, 153, 153, 153, 153, 153, 153, 153, 154, 154, + 120, 120, 120, 120, 120, 157, 157, 158, 158, 158, + 158, 156, 156, 159, 159, 160, 160, 161, 161, 161, + 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, + 163, 163, 163, 163, 164, 164, 164, 165, 165, 165, + 165, 166, 166, 166, 166, 166, 166, 166, 167, 167, + 167, 167, 167, 167, 168, 168, 168, 168, 168, 169, + 169, 169, 169, 169, 170, 170, 171, 171, 172, 172, + 173, 173, 174, 174, 175, 175, 176, 176, 177, 177, + 178, 178, 179, 179, 180, 180, 181, 181, 148, 148, + 182, 182, 183, 183, 183, 183, 183, 183, 183, 183, + 183, 183, 183, 183, 109, 109, 184, 184, 185, 185, + 186, 186, 108, 108, 108, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 108, 131, 195, 195, + 194, 194, 142, 142, 196, 196, 197, 197, 199, 199, + 198, 200, 203, 201, 201, 204, 202, 202, 132, 133, + 133, 134, 134, 187, 187, 187, 187, 187, 187, 187, + 187, 188, 188, 188, 188, 189, 189, 189, 189, 190, + 190, 135, 136, 205, 205, 208, 208, 206, 206, 209, + 207, 191, 192, 192, 137, 137, 137, 210, 211, 193, + 193, 212, 141, 155, 155, 213, 213, 152, 152, 151, + 151, 214, 112, 112, 215, 215, 110, 110, 146, 146, + 216}; const short QQmlJSGrammar::rhs [] = { 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, @@ -99,113 +100,114 @@ const short QQmlJSGrammar::rhs [] = { 3, 5, 5, 4, 4, 2, 2, 0, 1, 1, 2, 1, 3, 2, 3, 2, 1, 5, 4, 4, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, - 1, 0, 1, 2, 4, 6, 6, 3, 3, 7, - 7, 4, 4, 5, 5, 8, 8, 5, 6, 6, - 10, 6, 7, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 3, 3, 4, 5, 3, 4, 3, - 1, 1, 2, 3, 4, 1, 2, 3, 7, 8, - 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 0, 1, 2, 4, 6, 6, 3, 3, + 7, 7, 4, 4, 5, 5, 8, 8, 5, 6, + 6, 10, 6, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 3, 3, 4, 5, 3, 4, + 3, 1, 1, 2, 3, 4, 1, 2, 3, 7, + 8, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 3, 5, 1, 2, 4, 4, 4, 3, - 0, 1, 1, 3, 1, 1, 1, 2, 2, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, - 3, 3, 3, 1, 3, 3, 1, 3, 3, 3, - 1, 3, 3, 3, 3, 3, 3, 1, 3, 3, - 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, - 3, 3, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 5, 1, 5, 1, 3, 1, - 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 0, 1, 1, 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 1, 2, 0, - 1, 3, 3, 1, 1, 1, 3, 1, 3, 2, - 2, 2, 0, 1, 2, 0, 1, 1, 2, 2, - 7, 5, 7, 7, 7, 5, 9, 10, 7, 8, - 2, 2, 3, 3, 2, 2, 3, 3, 3, 3, - 5, 5, 3, 5, 1, 2, 0, 1, 4, 3, - 3, 3, 3, 3, 3, 4, 5, 2, 2, 2, - 1, 8, 8, 7, 1, 3, 0, 1, 0, 1, - 1, 1, 1, 1, 2, 1, 1, 0, 1, 2}; + 1, 1, 4, 3, 5, 1, 2, 4, 4, 4, + 3, 0, 1, 1, 3, 1, 1, 1, 2, 2, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 1, 3, 3, 3, 1, 3, 3, 1, 3, 3, + 3, 1, 3, 3, 3, 3, 3, 3, 1, 3, + 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, + 3, 3, 3, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 5, 1, 5, 1, 3, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 0, 1, 1, 3, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, + 0, 1, 3, 3, 1, 1, 1, 3, 1, 3, + 2, 2, 2, 0, 1, 2, 0, 1, 1, 2, + 2, 7, 5, 7, 7, 7, 5, 9, 10, 7, + 8, 2, 2, 3, 3, 2, 2, 3, 3, 3, + 3, 5, 5, 3, 5, 1, 2, 0, 1, 4, + 3, 3, 3, 3, 3, 3, 4, 5, 2, 2, + 2, 1, 8, 8, 7, 1, 3, 0, 1, 0, + 1, 1, 1, 1, 1, 2, 1, 1, 0, 1, + 2}; const short QQmlJSGrammar::action_default [] = { - 0, 0, 28, 0, 0, 0, 28, 0, 187, 254, - 218, 226, 222, 166, 238, 214, 3, 151, 84, 167, - 230, 234, 155, 184, 165, 170, 150, 204, 191, 0, - 91, 92, 87, 0, 81, 76, 358, 0, 0, 0, - 0, 89, 0, 0, 85, 88, 80, 0, 0, 77, - 79, 82, 78, 90, 83, 0, 86, 0, 0, 180, - 0, 0, 167, 186, 169, 168, 0, 0, 0, 182, - 183, 181, 185, 0, 215, 0, 0, 0, 0, 205, - 0, 0, 0, 0, 0, 0, 195, 0, 0, 0, - 189, 190, 188, 193, 197, 196, 194, 192, 207, 206, - 208, 0, 223, 0, 219, 0, 0, 161, 148, 160, - 149, 117, 118, 119, 144, 120, 145, 121, 122, 123, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 146, 134, 135, 136, 137, 138, 139, 140, 141, 142, - 143, 147, 0, 0, 159, 255, 162, 0, 163, 0, - 164, 158, 0, 251, 244, 242, 249, 250, 248, 247, - 253, 246, 245, 243, 252, 239, 0, 227, 0, 0, - 231, 0, 0, 235, 0, 0, 161, 153, 0, 152, - 0, 157, 171, 0, 347, 347, 348, 0, 345, 0, - 346, 0, 349, 262, 269, 268, 276, 264, 0, 265, - 0, 350, 0, 357, 266, 267, 84, 272, 270, 354, - 351, 356, 273, 0, 284, 0, 0, 0, 0, 341, - 0, 358, 256, 298, 0, 0, 0, 285, 0, 0, - 274, 275, 0, 263, 271, 299, 300, 0, 347, 0, - 0, 349, 0, 342, 343, 0, 331, 355, 0, 315, - 316, 317, 318, 0, 311, 312, 313, 314, 339, 340, - 0, 0, 0, 0, 0, 303, 304, 305, 260, 258, - 220, 228, 224, 240, 216, 261, 0, 167, 232, 236, - 209, 198, 0, 0, 217, 0, 0, 0, 0, 210, - 0, 0, 0, 0, 0, 202, 200, 203, 201, 199, - 212, 211, 213, 0, 225, 0, 221, 0, 259, 167, - 0, 241, 256, 257, 0, 256, 0, 0, 307, 0, - 0, 0, 309, 0, 229, 0, 0, 233, 0, 0, - 237, 296, 0, 288, 297, 291, 0, 295, 0, 256, - 289, 0, 256, 0, 0, 308, 0, 0, 0, 310, - 0, 0, 0, 302, 0, 301, 84, 111, 359, 0, - 0, 116, 278, 281, 0, 117, 284, 120, 145, 122, - 123, 87, 127, 128, 81, 129, 132, 85, 88, 256, - 82, 90, 135, 83, 137, 86, 139, 140, 285, 142, - 143, 147, 0, 113, 112, 115, 99, 114, 98, 0, - 108, 279, 277, 0, 0, 0, 349, 0, 109, 155, - 156, 161, 0, 154, 0, 319, 320, 0, 347, 0, - 0, 349, 0, 110, 0, 0, 0, 322, 327, 325, - 328, 0, 0, 326, 327, 0, 323, 0, 324, 280, - 330, 0, 280, 329, 0, 332, 333, 0, 280, 334, - 335, 0, 0, 336, 0, 0, 0, 337, 338, 173, - 172, 0, 0, 0, 306, 0, 0, 0, 321, 293, - 286, 0, 294, 290, 0, 292, 282, 0, 283, 287, - 0, 0, 349, 0, 344, 102, 0, 0, 106, 93, - 0, 95, 104, 0, 96, 105, 107, 97, 103, 94, - 0, 100, 177, 175, 179, 176, 174, 178, 352, 6, - 353, 4, 2, 74, 101, 0, 0, 77, 79, 78, - 37, 5, 0, 75, 0, 51, 50, 49, 0, 0, - 51, 0, 0, 0, 66, 67, 0, 64, 0, 65, - 41, 42, 43, 44, 46, 47, 70, 45, 0, 51, - 0, 0, 0, 0, 0, 60, 0, 61, 0, 0, - 32, 0, 0, 71, 33, 0, 36, 34, 30, 0, - 35, 31, 0, 62, 0, 63, 155, 0, 68, 72, - 0, 0, 0, 0, 155, 280, 0, 69, 84, 117, - 284, 120, 145, 122, 123, 87, 127, 128, 129, 132, - 85, 88, 256, 90, 135, 83, 137, 86, 139, 140, - 285, 142, 143, 147, 73, 0, 58, 52, 59, 53, - 0, 0, 0, 0, 55, 0, 56, 57, 54, 0, - 0, 0, 0, 48, 0, 38, 39, 0, 40, 8, - 0, 0, 9, 0, 11, 0, 10, 0, 1, 27, - 15, 14, 26, 13, 12, 29, 7, 0, 18, 0, - 19, 0, 24, 25, 0, 20, 21, 0, 22, 23, - 16, 17, 360}; + 0, 0, 28, 0, 0, 0, 28, 0, 188, 255, + 219, 227, 223, 167, 239, 215, 3, 152, 85, 168, + 231, 235, 156, 185, 166, 171, 151, 205, 192, 0, + 92, 93, 88, 0, 82, 77, 359, 0, 0, 0, + 0, 90, 0, 0, 86, 89, 81, 0, 0, 78, + 80, 83, 79, 91, 84, 0, 87, 0, 0, 181, + 0, 0, 168, 187, 170, 169, 0, 0, 0, 183, + 184, 182, 186, 0, 216, 0, 0, 0, 0, 206, + 0, 0, 0, 0, 0, 0, 196, 0, 0, 0, + 190, 191, 189, 194, 198, 197, 195, 193, 208, 207, + 209, 0, 224, 0, 220, 0, 0, 162, 149, 161, + 150, 118, 119, 120, 145, 121, 146, 122, 123, 124, + 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 147, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 148, 0, 0, 160, 256, 163, 0, 164, 0, + 165, 159, 0, 252, 245, 243, 250, 251, 249, 248, + 254, 247, 246, 244, 253, 240, 0, 228, 0, 0, + 232, 0, 0, 236, 0, 0, 162, 154, 0, 153, + 0, 158, 172, 0, 348, 348, 349, 0, 346, 0, + 347, 0, 350, 263, 270, 269, 277, 265, 0, 266, + 0, 351, 0, 358, 267, 268, 85, 273, 271, 355, + 352, 357, 274, 0, 285, 0, 0, 0, 0, 342, + 0, 359, 257, 299, 0, 0, 0, 286, 0, 0, + 275, 276, 0, 264, 272, 300, 301, 0, 348, 0, + 0, 350, 0, 343, 344, 0, 332, 356, 0, 316, + 317, 318, 319, 0, 312, 313, 314, 315, 340, 341, + 0, 0, 0, 0, 0, 304, 305, 306, 261, 259, + 221, 229, 225, 241, 217, 262, 0, 168, 233, 237, + 210, 199, 0, 0, 218, 0, 0, 0, 0, 211, + 0, 0, 0, 0, 0, 203, 201, 204, 202, 200, + 213, 212, 214, 0, 226, 0, 222, 0, 260, 168, + 0, 242, 257, 258, 0, 257, 0, 0, 308, 0, + 0, 0, 310, 0, 230, 0, 0, 234, 0, 0, + 238, 297, 0, 289, 298, 292, 0, 296, 0, 257, + 290, 0, 257, 0, 0, 309, 0, 0, 0, 311, + 0, 0, 0, 303, 0, 302, 85, 112, 360, 0, + 0, 117, 279, 282, 0, 118, 285, 121, 146, 123, + 124, 88, 128, 129, 82, 130, 133, 86, 89, 257, + 83, 91, 136, 84, 138, 87, 140, 141, 286, 143, + 144, 148, 0, 114, 113, 116, 100, 115, 99, 0, + 109, 280, 278, 0, 0, 0, 350, 0, 110, 156, + 157, 162, 0, 155, 0, 320, 321, 0, 348, 0, + 0, 350, 0, 111, 0, 0, 0, 323, 328, 326, + 329, 0, 0, 327, 328, 0, 324, 0, 325, 281, + 331, 0, 281, 330, 0, 333, 334, 0, 281, 335, + 336, 0, 0, 337, 0, 0, 0, 338, 339, 174, + 173, 0, 0, 0, 307, 0, 0, 0, 322, 294, + 287, 0, 295, 291, 0, 293, 283, 0, 284, 288, + 0, 0, 350, 0, 345, 103, 0, 0, 107, 94, + 0, 96, 105, 0, 97, 106, 108, 98, 104, 95, + 0, 101, 178, 176, 180, 177, 175, 179, 353, 6, + 354, 4, 2, 75, 102, 0, 0, 78, 80, 79, + 37, 5, 0, 76, 0, 51, 50, 49, 0, 0, + 51, 0, 0, 0, 52, 0, 67, 68, 0, 65, + 0, 66, 41, 42, 43, 44, 46, 47, 71, 45, + 0, 51, 0, 0, 0, 0, 0, 61, 0, 62, + 0, 0, 32, 0, 0, 72, 33, 0, 36, 34, + 30, 0, 35, 31, 0, 63, 0, 64, 156, 0, + 69, 73, 0, 0, 0, 0, 156, 281, 0, 70, + 85, 118, 285, 121, 146, 123, 124, 88, 128, 129, + 130, 133, 86, 89, 257, 91, 136, 84, 138, 87, + 140, 141, 286, 143, 144, 148, 74, 0, 59, 53, + 60, 54, 0, 0, 0, 0, 56, 0, 57, 58, + 55, 0, 0, 0, 0, 48, 0, 38, 39, 0, + 40, 8, 0, 0, 9, 0, 11, 0, 10, 0, + 1, 27, 15, 14, 26, 13, 12, 29, 7, 0, + 18, 0, 19, 0, 24, 25, 0, 20, 21, 0, + 22, 23, 16, 17, 361}; const short QQmlJSGrammar::goto_default [] = { - 7, 648, 211, 198, 209, 521, 509, 643, 656, 508, - 642, 646, 644, 652, 22, 649, 647, 645, 18, 520, - 569, 559, 566, 561, 546, 193, 197, 199, 204, 234, - 212, 231, 550, 620, 619, 203, 233, 26, 487, 486, + 7, 650, 211, 198, 209, 521, 509, 645, 658, 508, + 644, 648, 646, 654, 22, 651, 649, 647, 18, 520, + 571, 561, 568, 563, 548, 193, 197, 199, 204, 234, + 212, 231, 552, 622, 621, 203, 233, 26, 487, 486, 359, 358, 9, 357, 360, 202, 480, 361, 109, 17, 147, 24, 13, 146, 19, 25, 59, 23, 8, 28, 27, 280, 15, 274, 10, 270, 12, 272, 11, 271, @@ -216,896 +218,874 @@ const short QQmlJSGrammar::goto_default [] = { 0}; const short QQmlJSGrammar::action_index [] = { - 282, 1392, 2773, 2773, 2875, 1105, 102, 105, 129, -106, - -1, 23, -23, 224, -106, 378, 26, -106, -106, 718, - 39, 87, 207, 222, -106, -106, -106, 342, 290, 1392, - -106, -106, -106, 502, -106, -106, 2569, 1880, 1392, 1392, - 1392, -106, 1009, 1392, -106, -106, -106, 1392, 1392, -106, - -106, -106, -106, -106, -106, 1392, -106, 1392, 1392, -106, - 1392, 1392, 97, 236, -106, -106, 1392, 1392, 1392, -106, - -106, -106, 233, 1392, 378, 1392, 1392, 1392, 1392, 461, - 1392, 1392, 1392, 1392, 1392, 1392, 290, 1392, 1392, 1392, - 144, 124, 115, 290, 290, 290, 290, 290, 461, 461, - 363, 1392, -78, 1392, 81, 2365, 1392, 1392, -106, -106, + 246, 1285, 2768, 2768, 2666, 998, 98, 198, 86, -106, + 26, -15, -39, 234, -106, 314, 54, -106, -106, 714, + 89, 151, 212, 219, -106, -106, -106, 412, 279, 1285, + -106, -106, -106, 525, -106, -106, 2360, 1675, 1285, 1285, + 1285, -106, 902, 1285, -106, -106, -106, 1285, 1285, -106, + -106, -106, -106, -106, -106, 1285, -106, 1285, 1285, -106, + 1285, 1285, 103, 197, -106, -106, 1285, 1285, 1285, -106, + -106, -106, 214, 1285, 297, 1285, 1285, 1285, 1285, 392, + 1285, 1285, 1285, 1285, 1285, 1285, 213, 1285, 1285, 1285, + 96, 100, 101, 279, 279, 195, 190, 181, 402, 372, + 382, 1285, -10, 1285, 106, 2258, 1285, 1285, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, -106, - -106, -106, 143, 1392, -106, -106, 78, 60, -106, 1392, - -106, -106, 1392, -106, -106, -106, -106, -106, -106, -106, - -106, -106, -106, -106, -106, -106, 1392, -25, 1392, 1392, - 92, 85, 1392, -106, 2365, 1392, 1392, -106, 146, -106, - 46, -106, -106, 52, 359, 362, 104, 86, -106, 438, - -106, 56, 2773, -106, -106, -106, -106, -106, 164, -106, - 393, -106, 41, -106, -106, -106, 53, -106, -106, -106, - 2773, -106, -106, 600, -106, 597, 147, 2875, 64, 82, - 48, 3079, 1392, -106, 90, 1392, 66, -106, 33, 68, - -106, -106, 538, -106, -106, -106, -106, 88, 538, 35, - 40, 2773, 47, -106, -106, 2875, -106, -106, 151, -106, - -106, -106, -106, 145, -106, -106, -106, -106, -106, -106, - 72, 65, 1392, 107, 155, -106, -106, -106, 1586, -106, - 58, 59, 50, -106, 279, 75, 62, 821, 89, 93, - 295, 234, 447, 1392, 291, 1392, 1392, 1392, 1392, 316, - 1392, 1392, 1392, 1392, 1392, 290, 290, 290, 290, 290, - 322, 326, 332, 1392, 50, 1392, 74, 1392, -106, 718, - 1392, -106, 1392, 55, 42, 1392, 38, 2875, -106, 1392, - 132, 2875, -106, 1392, 84, 1392, 1392, 209, 106, 1392, - -106, 80, 130, 77, -106, -106, 1392, -106, 407, 1392, - -106, -48, 1392, -43, 2875, -106, 1392, 126, 2875, -106, - 1392, 128, 2875, 3, 2875, -106, 8, -106, 6, -34, - 15, -106, -106, 2875, -31, 615, 18, 546, 100, 1392, - 2875, 19, -8, 493, 2467, -16, 707, 5, 4, 1491, - 2467, 2, -28, 0, 1392, -2, -30, 1392, -5, 1392, - -32, -26, 2671, -106, -106, -106, -106, -106, -106, 1392, - -106, -106, -106, 21, -17, 22, 2773, -6, -106, 206, - -106, 1392, -10, -106, 91, -106, -106, 17, 538, 30, - 31, 2773, -3, -106, 1392, 111, 34, -106, 24, -106, - 25, 101, 1392, -106, 27, 28, -106, -22, -106, 2875, - -106, 120, 2875, -106, 227, -106, -106, 125, 2875, 16, - -106, 12, 13, -106, 453, -20, 14, -106, -106, -106, - -106, 1392, 160, 2875, -106, 1392, 113, 2875, -106, 37, - -106, 171, -106, -106, 1392, -106, -106, 441, -106, -106, - -33, -27, 2773, -4, -106, -106, 109, 1684, -106, -106, - 1978, -106, -106, 1782, -106, -106, -106, -106, -106, -106, - 127, -106, -106, -106, -106, -106, -106, -106, -106, -106, - 2773, -106, -106, -106, 148, -24, 915, 176, -29, 10, - -106, -106, 240, -106, 208, 1, -106, -106, 349, 195, - -106, 20, 339, 135, -106, -106, 191, -106, 2073, -106, - -106, -106, -106, -106, -106, -106, -106, -106, 221, 29, - 538, 152, 7, 538, 167, -106, 11, -106, 915, 114, - -106, 32, 915, -106, -106, 1201, -106, -106, -106, 1297, - -106, -106, 169, -106, 2073, -106, 280, -15, -106, -106, - 181, 457, 9, 2263, 271, 2977, 83, -106, 103, 615, - 67, 557, 116, 1392, 2875, 61, 43, 526, 45, 1009, - 51, 73, 1491, 71, 49, 69, 1392, 63, 44, 1392, - 54, 1392, 36, 57, -106, 213, -106, 217, -106, 79, - 70, 343, 194, 346, -106, 96, -106, -106, -106, 2168, - 799, 1880, 76, -106, 134, -106, -106, -15, -106, -106, - 915, 915, 112, 915, -106, 259, -106, 153, -106, -106, - 110, 99, -106, -106, -106, -106, -106, 450, -106, 157, - -106, 98, -106, -106, 538, -106, -106, 139, -106, -106, - -106, -106, -106, + -106, -106, 136, 1285, -106, -106, 65, 29, -106, 1285, + -106, -106, 1285, -106, -106, -106, -106, -106, -106, -106, + -106, -106, -106, -106, -106, -106, 1285, -46, 1285, 1285, + 30, 27, 1285, -106, 2258, 1285, 1285, -106, 130, -106, + -31, -106, -106, -16, 520, 520, 71, 21, -106, 421, + -106, 38, 2768, -106, -106, -106, -106, -106, 237, -106, + 520, -106, -52, -106, -106, -106, 23, -106, -106, -106, + 2768, -106, -106, 596, -106, 588, 141, 2666, 2, 1, + -1, 2972, 1285, -106, 13, 1285, 28, -106, -28, -30, + -106, -106, 435, -106, -106, -106, -106, 60, 520, 52, + 67, 2768, 64, -106, -106, 2666, -106, -106, 126, -106, + -106, -106, -106, 73, -106, -106, -106, -106, -106, -106, + -18, 34, 1285, 156, 168, -106, -106, -106, 1479, -106, + 79, 40, 48, -106, 312, 75, 42, 672, 80, 143, + 331, 279, 442, 1285, 316, 1285, 1285, 1285, 1285, 341, + 1285, 1285, 1285, 1285, 1285, 279, 360, 360, 196, 225, + 443, 357, 351, 1285, -4, 1285, 63, 1285, -106, 714, + 1285, -106, 1285, 102, 68, 1285, 62, 2666, -106, 1285, + 147, 2666, -106, 1285, 56, 1285, 1285, 91, 87, 1285, + -106, 81, 149, 74, -106, -106, 1285, -106, 439, 1285, + -106, -44, 1285, -42, 2666, -106, 1285, 153, 2666, -106, + 1285, 154, 2666, 10, 2666, -106, 0, -106, 15, -54, + 92, -106, -106, 2666, -50, 539, -7, 536, 121, 1285, + 2666, 5, -8, 445, 2462, 24, 902, 51, 50, 1384, + 2462, 47, 20, 46, 1285, 44, 19, 1285, 41, 1285, + 3, -5, 2564, -106, -106, -106, -106, -106, -106, 1285, + -106, -106, -106, 6, -17, 11, 2768, -9, -106, 249, + -106, 1285, -13, -106, 105, -106, -106, -12, 520, -41, + -20, 2768, -45, -106, 1285, 115, 12, -106, 36, -106, + 31, 122, 1285, -106, 58, 4, -106, -51, -106, 2666, + -106, 146, 2666, -106, 235, -106, -106, 140, 2666, 93, + -106, 84, 76, -106, 520, 17, 33, -106, -106, -106, + -106, 1285, 134, 2666, -106, 1285, 125, 2666, -106, 55, + -106, 163, -106, -106, 1285, -106, -106, 520, -106, -106, + 7, 45, 2768, 32, -106, -106, 120, 1773, -106, -106, + 1577, -106, -106, 1871, -106, -106, -106, -106, -106, -106, + 113, -106, -106, -106, -106, -106, -106, -106, -106, -106, + 2768, -106, -106, -106, 109, 35, 808, 206, 49, 61, + -106, -106, 229, -106, 203, 37, -106, -106, 611, 183, + -106, 124, 39, 389, -106, 97, -106, -106, 252, -106, + 2061, -106, -106, -106, -106, -106, -106, -106, -106, -106, + 269, -23, 611, 243, 180, 424, 232, -106, 16, -106, + 808, 162, -106, 22, 808, -106, -106, 1190, -106, -106, + -106, 1094, -106, -106, 248, -106, 2061, -106, 305, -24, + -106, -106, 215, 457, 18, 2156, 292, 2870, -11, -106, + 14, 599, 9, 528, 119, 1285, 2666, 8, 70, 514, + 72, 902, 95, 90, 1384, 85, 59, 77, 1285, 110, + 83, 1285, 104, 1285, 82, 78, -106, 205, -106, 236, + -106, 57, 25, 611, 167, 517, -106, 107, -106, -106, + -106, 1966, 808, 1675, 43, -106, 155, -106, -106, 53, + -106, -106, 808, 808, 108, 808, -106, 289, -106, 117, + -106, -106, 150, 157, -106, -106, -106, -106, -106, 364, + -106, 226, -106, 69, -106, -106, 432, -106, -106, 88, + -106, -106, -106, -106, -106, - -111, 6, 66, 84, 80, 306, 43, -111, -111, -111, - -111, -111, -111, -111, -111, -111, -111, -111, -111, -23, + -111, 8, 65, 83, 84, 317, 1, -111, -111, -111, + -111, -111, -111, -111, -111, -111, -111, -111, -111, -77, -111, -111, -111, -111, -111, -111, -111, -111, -111, 96, - -111, -111, -111, 51, -111, -111, 60, 35, 61, 95, - 92, -111, 93, 72, -111, -111, -111, 86, 85, -111, - -111, -111, -111, -111, -111, 82, -111, 81, 136, -111, - 77, 76, -111, -111, -111, -111, 73, 89, 127, -111, - -111, -111, -111, 125, -111, 124, 54, 120, 99, -111, - 113, 111, 110, 109, 107, 103, -111, 102, 100, 119, - -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, 52, -111, 49, -111, 62, 44, 28, -111, -111, + -111, -111, -111, 2, -111, -111, -5, -28, 12, 106, + 95, -111, 61, 55, -111, -111, -111, 63, 70, -111, + -111, -111, -111, -111, -111, 54, -111, 172, 177, -111, + 180, 191, -111, -111, -111, -111, 197, 202, 203, -111, + -111, -111, -111, 210, -111, 209, 195, 109, 116, -111, + 146, 125, 126, 127, 135, 138, -111, 141, 144, 110, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, + -111, 150, -111, 155, -111, 192, 4, -33, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, 25, -111, -111, -111, -111, -111, 18, - -111, -111, 16, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, -111, -111, -111, 57, -111, 40, 13, - -111, -111, 4, -111, 269, 42, 70, -111, -111, -111, - -111, -111, -111, -111, 26, 69, -111, -111, -111, 22, - -111, -111, 15, -111, -111, -111, -111, -111, -111, -111, - 14, -111, -111, -111, -111, -111, -111, -111, -111, -111, - 75, -111, -111, 10, -111, 32, -111, 74, -111, 24, - -111, 225, 46, -111, -111, 50, 41, -111, -111, -111, - -111, -111, 47, -111, -111, -111, -111, -111, 214, -111, - -111, 224, -111, -111, -111, 246, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, 27, -111, -111, -111, -111, -111, 117, -111, + -111, -111, -111, -9, -111, -111, -111, -111, -111, 7, + -111, -111, 40, -111, -111, -111, -111, -111, -111, -111, + -111, -111, -111, -111, -111, -111, 99, -111, 52, 31, + -111, -111, 30, -111, 253, 44, 87, -111, -111, -111, + -111, -111, -111, -111, 45, 86, -111, -111, -111, 41, + -111, -111, 5, -111, -111, -111, -111, -111, -111, -111, + 50, -111, -111, -111, -111, -111, -111, -111, -111, -111, + 154, -111, -111, 26, -111, 49, -111, 330, -111, 28, + -111, 248, 27, -111, -111, 124, 51, -111, -111, -111, + -111, -111, 46, -111, -111, -111, -111, -111, 196, -111, + -111, 185, -111, -111, -111, 194, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, 17, 236, -111, 239, 242, 250, 254, -111, - 199, 171, 200, 202, 203, -111, -111, -111, -111, -111, - -111, -111, -111, 264, -111, 265, -111, 213, -111, -111, - 267, -111, 260, -111, -111, 262, -111, 253, -111, 45, - -111, 83, -111, 222, -111, 223, 226, -111, -111, 229, - -111, -111, -111, -111, -111, -111, 238, -111, 105, 118, - -111, -111, 129, -111, 87, -111, 36, -111, 183, -111, - 34, -111, 187, -111, 192, -111, -111, -111, -111, -111, - -111, -111, -111, 193, -111, 9, -111, 23, -111, 144, - 195, -111, -111, 20, 184, -111, 189, -111, -111, 31, - 164, -111, -111, -111, 21, -111, 11, 158, -111, 161, - -111, -111, 188, -111, -111, -111, -111, -111, -111, 33, - -111, -111, -111, -111, -111, -111, 191, -111, -111, -111, - -111, 176, -111, -111, -111, -111, -111, -111, 198, -111, - -111, 201, -111, -111, 65, -111, -111, -111, -111, -111, - -29, -111, 58, -111, -27, -111, -111, -111, -111, 268, - -111, -111, 266, -111, -111, -111, -111, -111, 219, -46, - -111, -111, 38, -111, 39, -111, 37, -111, -111, -111, - -111, 53, -111, 220, -111, 48, -111, 221, -111, -111, - -111, -111, -111, -111, 30, -111, -111, 137, -111, -111, - -111, -111, 206, -111, -111, -111, -111, 29, -111, -111, - 207, -111, -111, 1, -111, -111, -111, -111, -111, -111, + -111, -111, 15, -111, -111, -111, -111, -111, 74, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - 216, -111, -111, -111, -111, -111, 0, -111, -111, -111, - -111, -111, -111, -111, -30, -111, -111, -111, -11, -13, - -111, -111, 5, -111, -111, -111, -111, -111, 336, -111, + -111, -111, -16, 230, -111, 233, 269, 251, 265, -111, + 80, 81, 82, 88, 89, -111, -111, -111, -111, -111, + -111, -111, -111, 216, -111, 255, -111, 259, -111, -111, + 223, -111, 68, -111, -111, 217, -111, 236, -111, 24, + -111, 244, -111, 227, -111, 226, 257, -111, -111, 263, + -111, -111, -111, -111, -111, -111, 249, -111, 113, 163, + -111, -111, 212, -111, 173, -111, 48, -111, 211, -111, + 53, -111, 206, -111, 204, -111, -111, -111, -111, -111, + -111, -111, -111, 199, -111, 23, -111, 25, -111, 134, + 175, -111, -111, 37, 200, -111, 222, -111, -111, 57, + 56, -111, -111, -111, 124, -111, 32, 43, -111, 105, + -111, -111, 139, -111, -111, -111, -111, -111, -111, 38, + -111, -111, -111, -111, -111, -111, 75, -111, -111, -111, + -111, 71, -111, -111, -111, -111, -111, -111, 72, -111, + -111, 85, -111, -111, 59, -111, -111, -111, -111, -111, + -37, -111, 62, -111, -58, -111, -111, -111, -111, 286, + -111, -111, 250, -111, -111, -111, -111, -111, 153, -57, + -111, -111, 33, -111, 34, -111, 36, -111, -111, -111, + -111, 47, -111, 77, -111, 29, -111, 67, -111, -111, + -111, -111, -111, -111, 42, -111, -111, 214, -111, -111, + -111, -111, 229, -111, -111, -111, -111, 35, -111, -111, + 145, -111, -111, 3, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - 7, -3, -111, -8, -111, -111, -111, -111, 174, -111, - -111, -111, 172, -111, -111, 323, -111, -111, -111, 334, - -111, -111, -111, -111, 372, -111, -111, -5, -111, -111, - -24, -7, -111, 439, -111, 248, -9, -111, -111, 8, - -111, -17, -111, 179, 342, -111, -111, 2, -111, 190, - -111, -111, 19, -111, -111, -111, 12, -111, -20, 68, - -111, 63, -111, -111, -111, -111, -111, -26, -111, -111, - -111, 3, -1, 79, -111, -111, -111, -111, -111, 354, - 67, 313, -4, -111, -111, -111, -111, -19, -111, -111, - -14, -10, 88, 233, -111, -111, -111, -111, -111, -111, - -111, -111, -111, -111, -111, -111, -111, -6, -111, -111, - -111, -111, -111, -111, -2, -111, -111, -111, -111, -111, - -111, -111, -111}; + 207, -111, -111, -111, -111, -111, 39, -111, -111, -111, + -111, -111, -111, -111, -24, -111, -111, -111, -12, -27, + -111, -111, -111, -14, -111, -111, -111, -111, -111, -111, + 333, -111, -111, -111, -111, -111, -111, -111, -111, -111, + -111, -111, 6, 22, -111, 20, -111, -111, -111, -111, + 159, -111, -111, -111, 246, -111, -111, 332, -111, -111, + -111, 436, -111, -111, -111, -111, 388, -111, -111, 18, + -111, -111, -6, 19, -111, 352, -111, 225, 14, -111, + -111, 13, -111, 11, -111, 167, 136, -111, -111, 10, + -111, 64, -111, -111, 9, -111, -111, -111, 124, -111, + 0, 69, -111, 60, -111, -111, -111, -111, -111, -10, + -111, -111, -111, -1, -11, -2, -111, -111, -111, -111, + -111, 370, 142, 315, -3, -111, -111, -111, -111, 17, + -111, -111, -13, 21, 133, 221, -111, -111, -111, -111, + -111, -111, -111, -111, -111, -111, -111, -111, -111, 16, + -111, -111, -111, -111, -111, -111, -15, -111, -111, -111, + -111, -111, -111, -111, -111}; const short QQmlJSGrammar::action_info [] = { - 73, 103, -141, 448, 461, -138, 482, -136, 424, -114, - 465, -115, -133, 342, 392, 245, 583, 344, 565, 354, - 350, 398, 399, 101, 402, -144, -125, 481, 268, 432, - 432, 553, 432, 438, 143, 439, 452, 580, 529, 615, - 456, 166, 524, 405, 532, 558, 448, 448, 454, 408, - 413, 484, 423, 418, 474, 406, 103, 404, -133, 283, - 245, -141, 0, 143, 421, 565, 551, 428, -125, 461, - -138, 101, 461, 241, -144, 283, -136, 448, -114, 268, - -115, 350, 73, 307, 350, 424, 149, 622, 185, 192, - 420, 323, 172, 465, 166, 240, 244, 336, 317, 448, - 268, 262, 243, 315, 465, 672, 181, 303, 346, 565, - 245, 435, 189, 329, 174, 143, 565, 490, 184, 143, - 151, 143, 562, 312, 238, 174, 424, 442, 143, 305, - 625, 451, 303, 175, 143, 143, 143, 168, 338, 64, - 143, 169, 562, 325, 175, 452, 191, 326, 0, 261, - 65, 143, 416, 415, 143, 60, 436, 627, 626, 663, - 662, 259, 258, 174, 60, 491, 61, 264, 143, 60, - 563, 426, 143, 467, 556, 61, 574, 259, 258, 477, - 61, 530, 175, 0, 60, 0, 348, 501, 352, 0, - 635, 339, 321, 640, 641, 61, 535, 534, 538, 144, - 669, 668, 179, 640, 641, 549, 257, 256, 259, 258, - 530, 323, 252, 251, 671, 670, 267, 265, 666, 665, - 463, 174, 174, 530, 530, 236, 235, 527, 557, 555, - 575, 573, 478, 476, 66, 143, 174, 525, 526, 105, - 175, 175, 411, 176, 266, 66, 530, 629, 66, 617, - 664, 527, 539, 537, 0, 175, 527, 411, 106, 87, - 107, 88, 526, 0, 0, 0, 0, 526, 0, 527, - 527, 0, 89, 565, 618, 616, 0, 0, 0, 67, - 526, 526, 0, 527, 0, 68, 174, 0, 446, 445, - 67, 0, 527, 67, 526, 174, 68, 285, 286, 68, - 0, 0, 0, 526, -101, 175, 659, 176, 0, 285, - 286, 0, 0, -101, 175, 87, 176, 88, 290, 291, - 660, 658, 0, 0, 287, 288, 0, 292, 89, 0, - 293, 0, 294, 0, 630, 0, 287, 288, 0, 290, - 291, 0, 0, 0, 0, 290, 291, 0, 292, 290, - 291, 293, 657, 294, 292, 290, 291, 293, 292, 294, - 0, 293, 0, 294, 292, 80, 81, 293, 35, 294, - 0, 0, 35, 82, 83, 35, 0, 84, 35, 85, - 6, 5, 4, 1, 3, 2, 80, 81, 35, 0, - 0, 35, 0, 0, 82, 83, 75, 76, 84, 0, - 85, 0, 0, 0, 0, 49, 52, 50, 0, 49, - 52, 50, 49, 52, 50, 49, 52, 50, 0, 0, - 0, 0, 35, 77, 78, 49, 52, 50, 49, 52, - 50, 0, 0, 46, 34, 51, 35, 46, 34, 51, + -145, 398, 101, 244, 438, 402, 465, 245, 461, 567, + 423, 439, -126, 421, 553, -126, -145, 342, 344, 420, + 185, 245, 567, 392, 418, 585, 354, 73, 268, 181, + 245, 465, 166, 101, 172, 350, 432, 184, 268, 461, + 103, 432, 404, 405, 406, 428, 408, 413, -142, 424, + 560, -139, 448, -137, -115, 567, 424, -116, -134, 261, + 350, 448, 143, 432, 283, 624, 448, 481, 534, 103, + 262, 192, 474, 149, 529, 305, 567, 456, 482, 189, + 283, 191, 323, 307, -137, 627, 567, 484, 303, 151, + 617, 166, -115, 323, 329, 424, 238, -116, 336, 399, + 241, 524, -134, 312, 303, 346, 268, 73, 350, 448, + 143, -142, 240, 452, 465, 582, 448, -139, 461, 243, + 454, 143, 317, 143, 174, 0, 60, 305, 490, 315, + 665, 664, 435, 143, 257, 256, 60, 61, 143, 532, + 60, 60, 143, 175, 143, 64, 451, 61, 533, 671, + 670, 61, 61, 442, 143, 143, 65, 338, 537, 536, + 452, 143, 143, 564, 143, 174, 416, 415, 629, 628, + 564, 477, 174, 501, 0, 426, 491, 436, 673, 672, + 259, 258, 259, 258, 175, 467, 179, 252, 251, 642, + 643, 175, 144, 325, 463, 532, 530, 326, 674, 642, + 643, 168, 259, 258, 555, 169, 87, 321, 88, 66, + 339, 637, 530, 348, 352, 87, 264, 88, 565, 89, + 87, 87, 88, 88, 478, 476, 66, 174, 89, 267, + 265, 66, 525, 89, 89, 551, 631, 0, 87, 558, + 88, 619, 527, 143, 530, 143, 175, 0, 176, 105, + 87, 89, 88, 526, 67, 576, 0, 266, 527, 540, + 68, 0, 567, 89, 174, 530, 620, 618, 106, 526, + 107, 67, 530, 0, 0, 0, 67, 68, 527, 0, + 0, 527, 68, 175, 174, 411, 0, 668, 667, 526, + 527, 0, 526, 559, 557, 0, 446, 445, 236, 235, + 0, 526, 0, 175, 87, 411, 88, 174, 0, 577, + 575, 527, 0, 541, 539, 75, 76, 89, 527, 666, + 174, 0, 526, 632, 0, -102, 175, 0, 176, 526, + 285, 286, 75, 76, 285, 286, 661, 0, -102, 175, + 0, 176, 77, 78, 6, 5, 4, 1, 3, 2, + 662, 660, 0, 0, 290, 291, 0, 287, 288, 77, + 78, 287, 288, 292, 290, 291, 293, 0, 294, 0, + 0, 0, 0, 292, 290, 291, 293, 0, 294, 0, + 290, 291, 659, 292, 0, 87, 293, 88, 294, 292, + 0, 0, 293, 35, 294, 80, 81, 0, 89, 0, + 0, 0, 0, 82, 83, 80, 81, 84, 0, 85, + 0, 0, 0, 82, 83, 80, 81, 84, 35, 85, + 0, 0, 0, 82, 83, 80, 81, 84, 0, 85, + 49, 52, 50, 82, 83, 80, 81, 84, 0, 85, + 0, 0, 0, 82, 83, 0, 0, 84, 0, 85, + 35, 0, 0, 35, 0, 49, 52, 50, 46, 34, + 51, 35, 0, 0, 35, 0, 290, 291, 35, 0, + 0, 35, 532, 0, 35, 292, 0, 0, 293, 0, + 294, 184, 0, 46, 34, 51, 35, 49, 52, 50, + 49, 52, 50, 0, 0, 0, 0, 0, 49, 52, + 50, 49, 52, 50, 0, 49, 52, 50, 49, 52, + 50, 49, 52, 50, 0, 46, 34, 51, 46, 34, + 51, 0, 0, 49, 52, 50, 46, 34, 51, 46, + 34, 51, 532, 46, 34, 51, 46, 34, 51, 46, + 34, 51, 0, 35, 0, 0, 35, 0, 0, 35, + 184, 46, 34, 51, 35, 0, 0, 35, 0, 0, + 0, 184, 0, 0, 0, 35, 0, 0, 35, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 49, 52, 50, 49, 52, 50, 49, 52, 50, 255, + 254, 49, 52, 50, 49, 52, 50, 255, 254, 0, + 250, 249, 49, 52, 50, 49, 52, 50, 46, 34, + 51, 46, 34, 51, 46, 34, 51, 35, 0, 46, + 34, 51, 46, 34, 51, 35, 532, 0, 35, 0, 46, 34, 51, 46, 34, 51, 0, 0, 0, 0, - 0, 0, 0, 46, 34, 51, 46, 34, 51, 49, - 52, 50, 0, 0, 0, 0, 0, 35, 0, 0, - 35, 0, 0, 49, 52, 50, 35, 0, 0, 35, - 0, 0, 35, 0, 80, 81, 35, 46, 34, 51, - 0, 0, 82, 83, 0, 0, 84, 0, 85, 0, - 0, 46, 34, 51, 49, 52, 50, 49, 52, 50, - 0, 0, 0, 49, 52, 50, 49, 52, 50, 49, - 52, 50, 35, 49, 52, 50, 0, 0, 0, 184, - 0, 35, 46, 34, 51, 46, 34, 51, 184, 0, - 0, 46, 34, 51, 46, 34, 51, 46, 34, 51, - 0, 46, 34, 51, 0, 35, 0, 0, 0, 49, - 52, 50, 184, 0, 0, 0, 0, 35, 49, 52, - 50, 0, 0, 0, 0, 35, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 35, 46, 34, 51, - 0, 0, 49, 52, 50, 0, 46, 34, 51, 0, - 0, 0, 0, 0, 49, 52, 50, 255, 254, 0, - 0, 0, 49, 52, 50, 0, 0, 0, 255, 254, - 46, 34, 51, 49, 52, 50, 35, 0, 0, 35, + 35, 0, 0, 0, 0, 0, 0, 0, 0, 255, + 254, 0, 0, 0, 49, 52, 50, 250, 249, 0, + 250, 249, 49, 52, 50, 49, 52, 50, 0, 0, + 0, 0, 0, 0, 0, 153, 0, 49, 52, 50, + 0, 0, 46, 34, 51, 154, 0, 0, 0, 155, + 46, 34, 51, 46, 34, 51, 0, 0, 156, 0, + 157, 0, 0, 319, 0, 46, 34, 51, 0, 0, + 0, 158, 0, 159, 64, 0, 0, 153, 0, 0, + 0, 160, 0, 0, 161, 65, 0, 154, 0, 0, + 162, 155, 0, 0, 0, 0, 163, 0, 0, 0, + 156, 0, 157, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 164, 158, 0, 159, 64, 0, 0, 0, + 0, 0, 0, 160, 0, 0, 161, 65, 0, 0, + 0, 0, 162, 0, 0, 0, 0, 0, 163, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, + 0, 36, 37, 0, 38, 0, 0, 0, 0, 0, + 0, 516, 0, 0, 0, 45, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 53, 49, 52, 50, 0, 54, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, + 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 46, 34, 51, 0, 35, 0, 0, 0, 0, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 255, 254, - 0, 250, 249, 49, 52, 50, 49, 52, 50, 0, - 0, 0, 0, 0, 0, 0, 250, 249, 0, 0, - 0, 49, 52, 50, 0, 0, 0, 0, 0, 0, - 0, 46, 34, 51, 46, 34, 51, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 34, 51, 0, 0, 0, 0, 0, 0, 0, 30, - 31, 153, 0, 0, 0, 0, 0, 0, 0, 33, - 0, 154, 0, 0, 0, 155, 35, 0, 0, 0, - 36, 37, 0, 38, 156, 0, 157, 0, 0, 0, - 42, 0, 0, 0, 45, 0, 0, 158, 0, 159, - 64, 0, 0, 0, 0, 0, 0, 160, 0, 0, - 161, 65, 53, 49, 52, 50, 162, 54, 0, 0, - 0, 0, 163, 0, 0, 0, 0, 0, 44, 56, - 32, 0, 0, 0, 41, 0, 0, 0, 164, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, - 0, 30, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 33, 0, 0, 153, 0, 0, 0, 35, 0, - 0, 0, 36, 37, 154, 38, 0, 0, 155, 0, - 0, 0, 516, 0, 0, 0, 45, 156, 0, 157, - 0, 0, 319, 0, 0, 0, 0, 0, 0, 0, - 158, 0, 159, 64, 53, 49, 52, 50, 0, 54, - 160, 0, 0, 161, 65, 0, 0, 0, 0, 162, - 44, 56, 32, 0, 0, 163, 41, 0, 0, 0, - 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, - 0, 164, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 30, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, + 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, + 0, 0, 0, 0, 0, 42, 0, 0, 0, 45, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, + 50, 0, 54, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 515, 0, + 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, + 219, 0, 0, 0, 0, 0, 0, 35, 0, 0, + 0, 36, 37, 0, 38, 0, 0, 0, 0, 0, + 0, 516, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 30, 31, 0, + 0, 0, 0, 53, 517, 519, 518, 0, 54, 0, + 0, 0, 0, 227, 0, 0, 0, 0, 0, 44, + 56, 32, 214, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 515, 0, 30, 31, 0, 0, + 0, 0, 0, 0, 0, 0, 219, 0, 0, 0, + 0, 0, 0, 35, 0, 0, 0, 36, 37, 0, + 38, 0, 0, 0, 0, 0, 0, 516, 0, 0, + 0, 45, 0, 0, 0, 0, 0, 0, 0, 572, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, + 517, 519, 518, 0, 54, 0, 0, 0, 0, 227, + 0, 0, 0, 0, 0, 44, 56, 32, 214, 0, + 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, + 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 515, 0, 30, 31, 0, 0, 0, 0, 0, 0, + 0, 0, 219, 0, 0, 0, 0, 0, 0, 35, + 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, + 0, 0, 0, 516, 0, 0, 0, 45, 0, 0, + 0, 0, 0, 0, 0, 569, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 53, 517, 519, 518, 0, + 54, 0, 0, 0, 0, 227, 0, 0, 0, 0, + 0, 44, 56, 32, 214, 0, 0, 41, 0, 0, + 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, - 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, + 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, + 0, 0, 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 49, 52, 50, 0, 54, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 44, 56, 32, 0, + 53, 49, 52, 50, 0, 54, 0, 55, 0, 57, + 0, 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 30, 31, 0, 0, 0, 0, 0, 0, 0, + 0, -135, 0, 0, 0, 29, 30, 31, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, + 0, 0, 0, 35, 0, 0, 0, 36, 37, 0, + 38, 0, 0, 0, 39, 0, 40, 42, 43, 0, + 0, 45, 0, 0, 0, 47, 0, 48, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, + 49, 52, 50, 0, 54, 0, 55, 0, 57, 0, + 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, + 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, + 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, - 0, 0, 36, 37, 0, 38, 0, 0, 0, 0, - 0, 0, 42, 0, 0, 0, 45, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, + 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, + 47, 0, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 55, 0, 57, 282, 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 515, 0, 30, 31, 0, - 0, 0, 0, 0, 0, 0, 0, 219, 0, 0, + 0, 0, 0, 0, 0, 488, 0, 0, 29, 30, + 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, + 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 36, 37, 0, 38, 0, 0, 0, 39, 0, 40, + 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, + 48, 0, 0, 494, 0, 0, 0, 0, 0, 0, + 0, 0, 53, 49, 52, 50, 0, 54, 0, 55, + 0, 57, 0, 58, 0, 0, 0, 0, 44, 56, + 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, + 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 488, 0, 0, 29, 30, 31, 0, + 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, - 0, 38, 0, 0, 0, 0, 0, 0, 516, 0, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 53, 517, 519, 518, 0, 54, 0, 0, 0, 0, - 227, 0, 0, 0, 0, 0, 44, 56, 32, 214, + 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, + 0, 0, 45, 0, 0, 0, 47, 0, 48, 0, + 0, 489, 0, 0, 0, 0, 0, 0, 0, 0, + 53, 49, 52, 50, 0, 54, 0, 55, 0, 57, + 0, 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 515, 0, 30, 31, 0, 0, 0, 0, 0, - 0, 0, 0, 219, 0, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 36, 37, 0, 38, 0, 0, - 0, 0, 0, 0, 516, 0, 0, 0, 45, 0, - 0, 0, 0, 0, 0, 0, 567, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 53, 517, 519, 518, - 0, 54, 0, 0, 0, 0, 227, 0, 0, 0, - 0, 0, 44, 56, 32, 214, 0, 0, 41, 0, - 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 515, 0, 30, - 31, 0, 0, 0, 0, 0, 0, 0, 0, 219, - 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, - 36, 37, 0, 38, 0, 0, 0, 0, 0, 0, - 516, 0, 0, 0, 45, 0, 0, 0, 0, 0, - 0, 0, 570, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 53, 517, 519, 518, 0, 54, 0, 0, - 0, 0, 227, 0, 0, 0, 0, 0, 44, 56, - 32, 214, 0, 0, 41, 0, 0, 0, 0, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 29, 30, 31, 0, 0, 0, 0, - 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, - 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, - 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, - 0, 0, 0, 47, 0, 48, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, - 50, 0, 54, 0, 55, 0, 57, 0, 58, 0, - 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, - 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -134, 0, + 0, 496, 0, 0, 29, 30, 31, 0, 0, 0, + 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, + 0, 0, 35, 0, 0, 0, 36, 37, 0, 38, + 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, + 45, 0, 0, 0, 47, 0, 48, 0, 0, 499, + 0, 0, 0, 0, 0, 0, 0, 0, 53, 49, + 52, 50, 0, 54, 0, 55, 0, 57, 0, 58, + 0, 0, 0, 0, 44, 56, 32, 0, 0, 0, + 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 496, 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, - 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, + 0, 0, 47, 0, 48, 0, 0, 497, 0, 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, 50, 0, 54, 0, 55, 0, 57, 0, 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, - 0, 0, 0, 0, 0, 35, 0, 0, 0, 36, + 0, 0, 0, 0, 0, 35, 220, 0, 0, 587, + 633, 0, 38, 0, 0, 0, 39, 0, 40, 42, + 43, 0, 0, 45, 0, 0, 0, 47, 0, 48, + 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, + 0, 53, 49, 52, 50, 224, 54, 0, 55, 226, + 57, 0, 58, 0, 229, 0, 0, 44, 56, 32, + 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, + 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 29, 30, 31, 0, 0, 0, 0, 0, + 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, + 35, 220, 0, 0, 221, 37, 0, 38, 0, 0, + 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, + 0, 0, 47, 0, 48, 0, 0, 0, 0, 0, + 0, 0, 223, 0, 0, 0, 53, 49, 52, 50, + 224, 54, 0, 55, 226, 57, 0, 58, 0, 229, + 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, + 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 29, 30, 31, + 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, + 0, 0, 0, 0, 0, 35, 220, 0, 0, 587, 37, 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, 47, 0, 48, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 53, 49, 52, 50, 0, 54, 0, 55, 0, - 57, 282, 58, 0, 0, 0, 0, 44, 56, 32, + 0, 0, 0, 0, 0, 0, 0, 223, 0, 0, + 0, 53, 49, 52, 50, 224, 54, 0, 55, 226, + 57, 0, 58, 0, 229, 0, 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 496, 0, 0, 29, 30, 31, 0, 0, - 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, - 0, 0, 0, 35, 0, 0, 0, 36, 37, 0, - 38, 0, 0, 0, 39, 0, 40, 42, 43, 0, - 0, 45, 0, 0, 0, 47, 0, 48, 0, 0, - 499, 0, 0, 0, 0, 0, 0, 0, 0, 53, - 49, 52, 50, 0, 54, 0, 55, 0, 57, 0, - 58, 0, 0, 0, 0, 44, 56, 32, 0, 0, - 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, - 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 496, 0, 0, 29, 30, 31, 0, 0, 0, 0, - 0, 0, 0, 0, 33, 0, 0, 0, 0, 0, - 0, 35, 0, 0, 0, 36, 37, 0, 38, 0, - 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, - 0, 0, 0, 47, 0, 48, 0, 0, 497, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 49, 52, - 50, 0, 54, 0, 55, 0, 57, 0, 58, 0, - 0, 0, 0, 44, 56, 32, 0, 0, 0, 41, - 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 488, 0, - 0, 29, 30, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 33, 0, 0, 0, 0, 0, 0, 35, - 0, 0, 0, 36, 37, 0, 38, 0, 0, 0, - 39, 0, 40, 42, 43, 0, 0, 45, 0, 0, - 0, 47, 0, 48, 0, 0, 489, 0, 0, 0, - 0, 0, 0, 0, 0, 53, 49, 52, 50, 0, - 54, 0, 55, 0, 57, 0, 58, 0, 0, 0, - 0, 44, 56, 32, 0, 0, 0, 41, 0, 0, - 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 488, 0, 0, 29, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 35, 0, 0, - 0, 36, 37, 0, 38, 0, 0, 0, 39, 0, - 40, 42, 43, 0, 0, 45, 0, 0, 0, 47, - 0, 48, 0, 0, 494, 0, 0, 0, 0, 0, - 0, 0, 0, 53, 49, 52, 50, 0, 54, 0, - 55, 0, 57, 0, 58, 0, 0, 0, 0, 44, - 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 111, 112, 113, 0, 0, 115, 117, 118, + 0, 0, 119, 0, 120, 0, 0, 0, 122, 123, + 124, 0, 0, 0, 0, 0, 0, 35, 125, 126, + 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 131, 0, 0, + 0, 0, 0, 0, 49, 52, 50, 132, 133, 134, + 0, 136, 137, 138, 139, 140, 141, 0, 0, 129, + 135, 121, 114, 116, 130, 0, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, - 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, - 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, - 0, 0, 0, 0, 223, 0, 0, 0, 53, 49, - 52, 50, 224, 54, 0, 55, 226, 57, 0, 58, - 0, 229, 0, 0, 44, 56, 32, 0, 0, 0, - 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, - 30, 31, 0, 0, 0, 0, 0, 0, 0, 0, - 33, 0, 0, 0, 0, 0, 0, 35, 220, 0, - 0, 585, 631, 0, 38, 0, 0, 0, 39, 0, + 0, 0, 0, 0, 111, 112, 113, 0, 0, 115, + 117, 118, 0, 0, 119, 0, 120, 0, 0, 0, + 122, 123, 124, 0, 0, 0, 0, 0, 0, 35, + 125, 126, 127, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 128, 0, 0, 0, 395, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, + 0, 0, 0, 0, 0, 397, 49, 52, 50, 132, + 133, 134, 0, 136, 137, 138, 139, 140, 141, 0, + 0, 129, 135, 121, 114, 116, 130, 0, 0, 0, + 0, 0, 0, 0, 46, 374, 380, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 111, 112, 113, 0, + 0, 115, 117, 118, 0, 0, 119, 0, 120, 0, + 0, 0, 122, 123, 124, 0, 0, 0, 0, 0, + 0, 35, 125, 126, 127, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 0, 0, 0, 395, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 131, 0, 0, 0, 0, 0, 397, 49, 52, + 50, 132, 133, 134, 0, 136, 137, 138, 139, 140, + 141, 0, 0, 129, 135, 121, 114, 116, 130, 0, + 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 111, 112, + 113, 0, 0, 115, 117, 118, 0, 0, 119, 0, + 120, 0, 0, 0, 122, 123, 124, 0, 0, 0, + 0, 0, 0, 35, 125, 126, 127, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, + 0, 395, 0, 0, 0, 0, 0, 0, 0, 396, + 0, 0, 0, 131, 0, 0, 0, 0, 0, 397, + 49, 52, 50, 132, 133, 134, 0, 136, 137, 138, + 139, 140, 141, 0, 0, 129, 135, 121, 114, 116, + 130, 0, 0, 0, 0, 0, 0, 0, 46, 374, + 380, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 213, 0, 0, 0, 0, 215, 0, 29, 30, 31, + 217, 0, 0, 0, 0, 0, 0, 218, 33, 0, + 0, 0, 0, 0, 0, 35, 220, 0, 0, 221, + 37, 0, 38, 0, 0, 0, 39, 0, 40, 42, + 43, 0, 0, 45, 0, 0, 0, 47, 0, 48, + 0, 0, 0, 0, 0, 222, 0, 223, 0, 0, + 0, 53, 49, 52, 50, 224, 54, 225, 55, 226, + 57, 227, 58, 228, 229, 0, 0, 44, 56, 32, + 214, 216, 0, 41, 0, 0, 0, 0, 0, 0, + 46, 34, 51, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 213, 0, 0, 0, 0, 215, 0, 29, + 30, 31, 217, 0, 0, 0, 0, 0, 0, 218, + 219, 0, 0, 0, 0, 0, 0, 35, 220, 0, + 0, 221, 37, 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, 45, 0, 0, 0, 47, - 0, 48, 0, 0, 0, 0, 0, 0, 0, 223, - 0, 0, 0, 53, 49, 52, 50, 224, 54, 0, - 55, 226, 57, 0, 58, 0, 229, 0, 0, 44, - 56, 32, 0, 0, 0, 41, 0, 0, 0, 0, + 0, 48, 0, 0, 0, 0, 0, 222, 0, 223, + 0, 0, 0, 53, 49, 52, 50, 224, 54, 225, + 55, 226, 57, 227, 58, 228, 229, 0, 0, 44, + 56, 32, 214, 216, 0, 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, - 0, 0, 0, 0, 0, 33, 0, 0, 0, 0, - 0, 0, 35, 220, 0, 0, 585, 37, 0, 38, - 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, - 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, - 0, 0, 0, 0, 223, 0, 0, 0, 53, 49, - 52, 50, 224, 54, 0, 55, 226, 57, 0, 58, - 0, 229, 0, 0, 44, 56, 32, 0, 0, 0, - 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 111, - 112, 113, 0, 0, 115, 117, 118, 0, 0, 119, - 0, 120, 0, 0, 0, 122, 123, 124, 0, 0, - 0, 0, 0, 0, 35, 125, 126, 127, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, - 0, 49, 52, 50, 132, 133, 134, 0, 136, 137, - 138, 139, 140, 141, 0, 0, 129, 135, 121, 114, - 116, 130, 0, 0, 0, 0, 0, 0, 0, 46, - 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 111, 112, 113, 0, 0, 115, 117, 118, 0, - 0, 119, 0, 120, 0, 0, 0, 122, 123, 124, - 0, 0, 0, 0, 0, 0, 35, 125, 126, 127, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 128, 0, 0, 0, 395, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 131, 0, 0, 0, - 0, 0, 397, 49, 52, 50, 132, 133, 134, 0, - 136, 137, 138, 139, 140, 141, 0, 0, 129, 135, - 121, 114, 116, 130, 0, 0, 0, 0, 0, 0, - 0, 46, 34, 51, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 111, 112, 113, 0, 0, 115, 117, - 118, 0, 0, 119, 0, 120, 0, 0, 0, 122, - 123, 124, 0, 0, 0, 0, 0, 0, 35, 125, - 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 128, 0, 0, 0, 395, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 131, 0, - 0, 0, 0, 0, 397, 49, 52, 50, 132, 133, - 134, 0, 136, 137, 138, 139, 140, 141, 0, 0, - 129, 135, 121, 114, 116, 130, 0, 0, 0, 0, - 0, 0, 0, 46, 374, 380, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 111, 112, 113, 0, 0, - 115, 117, 118, 0, 0, 119, 0, 120, 0, 0, - 0, 122, 123, 124, 0, 0, 0, 0, 0, 0, - 35, 125, 126, 127, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 128, 0, 0, 0, 395, 0, - 0, 0, 0, 0, 0, 0, 396, 0, 0, 0, - 131, 0, 0, 0, 0, 0, 397, 49, 52, 50, - 132, 133, 134, 0, 136, 137, 138, 139, 140, 141, - 0, 0, 129, 135, 121, 114, 116, 130, 0, 0, - 0, 0, 0, 0, 0, 46, 374, 380, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 213, 0, 0, - 0, 0, 215, 0, 29, 30, 31, 217, 0, 0, - 0, 0, 0, 0, 218, 219, 0, 0, 0, 0, - 0, 0, 35, 220, 0, 0, 221, 37, 0, 38, - 0, 0, 0, 39, 0, 40, 42, 43, 0, 0, - 45, 0, 0, 0, 47, 0, 48, 0, 0, 0, - 0, 0, 222, 0, 223, 0, 0, 0, 53, 49, - 52, 50, 224, 54, 225, 55, 226, 57, 227, 58, - 228, 229, 0, 0, 44, 56, 32, 214, 216, 0, - 41, 0, 0, 0, 0, 0, 0, 46, 34, 51, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 213, - 0, 0, 0, 0, 215, 0, 29, 30, 31, 217, - 0, 0, 0, 0, 0, 0, 218, 33, 0, 0, - 0, 0, 0, 0, 35, 220, 0, 0, 221, 37, - 0, 38, 0, 0, 0, 39, 0, 40, 42, 43, - 0, 0, 45, 0, 0, 0, 47, 0, 48, 0, - 0, 0, 0, 0, 222, 0, 223, 0, 0, 0, - 53, 49, 52, 50, 224, 54, 225, 55, 226, 57, - 227, 58, 228, 229, 0, 0, 44, 56, 32, 214, - 216, 0, 41, 0, 0, 0, 0, 0, 0, 46, - 34, 51, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 589, 112, 113, 0, 0, 591, 117, 593, 30, - 31, 594, 0, 120, 0, 0, 0, 122, 596, 597, - 0, 0, 0, 0, 0, 0, 35, 598, 126, 127, - 221, 37, 0, 38, 0, 0, 0, 39, 0, 40, - 599, 43, 0, 0, 601, 0, 0, 0, 47, 0, - 48, 0, 0, 0, 0, 0, 602, 0, 223, 0, - 0, 0, 603, 49, 52, 50, 604, 605, 606, 55, - 608, 609, 610, 611, 612, 613, 0, 0, 600, 607, - 595, 590, 592, 130, 41, 0, 0, 0, 0, 0, - 0, 46, 374, 380, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 365, 112, 113, 0, 0, 367, 117, - 369, 30, 31, 370, 0, 120, 0, 0, 0, 122, - 372, 373, 0, 0, 0, 0, 0, 0, 35, 375, - 126, 127, 221, 37, 0, 38, 0, 0, 0, 39, - 0, 40, 376, 43, 0, 0, 378, 0, 0, 0, - 47, 0, 48, 0, -280, 0, 0, 0, 379, 0, - 223, 0, 0, 0, 381, 49, 52, 50, 382, 383, - 384, 55, 386, 387, 388, 389, 390, 391, 0, 0, - 377, 385, 371, 366, 368, 130, 41, 0, 0, 0, - 0, 0, 0, 46, 374, 380, 0, 0, 0, 0, - 0, 0, 0, 0, 0, + 0, 0, 0, 0, 591, 112, 113, 0, 0, 593, + 117, 595, 30, 31, 596, 0, 120, 0, 0, 0, + 122, 598, 599, 0, 0, 0, 0, 0, 0, 35, + 600, 126, 127, 221, 37, 0, 38, 0, 0, 0, + 39, 0, 40, 601, 43, 0, 0, 603, 0, 0, + 0, 47, 0, 48, 0, 0, 0, 0, 0, 604, + 0, 223, 0, 0, 0, 605, 49, 52, 50, 606, + 607, 608, 55, 610, 611, 612, 613, 614, 615, 0, + 0, 602, 609, 597, 592, 594, 130, 41, 0, 0, + 0, 0, 0, 0, 46, 374, 380, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 365, 112, 113, 0, + 0, 367, 117, 369, 30, 31, 370, 0, 120, 0, + 0, 0, 122, 372, 373, 0, 0, 0, 0, 0, + 0, 35, 375, 126, 127, 221, 37, 0, 38, 0, + 0, 0, 39, 0, 40, 376, 43, 0, 0, 378, + 0, 0, 0, 47, 0, 48, 0, -281, 0, 0, + 0, 379, 0, 223, 0, 0, 0, 381, 49, 52, + 50, 382, 383, 384, 55, 386, 387, 388, 389, 390, + 391, 0, 0, 377, 385, 371, 366, 368, 130, 41, + 0, 0, 0, 0, 0, 0, 46, 374, 380, 0, + 0, 0, 0, 0, 0, 0, 0, 0, - 650, 253, 528, 638, 651, 447, 621, 536, 581, 16, - 554, 582, 661, 614, 548, 444, 667, 579, 636, 531, - 183, 628, 313, 533, 444, 572, 248, 248, 248, 552, - 263, 623, 237, 206, 313, 331, 447, 351, 183, 347, - 190, 253, 183, 495, 188, 178, 173, 142, 320, 313, - 253, 466, 639, 444, 152, 171, 462, 455, 165, 453, - 150, 441, 457, 458, 500, 469, 447, 145, 425, 183, - 148, 498, 475, 437, 433, 400, 260, 485, 393, 247, - 108, 514, 512, 0, 206, 322, 0, 188, 511, 345, - 637, 0, 206, 206, 62, 0, 0, 624, 206, 654, - 653, 206, 206, 62, 0, 206, 62, 409, 62, 110, - 170, 62, 148, 104, 98, 187, 0, 62, 102, 460, - 180, 313, 62, 331, 459, 167, 62, 62, 504, 69, - 62, 62, 313, 72, 63, 62, 62, 459, 507, 62, - 62, 506, 505, 62, 410, 70, 62, 0, 503, 62, - 62, 502, 182, 62, 62, 469, 62, 62, 91, 100, - 90, 62, 97, 62, 62, 62, 96, 62, 95, 94, - 93, 277, 86, 62, 62, 510, 281, 92, 62, 62, - 99, 62, 393, 71, 79, 349, 514, 74, 514, 353, - 62, 564, 460, 560, 355, 401, 341, 260, 62, 340, - 182, 206, 393, 409, 409, 206, 393, 343, 417, 206, - 206, 206, 62, 206, 459, 62, 188, 460, 148, 206, - 247, 362, 464, 468, 206, 62, 412, 362, 403, 479, - 296, 394, 188, 62, 206, 182, 407, 206, 206, 206, - 410, 410, 206, 356, 419, 493, 422, 514, 246, 492, - 362, 483, 655, 62, 62, 318, 62, 62, 295, 297, - 239, 298, 299, 313, 206, 313, 588, 309, 362, 242, - 362, 206, 281, 0, 0, 0, 62, 62, 0, 0, - 309, 281, 281, 309, 206, 281, 206, 108, 281, 308, - 62, 324, 309, 62, 327, 281, 62, 281, 281, 284, - 289, 281, 328, 300, 62, 330, 0, 0, 62, 281, - 0, 301, 0, 281, 337, 302, 110, 177, 62, 62, - 514, 309, 0, 281, 281, 0, 281, 576, 568, 522, - 306, 304, 560, 0, 634, 0, 0, 514, 314, 571, - 316, 513, 523, 311, 260, 0, 522, 0, 514, 0, - 0, 0, 0, 0, 443, 485, 440, 522, 513, 523, - 206, 540, 541, 542, 543, 547, 544, 545, 584, 513, - 523, 0, 0, 0, 0, 0, 0, 632, 633, 540, - 541, 542, 543, 547, 544, 545, 576, 0, 0, 0, - 0, 0, 0, 0, 0, 577, 578, 540, 541, 542, - 543, 547, 544, 545, 0, 0, 0, 0, 0, 0, + 152, 652, 331, 669, 535, 531, 538, 142, 528, 148, + 641, 16, 313, 393, 485, 500, 626, 630, 263, 638, + 183, 625, 623, 206, 574, 447, 583, 320, 183, 253, + 313, 248, 466, 145, 663, 653, 616, 584, 556, 640, + 581, 248, 437, 253, 248, 495, 183, 178, 453, 150, + 462, 347, 455, 550, 554, 183, 351, 447, 458, 190, + 313, 457, 425, 188, 469, 441, 433, 253, 237, 468, + 0, 313, 173, 171, 393, 409, 447, 498, 409, 464, + 400, 0, 165, 206, 475, 206, 512, 511, 0, 0, + 188, 0, 0, 206, 0, 206, 0, 62, 0, 459, + 417, 206, 206, 206, 188, 0, 62, 0, 62, 62, + 507, 504, 410, 148, 62, 410, 460, 62, 419, 505, + 407, 412, 170, 62, 62, 459, 506, 444, 277, 148, + 422, 331, 187, 281, 62, 62, 62, 180, 260, 295, + 296, 297, 62, 62, 656, 655, 314, 298, 299, 62, + 62, 503, 182, 62, 206, 362, 514, 393, 247, 62, + 62, 460, 502, 62, 62, 639, 313, 167, 92, 99, + 62, 206, 206, 514, 510, 345, 100, 260, 562, 62, + 62, 62, 394, 493, 93, 94, 95, 492, 62, 62, + 182, 206, 62, 206, 96, 62, 246, 97, 62, 90, + 62, 401, 91, 206, 62, 86, 355, 340, 353, 62, + 108, 247, 206, 349, 188, 313, 102, 206, 393, 104, + 313, 62, 206, 182, 206, 206, 62, 362, 459, 206, + 242, 62, 469, 460, 62, 514, 409, 63, 318, 110, + 657, 341, 239, 590, 403, 62, 322, 206, 72, 62, + 362, 62, 362, 69, 206, 98, 62, 62, 70, 71, + 514, 0, 206, 62, 62, 566, 356, 0, 206, 79, + 62, 108, 74, 410, 483, 281, 0, 309, 0, 0, + 62, 62, 281, 304, 62, 281, 281, 62, 362, 281, + 343, 0, 281, 284, 289, 316, 324, 327, 0, 311, + 110, 177, 0, 309, 206, 62, 479, 0, 281, 62, + 281, 309, 301, 309, 281, 0, 281, 309, 281, 62, + 306, 0, 281, 62, 281, 337, 302, 0, 281, 578, + 300, 514, 260, 328, 562, 308, 636, 570, 443, 330, + 522, 0, 0, 0, 0, 0, 514, 0, 206, 0, + 0, 0, 513, 523, 0, 522, 0, 485, 542, 543, + 544, 545, 549, 546, 547, 0, 586, 513, 523, 0, + 0, 0, 0, 0, 440, 588, 589, 542, 543, 544, + 545, 549, 546, 547, 586, 0, 0, 0, 0, 0, + 0, 0, 0, 634, 635, 542, 543, 544, 545, 549, + 546, 547, 578, 0, 0, 0, 0, 0, 0, 0, + 0, 579, 580, 542, 543, 544, 545, 549, 546, 547, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 573, 0, 0, 0, 0, 0, 0, 0, 0, + 514, 0, 0, 0, 0, 0, 0, 0, 0, 522, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 513, 523, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 584, 0, 0, 0, 0, 0, 0, - 0, 0, 586, 587, 540, 541, 542, 543, 547, 544, - 545, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0}; const short QQmlJSGrammar::action_check [] = { - 1, 79, 7, 33, 36, 7, 33, 7, 36, 7, - 36, 7, 7, 61, 8, 7, 7, 60, 33, 16, - 36, 55, 7, 48, 55, 7, 7, 60, 36, 5, - 5, 24, 5, 55, 8, 7, 20, 66, 37, 29, - 60, 2, 66, 60, 24, 34, 33, 33, 36, 55, - 60, 55, 55, 36, 17, 33, 79, 36, 7, 1, - 7, 7, -1, 8, 33, 33, 37, 33, 7, 36, - 7, 48, 36, 33, 7, 1, 7, 33, 7, 36, - 7, 36, 1, 8, 36, 36, 8, 8, 36, 33, - 60, 2, 7, 36, 2, 60, 55, 17, 60, 33, - 36, 36, 55, 61, 36, 0, 60, 48, 31, 33, - 7, 10, 8, 7, 15, 8, 33, 8, 36, 8, - 60, 8, 8, 61, 36, 15, 36, 7, 8, 79, - 60, 6, 48, 34, 8, 8, 8, 50, 8, 42, - 8, 54, 8, 50, 34, 20, 60, 54, -1, 77, - 53, 8, 61, 62, 8, 40, 55, 61, 62, 61, - 62, 61, 62, 15, 40, 56, 51, 60, 8, 40, - 56, 60, 8, 60, 7, 51, 7, 61, 62, 8, - 51, 29, 34, -1, 40, -1, 60, 60, 60, -1, - 56, 61, 60, 91, 92, 51, 61, 62, 7, 56, - 61, 62, 56, 91, 92, 29, 61, 62, 61, 62, - 29, 2, 61, 62, 61, 62, 61, 62, 61, 62, - 60, 15, 15, 29, 29, 61, 62, 75, 61, 62, - 61, 62, 61, 62, 12, 8, 15, 29, 86, 15, - 34, 34, 36, 36, 89, 12, 29, 7, 12, 36, - 93, 75, 61, 62, -1, 34, 75, 36, 34, 25, - 36, 27, 86, -1, -1, -1, -1, 86, -1, 75, - 75, -1, 38, 33, 61, 62, -1, -1, -1, 57, - 86, 86, -1, 75, -1, 63, 15, -1, 61, 62, - 57, -1, 75, 57, 86, 15, 63, 18, 19, 63, - -1, -1, -1, 86, 33, 34, 47, 36, -1, 18, - 19, -1, -1, 33, 34, 25, 36, 27, 23, 24, - 61, 62, -1, -1, 45, 46, -1, 32, 38, -1, - 35, -1, 37, -1, 94, -1, 45, 46, -1, 23, - 24, -1, -1, -1, -1, 23, 24, -1, 32, 23, - 24, 35, 93, 37, 32, 23, 24, 35, 32, 37, - -1, 35, -1, 37, 32, 23, 24, 35, 29, 37, - -1, -1, 29, 31, 32, 29, -1, 35, 29, 37, - 98, 99, 100, 101, 102, 103, 23, 24, 29, -1, - -1, 29, -1, -1, 31, 32, 18, 19, 35, -1, - 37, -1, -1, -1, -1, 66, 67, 68, -1, 66, - 67, 68, 66, 67, 68, 66, 67, 68, -1, -1, - -1, -1, 29, 45, 46, 66, 67, 68, 66, 67, - 68, -1, -1, 94, 95, 96, 29, 94, 95, 96, + 7, 55, 48, 55, 55, 55, 36, 7, 36, 33, + 55, 7, 7, 33, 37, 7, 7, 61, 60, 60, + 36, 7, 33, 8, 36, 7, 16, 1, 36, 60, + 7, 36, 2, 48, 7, 36, 5, 36, 36, 36, + 79, 5, 36, 60, 33, 33, 55, 60, 7, 36, + 34, 7, 33, 7, 7, 33, 36, 7, 7, 77, + 36, 33, 8, 5, 1, 8, 33, 60, 29, 79, + 36, 33, 17, 8, 37, 79, 33, 60, 33, 8, + 1, 60, 2, 8, 7, 60, 33, 55, 48, 60, + 29, 2, 7, 2, 7, 36, 36, 7, 17, 7, + 33, 66, 7, 61, 48, 31, 36, 1, 36, 33, + 8, 7, 60, 20, 36, 66, 33, 7, 36, 55, + 36, 8, 60, 8, 15, -1, 40, 79, 8, 61, + 61, 62, 10, 8, 61, 62, 40, 51, 8, 15, + 40, 40, 8, 34, 8, 42, 6, 51, 24, 61, + 62, 51, 51, 7, 8, 8, 53, 8, 61, 62, + 20, 8, 8, 8, 8, 15, 61, 62, 61, 62, + 8, 8, 15, 60, -1, 60, 56, 55, 61, 62, + 61, 62, 61, 62, 34, 60, 56, 61, 62, 91, + 92, 34, 56, 50, 60, 15, 29, 54, 0, 91, + 92, 50, 61, 62, 24, 54, 25, 60, 27, 12, + 61, 56, 29, 60, 60, 25, 60, 27, 56, 38, + 25, 25, 27, 27, 61, 62, 12, 15, 38, 61, + 62, 12, 29, 38, 38, 29, 7, -1, 25, 7, + 27, 36, 75, 8, 29, 8, 34, -1, 36, 15, + 25, 38, 27, 86, 57, 7, -1, 89, 75, 7, + 63, -1, 33, 38, 15, 29, 61, 62, 34, 86, + 36, 57, 29, -1, -1, -1, 57, 63, 75, -1, + -1, 75, 63, 34, 15, 36, -1, 61, 62, 86, + 75, -1, 86, 61, 62, -1, 61, 62, 61, 62, + -1, 86, -1, 34, 25, 36, 27, 15, -1, 61, + 62, 75, -1, 61, 62, 18, 19, 38, 75, 93, + 15, -1, 86, 94, -1, 33, 34, -1, 36, 86, + 18, 19, 18, 19, 18, 19, 47, -1, 33, 34, + -1, 36, 45, 46, 98, 99, 100, 101, 102, 103, + 61, 62, -1, -1, 23, 24, -1, 45, 46, 45, + 46, 45, 46, 32, 23, 24, 35, -1, 37, -1, + -1, -1, -1, 32, 23, 24, 35, -1, 37, -1, + 23, 24, 93, 32, -1, 25, 35, 27, 37, 32, + -1, -1, 35, 29, 37, 23, 24, -1, 38, -1, + -1, -1, -1, 31, 32, 23, 24, 35, -1, 37, + -1, -1, -1, 31, 32, 23, 24, 35, 29, 37, + -1, -1, -1, 31, 32, 23, 24, 35, -1, 37, + 66, 67, 68, 31, 32, 23, 24, 35, -1, 37, + -1, -1, -1, 31, 32, -1, -1, 35, -1, 37, + 29, -1, -1, 29, -1, 66, 67, 68, 94, 95, + 96, 29, -1, -1, 29, -1, 23, 24, 29, -1, + -1, 29, 15, -1, 29, 32, -1, -1, 35, -1, + 37, 36, -1, 94, 95, 96, 29, 66, 67, 68, + 66, 67, 68, -1, -1, -1, -1, -1, 66, 67, + 68, 66, 67, 68, -1, 66, 67, 68, 66, 67, + 68, 66, 67, 68, -1, 94, 95, 96, 94, 95, + 96, -1, -1, 66, 67, 68, 94, 95, 96, 94, + 95, 96, 15, 94, 95, 96, 94, 95, 96, 94, + 95, 96, -1, 29, -1, -1, 29, -1, -1, 29, + 36, 94, 95, 96, 29, -1, -1, 29, -1, -1, + -1, 36, -1, -1, -1, 29, -1, -1, 29, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 66, 67, 68, 66, 67, 68, 66, 67, 68, 61, + 62, 66, 67, 68, 66, 67, 68, 61, 62, -1, + 61, 62, 66, 67, 68, 66, 67, 68, 94, 95, + 96, 94, 95, 96, 94, 95, 96, 29, -1, 94, + 95, 96, 94, 95, 96, 29, 15, -1, 29, -1, 94, 95, 96, 94, 95, 96, -1, -1, -1, -1, - -1, -1, -1, 94, 95, 96, 94, 95, 96, 66, - 67, 68, -1, -1, -1, -1, -1, 29, -1, -1, - 29, -1, -1, 66, 67, 68, 29, -1, -1, 29, - -1, -1, 29, -1, 23, 24, 29, 94, 95, 96, - -1, -1, 31, 32, -1, -1, 35, -1, 37, -1, - -1, 94, 95, 96, 66, 67, 68, 66, 67, 68, - -1, -1, -1, 66, 67, 68, 66, 67, 68, 66, - 67, 68, 29, 66, 67, 68, -1, -1, -1, 36, - -1, 29, 94, 95, 96, 94, 95, 96, 36, -1, - -1, 94, 95, 96, 94, 95, 96, 94, 95, 96, - -1, 94, 95, 96, -1, 29, -1, -1, -1, 66, - 67, 68, 36, -1, -1, -1, -1, 29, 66, 67, - 68, -1, -1, -1, -1, 29, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 29, 94, 95, 96, - -1, -1, 66, 67, 68, -1, 94, 95, 96, -1, - -1, -1, -1, -1, 66, 67, 68, 61, 62, -1, - -1, -1, 66, 67, 68, -1, -1, -1, 61, 62, - 94, 95, 96, 66, 67, 68, 29, -1, -1, 29, + 29, -1, -1, -1, -1, -1, -1, -1, -1, 61, + 62, -1, -1, -1, 66, 67, 68, 61, 62, -1, + 61, 62, 66, 67, 68, 66, 67, 68, -1, -1, + -1, -1, -1, -1, -1, 3, -1, 66, 67, 68, + -1, -1, 94, 95, 96, 13, -1, -1, -1, 17, + 94, 95, 96, 94, 95, 96, -1, -1, 26, -1, + 28, -1, -1, 31, -1, 94, 95, 96, -1, -1, + -1, 39, -1, 41, 42, -1, -1, 3, -1, -1, + -1, 49, -1, -1, 52, 53, -1, 13, -1, -1, + 58, 17, -1, -1, -1, -1, 64, -1, -1, -1, + 26, -1, 28, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 80, 39, -1, 41, 42, -1, -1, -1, + -1, -1, -1, 49, -1, -1, 52, 53, -1, -1, + -1, -1, 58, -1, -1, -1, -1, -1, 64, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 80, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, + -1, 33, 34, -1, 36, -1, -1, -1, -1, -1, + -1, 43, -1, -1, -1, 47, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, + 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, - 94, 95, 96, -1, 29, -1, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, -1, -1, 61, 62, - -1, 61, 62, 66, 67, 68, 66, 67, 68, -1, - -1, -1, -1, -1, -1, -1, 61, 62, -1, -1, - -1, 66, 67, 68, -1, -1, -1, -1, -1, -1, - -1, 94, 95, 96, 94, 95, 96, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 94, - 95, 96, -1, -1, -1, -1, -1, -1, -1, 12, - 13, 3, -1, -1, -1, -1, -1, -1, -1, 22, - -1, 13, -1, -1, -1, 17, 29, -1, -1, -1, - 33, 34, -1, 36, 26, -1, 28, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, 39, -1, 41, - 42, -1, -1, -1, -1, -1, -1, 49, -1, -1, - 52, 53, 65, 66, 67, 68, 58, 70, -1, -1, - -1, -1, 64, -1, -1, -1, -1, -1, 81, 82, - 83, -1, -1, -1, 87, -1, -1, -1, 80, -1, - -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, - -1, 12, 13, -1, -1, -1, -1, -1, -1, -1, - -1, 22, -1, -1, 3, -1, -1, -1, 29, -1, - -1, -1, 33, 34, 13, 36, -1, -1, 17, -1, - -1, -1, 43, -1, -1, -1, 47, 26, -1, 28, - -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, - 39, -1, 41, 42, 65, 66, 67, 68, -1, 70, - 49, -1, -1, 52, 53, -1, -1, -1, -1, 58, - 81, 82, 83, -1, -1, 64, 87, -1, -1, -1, - -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, - -1, 80, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 12, 13, -1, -1, -1, -1, + -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, + -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, + 68, -1, 70, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, + -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 10, -1, + 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, + -1, 33, 34, -1, 36, -1, -1, -1, -1, -1, + -1, 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 12, 13, -1, + -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, + -1, -1, -1, 75, -1, -1, -1, -1, -1, 81, + 82, 83, 84, -1, -1, 87, -1, -1, -1, -1, + -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 10, -1, 12, 13, -1, -1, + -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, + -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, + 36, -1, -1, -1, -1, -1, -1, 43, -1, -1, + -1, 47, -1, -1, -1, -1, -1, -1, -1, 55, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, + 66, 67, 68, -1, 70, -1, -1, -1, -1, 75, + -1, -1, -1, -1, -1, 81, 82, 83, 84, -1, + -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, + 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 10, -1, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, 55, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, + 70, -1, -1, -1, -1, 75, -1, -1, -1, -1, + -1, 81, 82, 83, 84, -1, -1, 87, -1, -1, + -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 81, 82, 83, -1, + 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, + -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 12, 13, -1, -1, -1, -1, -1, -1, -1, + -1, 7, -1, -1, -1, 11, 12, 13, -1, -1, + -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, + -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, + 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, + -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, + 66, 67, 68, -1, 70, -1, 72, -1, 74, -1, + 76, -1, -1, -1, -1, 81, 82, 83, -1, -1, + -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, + 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, - -1, -1, 33, 34, -1, 36, -1, -1, -1, -1, - -1, -1, 43, -1, -1, -1, 47, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, + -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, + 51, -1, 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, 70, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 72, -1, 74, 75, 76, -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 10, -1, 12, 13, -1, + -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, + -1, -1, 65, 66, 67, 68, -1, 70, -1, 72, + -1, 74, -1, 76, -1, -1, -1, -1, 81, 82, + 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, + -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, - -1, 36, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, 47, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 65, 66, 67, 68, -1, 70, -1, -1, -1, -1, - 75, -1, -1, -1, -1, -1, 81, 82, 83, 84, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, + -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, 68, -1, 70, -1, 72, -1, 74, + -1, 76, -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 10, -1, 12, 13, -1, -1, -1, -1, -1, + -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, + -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, + -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, 56, + -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, + 67, 68, -1, 70, -1, 72, -1, 74, -1, 76, + -1, -1, -1, -1, 81, 82, 83, -1, -1, -1, + 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, - -1, -1, -1, -1, 43, -1, -1, -1, 47, -1, - -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, - -1, 70, -1, -1, -1, -1, 75, -1, -1, -1, - -1, -1, 81, 82, 83, 84, -1, -1, 87, -1, + -1, 70, -1, 72, -1, 74, -1, 76, -1, -1, + -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 10, -1, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, - -1, -1, 55, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, 68, -1, 70, -1, -1, - -1, -1, 75, -1, -1, -1, -1, -1, 81, 82, - 83, 84, -1, -1, 87, -1, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, - 68, -1, 70, -1, 72, -1, 74, -1, 76, -1, - -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, - -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 7, -1, + -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, + -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, + -1, -1, -1, -1, -1, 29, 30, -1, -1, 33, + 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, + 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, + -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, -1, 72, 73, + 74, -1, 76, -1, 78, -1, -1, 81, 82, 83, + -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, + 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, - 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, + 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 65, 66, 67, 68, - -1, 70, -1, 72, -1, 74, -1, 76, -1, -1, + -1, -1, 61, -1, -1, -1, 65, 66, 67, 68, + 69, 70, -1, 72, 73, 74, -1, 76, -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, - -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, + -1, -1, -1, -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 65, 66, 67, 68, -1, 70, -1, 72, -1, - 74, 75, 76, -1, -1, -1, -1, 81, 82, 83, + -1, -1, -1, -1, -1, -1, -1, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, -1, 72, 73, + 74, -1, 76, -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 8, -1, -1, 11, 12, 13, -1, -1, - -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, - -1, -1, -1, 29, -1, -1, -1, 33, 34, -1, - 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, - -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, - 56, -1, -1, -1, -1, -1, -1, -1, -1, 65, - 66, 67, 68, -1, 70, -1, 72, -1, 74, -1, - 76, -1, -1, -1, -1, 81, 82, 83, -1, -1, - -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, - 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, 56, -1, - -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, - 68, -1, 70, -1, 72, -1, 74, -1, 76, -1, - -1, -1, -1, 81, 82, 83, -1, -1, -1, 87, - -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 8, -1, - -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, - -1, 51, -1, 53, -1, -1, 56, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, 68, -1, - 70, -1, 72, -1, 74, -1, 76, -1, -1, -1, - -1, 81, 82, 83, -1, -1, -1, 87, -1, -1, - -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, -1, -1, 11, - 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, - 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, - -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, - 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, - -1, 53, -1, -1, 56, -1, -1, -1, -1, -1, - -1, -1, -1, 65, 66, 67, 68, -1, 70, -1, - 72, -1, 74, -1, 76, -1, -1, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, + -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, + -1, -1, 14, -1, 16, -1, -1, -1, 20, 21, + 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, + 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 43, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, + -1, -1, -1, -1, 66, 67, 68, 69, 70, 71, + -1, 73, 74, 75, 76, 77, 78, -1, -1, 81, + 82, 83, 84, 85, 86, -1, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, -1, -1, 61, -1, -1, -1, 65, 66, - 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, - -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, - 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, - 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, + 10, 11, -1, -1, 14, -1, 16, -1, -1, -1, + 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, + 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, 65, 66, 67, 68, 69, + 70, 71, -1, 73, 74, 75, 76, 77, 78, -1, + -1, 81, 82, 83, 84, 85, 86, -1, -1, -1, + -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 4, 5, 6, -1, + -1, 9, 10, 11, -1, -1, 14, -1, 16, -1, + -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, + -1, 29, 30, 31, 32, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 59, -1, -1, -1, -1, -1, 65, 66, 67, + 68, 69, 70, 71, -1, 73, 74, 75, 76, 77, + 78, -1, -1, 81, 82, 83, 84, 85, 86, -1, + -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 4, 5, + 6, -1, -1, 9, 10, 11, -1, -1, 14, -1, + 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, + -1, -1, -1, 29, 30, 31, 32, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 43, -1, -1, + -1, 47, -1, -1, -1, -1, -1, -1, -1, 55, + -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, + 66, 67, 68, 69, 70, 71, -1, 73, 74, 75, + 76, 77, 78, -1, -1, 81, 82, 83, 84, 85, + 86, -1, -1, -1, -1, -1, -1, -1, 94, 95, + 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 4, -1, -1, -1, -1, 9, -1, 11, 12, 13, + 14, -1, -1, -1, -1, -1, -1, 21, 22, -1, + -1, -1, -1, -1, -1, 29, 30, -1, -1, 33, + 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, + 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, + -1, -1, -1, -1, -1, 59, -1, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 78, -1, -1, 81, 82, 83, + 84, 85, -1, 87, -1, -1, -1, -1, -1, -1, + 94, 95, 96, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 4, -1, -1, -1, -1, 9, -1, 11, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, - -1, 53, -1, -1, -1, -1, -1, -1, -1, 61, - -1, -1, -1, 65, 66, 67, 68, 69, 70, -1, - 72, 73, 74, -1, 76, -1, 78, -1, -1, 81, - 82, 83, -1, -1, -1, 87, -1, -1, -1, -1, + -1, 53, -1, -1, -1, -1, -1, 59, -1, 61, + -1, -1, -1, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, -1, -1, 81, + 82, 83, 84, 85, -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, -1, -1, 61, -1, -1, -1, 65, 66, - 67, 68, 69, 70, -1, 72, 73, 74, -1, 76, - -1, 78, -1, -1, 81, 82, 83, -1, -1, -1, - 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, - -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, 31, 32, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 59, -1, -1, -1, -1, -1, - -1, 66, 67, 68, 69, 70, 71, -1, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, 86, -1, -1, -1, -1, -1, -1, -1, 94, - 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, - -1, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 43, -1, -1, -1, 47, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, - -1, -1, 65, 66, 67, 68, 69, 70, 71, -1, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, -1, -1, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, - 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 43, -1, -1, -1, 47, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, - -1, -1, -1, -1, 65, 66, 67, 68, 69, 70, - 71, -1, 73, 74, 75, 76, 77, 78, -1, -1, - 81, 82, 83, 84, 85, 86, -1, -1, -1, -1, - -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, - 9, 10, 11, -1, -1, 14, -1, 16, -1, -1, - -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, - 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 43, -1, -1, -1, 47, -1, - -1, -1, -1, -1, -1, -1, 55, -1, -1, -1, - 59, -1, -1, -1, -1, -1, 65, 66, 67, 68, - 69, 70, 71, -1, 73, 74, 75, 76, 77, 78, - -1, -1, 81, 82, 83, 84, 85, 86, -1, -1, - -1, -1, -1, -1, -1, 94, 95, 96, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, - -1, -1, 9, -1, 11, 12, 13, 14, -1, -1, - -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, - -1, -1, 29, 30, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, 59, -1, 61, -1, -1, -1, 65, 66, - 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, - 77, 78, -1, -1, 81, 82, 83, 84, 85, -1, - 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, - -1, -1, -1, -1, 9, -1, 11, 12, 13, 14, - -1, -1, -1, -1, -1, -1, 21, 22, -1, -1, - -1, -1, -1, -1, 29, 30, -1, -1, 33, 34, - -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, - -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, - -1, -1, -1, -1, 59, -1, 61, -1, -1, -1, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 78, -1, -1, 81, 82, 83, 84, - 85, -1, 87, -1, -1, -1, -1, -1, -1, 94, - 95, 96, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 4, 5, 6, -1, -1, 9, 10, 11, 12, - 13, 14, -1, 16, -1, -1, -1, 20, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, 59, -1, 61, -1, - -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, -1, -1, 81, 82, - 83, 84, 85, 86, 87, -1, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, - 11, 12, 13, 14, -1, 16, -1, -1, -1, 20, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - 31, 32, 33, 34, -1, 36, -1, -1, -1, 40, - -1, 42, 43, 44, -1, -1, 47, -1, -1, -1, - 51, -1, 53, -1, 55, -1, -1, -1, 59, -1, - 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 75, 76, 77, 78, -1, -1, - 81, 82, 83, 84, 85, 86, 87, -1, -1, -1, - -1, -1, -1, 94, 95, 96, -1, -1, -1, -1, - -1, -1, -1, -1, -1, + -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, + 10, 11, 12, 13, 14, -1, 16, -1, -1, -1, + 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, + 30, 31, 32, 33, 34, -1, 36, -1, -1, -1, + 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, + -1, 51, -1, 53, -1, -1, -1, -1, -1, 59, + -1, 61, -1, -1, -1, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, -1, + -1, 81, 82, 83, 84, 85, 86, 87, -1, -1, + -1, -1, -1, -1, 94, 95, 96, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 4, 5, 6, -1, + -1, 9, 10, 11, 12, 13, 14, -1, 16, -1, + -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, + -1, 29, 30, 31, 32, 33, 34, -1, 36, -1, + -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, + -1, -1, -1, 51, -1, 53, -1, 55, -1, -1, + -1, 59, -1, 61, -1, -1, -1, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, -1, -1, 81, 82, 83, 84, 85, 86, 87, + -1, -1, -1, -1, -1, -1, 94, 95, 96, -1, + -1, -1, -1, -1, -1, -1, -1, -1, - 14, 18, 32, 22, 14, 25, 32, 18, 32, 3, - 18, 18, 18, 22, 14, 3, 18, 22, 22, 32, - 18, 18, 3, 18, 3, 18, 18, 18, 18, 32, - 3, 32, 18, 18, 3, 18, 25, 3, 18, 3, - 18, 18, 18, 42, 18, 3, 42, 3, 3, 3, - 18, 3, 9, 3, 77, 42, 3, 18, 42, 105, - 42, 3, 25, 25, 3, 18, 25, 42, 3, 18, - 42, 42, 42, 100, 103, 42, 2, 42, 18, 4, - 18, 14, 2, -1, 18, 2, -1, 18, 4, 2, - 23, -1, 18, 18, 54, -1, -1, 18, 18, 11, - 12, 18, 18, 54, -1, 18, 54, 14, 54, 47, - 70, 54, 42, 64, 60, 46, -1, 54, 66, 56, - 50, 3, 54, 18, 56, 68, 54, 54, 56, 56, - 54, 54, 3, 57, 57, 54, 54, 56, 56, 54, - 54, 56, 56, 54, 51, 56, 54, -1, 56, 54, - 54, 56, 56, 54, 54, 18, 54, 54, 58, 60, - 58, 54, 59, 54, 54, 54, 59, 54, 59, 59, - 59, 54, 59, 54, 54, 109, 59, 58, 54, 54, - 60, 54, 18, 56, 60, 2, 14, 62, 14, 2, - 54, 19, 56, 19, 2, 2, 78, 2, 54, 94, - 56, 18, 18, 14, 14, 18, 18, 78, 44, 18, - 18, 18, 54, 18, 56, 54, 18, 56, 42, 18, - 4, 2, 2, 2, 18, 54, 50, 2, 44, 92, - 59, 43, 18, 54, 18, 56, 45, 18, 18, 18, - 51, 51, 18, 18, 46, 38, 45, 14, 2, 42, - 2, 45, 19, 54, 54, 2, 54, 54, 59, 59, - 46, 59, 59, 3, 18, 3, 18, 54, 2, 45, - 2, 18, 59, -1, -1, -1, 54, 54, -1, -1, - 54, 59, 59, 54, 18, 59, 18, 18, 59, 76, - 54, 69, 54, 54, 71, 59, 54, 59, 59, 63, - 61, 59, 76, 61, 54, 76, -1, -1, 54, 59, - -1, 61, -1, 59, 76, 61, 47, 48, 54, 54, - 14, 54, -1, 59, 59, -1, 59, 14, 5, 23, - 65, 67, 19, -1, 21, -1, -1, 14, 78, 5, - 78, 35, 36, 76, 2, -1, 23, -1, 14, -1, - -1, -1, -1, -1, 88, 42, 88, 23, 35, 36, - 18, 25, 26, 27, 28, 29, 30, 31, 14, 35, - 36, -1, -1, -1, -1, -1, -1, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 14, -1, -1, -1, - -1, -1, -1, -1, -1, 23, 24, 25, 26, 27, - 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 77, 14, 18, 18, 18, 32, 18, 3, 32, 42, + 9, 3, 3, 18, 42, 3, 18, 18, 3, 22, + 18, 32, 32, 18, 18, 25, 32, 3, 18, 18, + 3, 18, 3, 42, 18, 14, 22, 18, 18, 22, + 22, 18, 100, 18, 18, 42, 18, 3, 105, 42, + 3, 3, 18, 14, 32, 18, 3, 25, 25, 18, + 3, 25, 3, 18, 18, 3, 103, 18, 18, 2, + -1, 3, 42, 42, 18, 14, 25, 42, 14, 2, + 42, -1, 42, 18, 42, 18, 2, 4, -1, -1, + 18, -1, -1, 18, -1, 18, -1, 54, -1, 56, + 44, 18, 18, 18, 18, -1, 54, -1, 54, 54, + 56, 56, 51, 42, 54, 51, 56, 54, 46, 56, + 45, 50, 70, 54, 54, 56, 56, 3, 54, 42, + 45, 18, 46, 59, 54, 54, 54, 50, 2, 59, + 59, 59, 54, 54, 11, 12, 78, 59, 59, 54, + 54, 56, 56, 54, 18, 2, 14, 18, 4, 54, + 54, 56, 56, 54, 54, 23, 3, 68, 58, 60, + 54, 18, 18, 14, 109, 2, 60, 2, 19, 54, + 54, 54, 43, 38, 59, 59, 59, 42, 54, 54, + 56, 18, 54, 18, 59, 54, 2, 59, 54, 58, + 54, 2, 58, 18, 54, 59, 2, 94, 2, 54, + 18, 4, 18, 2, 18, 3, 66, 18, 18, 64, + 3, 54, 18, 56, 18, 18, 54, 2, 56, 18, + 45, 54, 18, 56, 54, 14, 14, 57, 2, 47, + 19, 78, 46, 18, 44, 54, 2, 18, 57, 54, + 2, 54, 2, 56, 18, 60, 54, 54, 56, 56, + 14, -1, 18, 54, 54, 19, 18, -1, 18, 60, + 54, 18, 62, 51, 45, 59, -1, 54, -1, -1, + 54, 54, 59, 67, 54, 59, 59, 54, 2, 59, + 78, -1, 59, 63, 61, 78, 69, 71, -1, 76, + 47, 48, -1, 54, 18, 54, 92, -1, 59, 54, + 59, 54, 61, 54, 59, -1, 59, 54, 59, 54, + 65, -1, 59, 54, 59, 76, 61, -1, 59, 14, + 61, 14, 2, 76, 19, 76, 21, 5, 88, 76, + 23, -1, -1, -1, -1, -1, 14, -1, 18, -1, + -1, -1, 35, 36, -1, 23, -1, 42, 25, 26, + 27, 28, 29, 30, 31, -1, 14, 35, 36, -1, + -1, -1, -1, -1, 88, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 14, -1, -1, -1, -1, -1, + -1, -1, -1, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 14, -1, -1, -1, -1, -1, -1, -1, + -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, + 14, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, - -1, -1, 23, 24, 25, 26, 27, 28, 29, 30, - 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 35, 36, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + -1, -1, -1, -1, -1, -1, -1}; QT_END_NAMESPACE diff --git a/src/qml/parser/qqmljsgrammar_p.h b/src/qml/parser/qqmljsgrammar_p.h index 244a807f24..050ef6c288 100644 --- a/src/qml/parser/qqmljsgrammar_p.h +++ b/src/qml/parser/qqmljsgrammar_p.h @@ -167,15 +167,15 @@ public: T_XOR = 79, T_XOR_EQ = 80, - ACCEPT_STATE = 672, - RULE_COUNT = 360, - STATE_COUNT = 673, + ACCEPT_STATE = 674, + RULE_COUNT = 361, + STATE_COUNT = 675, TERMINAL_COUNT = 106, NON_TERMINAL_COUNT = 111, - GOTO_INDEX_OFFSET = 673, - GOTO_INFO_OFFSET = 3185, - GOTO_CHECK_OFFSET = 3185 + GOTO_INDEX_OFFSET = 675, + GOTO_INFO_OFFSET = 3078, + GOTO_CHECK_OFFSET = 3078 }; static const char *const spell []; diff --git a/src/qml/parser/qqmljsparser.cpp b/src/qml/parser/qqmljsparser.cpp index ca5a09d22d..50518a92ee 100644 --- a/src/qml/parser/qqmljsparser.cpp +++ b/src/qml/parser/qqmljsparser.cpp @@ -436,31 +436,55 @@ case 47: sym(1).Node = node; } break; +case 48: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 49: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + +case 50: { + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(stringRef(1)); + node->identifierToken = loc(1); + sym(1).Node = node; +} break; + case 51: { - sym(1).Node = 0; + AST::UiQualifiedId *node = new (pool) AST::UiQualifiedId(sym(1).UiQualifiedId, stringRef(3)); + node->identifierToken = loc(3); + sym(1).Node = node; } break; case 52: { - sym(1).Node = sym(1).UiParameterList->finish (); + sym(1).Node = 0; } break; case 53: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(stringRef(1), stringRef(2)); + sym(1).Node = sym(1).UiParameterList->finish (); +} break; + +case 54: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiQualifiedId->finish(), stringRef(2)); node->propertyTypeToken = loc(1); node->identifierToken = loc(2); sym(1).Node = node; } break; -case 54: { - AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, stringRef(3), stringRef(4)); +case 55: { + AST::UiParameterList *node = new (pool) AST::UiParameterList(sym(1).UiParameterList, sym(3).UiQualifiedId->finish(), stringRef(4)); node->propertyTypeToken = loc(3); node->commaToken = loc(2); node->identifierToken = loc(4); sym(1).Node = node; } break; -case 56: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); +case 57: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2)); node->type = AST::UiPublicMember::Signal; node->propertyToken = loc(1); node->typeToken = loc(2); @@ -470,8 +494,8 @@ case 56: { sym(1).Node = node; } break; -case 58: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(QStringRef(), stringRef(2)); +case 59: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(nullptr, stringRef(2)); node->type = AST::UiPublicMember::Signal; node->propertyToken = loc(1); node->typeToken = loc(2); @@ -480,8 +504,8 @@ case 58: { sym(1).Node = node; } break; -case 60: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); +case 61: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6)); node->typeModifier = stringRef(2); node->propertyToken = loc(1); node->typeModifierToken = loc(2); @@ -491,8 +515,8 @@ case 60: { sym(1).Node = node; } break; -case 62: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); +case 63: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3)); node->propertyToken = loc(1); node->typeToken = loc(2); node->identifierToken = loc(3); @@ -500,8 +524,8 @@ case 62: { sym(1).Node = node; } break; -case 64: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); +case 65: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4)); node->isDefaultMember = true; node->defaultToken = loc(1); node->propertyToken = loc(2); @@ -511,8 +535,8 @@ case 64: { sym(1).Node = node; } break; -case 66: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(5), stringRef(7)); +case 67: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(5).UiQualifiedId->finish(), stringRef(7)); node->isDefaultMember = true; node->defaultToken = loc(1); node->typeModifier = stringRef(3); @@ -524,8 +548,8 @@ case 66: { sym(1).Node = node; } break; -case 67: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), +case 68: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3), sym(5).Statement); node->propertyToken = loc(1); node->typeToken = loc(2); @@ -534,8 +558,8 @@ case 67: { sym(1).Node = node; } break; -case 68: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), +case 69: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement); node->isReadonlyMember = true; node->readonlyToken = loc(1); @@ -546,8 +570,8 @@ case 68: { sym(1).Node = node; } break; -case 69: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), +case 70: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4), sym(6).Statement); node->isDefaultMember = true; node->defaultToken = loc(1); @@ -558,8 +582,8 @@ case 69: { sym(1).Node = node; } break; -case 70: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); +case 71: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6)); node->typeModifier = stringRef(2); node->propertyToken = loc(1); node->typeModifierToken = loc(2); @@ -582,8 +606,8 @@ case 70: { sym(1).Node = node; } break; -case 71: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); +case 72: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(2).UiQualifiedId->finish(), stringRef(3)); node->propertyToken = loc(1); node->typeToken = loc(2); node->identifierToken = loc(3); @@ -602,8 +626,8 @@ case 71: { sym(1).Node = node; } break; -case 72: { - AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); +case 73: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(3).UiQualifiedId->finish(), stringRef(4)); node->isReadonlyMember = true; node->readonlyToken = loc(1); node->propertyToken = loc(2); @@ -624,57 +648,57 @@ case 72: { sym(1).Node = node; } break; -case 73: { +case 74: { sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); } break; -case 74: { +case 75: { sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); } break; -case 82: { +case 83: { AST::ThisExpression *node = new (pool) AST::ThisExpression(); node->thisToken = loc(1); sym(1).Node = node; } break; -case 83: { +case 84: { AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 84: { +case 85: { AST::NullExpression *node = new (pool) AST::NullExpression(); node->nullToken = loc(1); sym(1).Node = node; } break; -case 85: { +case 86: { AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); node->trueToken = loc(1); sym(1).Node = node; } break; -case 86: { +case 87: { AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); node->falseToken = loc(1); sym(1).Node = node; } break; -case 87: { +case 88: { AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); node->literalToken = loc(1); sym(1).Node = node; } break; -case 88: -case 89: { +case 89: +case 90: { AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); node->literalToken = loc(1); sym(1).Node = node; } break; -case 90: { +case 91: { bool rx = lexer->scanRegExp(Lexer::NoPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -690,7 +714,7 @@ case 90: { sym(1).Node = node; } break; -case 91: { +case 92: { bool rx = lexer->scanRegExp(Lexer::EqualPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -706,28 +730,28 @@ case 91: { sym(1).Node = node; } break; -case 92: { +case 93: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); node->lbracketToken = loc(1); node->rbracketToken = loc(2); sym(1).Node = node; } break; -case 93: { +case 94: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).Elision->finish()); node->lbracketToken = loc(1); node->rbracketToken = loc(3); sym(1).Node = node; } break; -case 94: { +case 95: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish ()); node->lbracketToken = loc(1); node->rbracketToken = loc(3); sym(1).Node = node; } break; -case 95: { +case 96: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), (AST::Elision *) 0); node->lbracketToken = loc(1); @@ -736,7 +760,7 @@ case 95: { sym(1).Node = node; } break; -case 96: { +case 97: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), sym(4).Elision->finish()); node->lbracketToken = loc(1); @@ -745,7 +769,7 @@ case 96: { sym(1).Node = node; } break; -case 97: { +case 98: { AST::ObjectLiteral *node = 0; if (sym(2).Node) node = new (pool) AST::ObjectLiteral( @@ -757,7 +781,7 @@ case 97: { sym(1).Node = node; } break; -case 98: { +case 99: { AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( sym(2).PropertyAssignmentList->finish ()); node->lbraceToken = loc(1); @@ -765,14 +789,14 @@ case 98: { sym(1).Node = node; } break; -case 99: { +case 100: { AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); node->lparenToken = loc(1); node->rparenToken = loc(3); sym(1).Node = node; } break; -case 100: { +case 101: { if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, QLatin1String("Ignored annotation"))); @@ -792,48 +816,48 @@ case 100: { } } break; -case 101: { +case 102: { sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); } break; -case 102: { +case 103: { sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); } break; -case 103: { +case 104: { AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, (AST::Elision *) 0, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 104: { +case 105: { AST::ElementList *node = new (pool) AST::ElementList(sym(1).ElementList, sym(3).Elision->finish(), sym(4).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 105: { +case 106: { AST::Elision *node = new (pool) AST::Elision(); node->commaToken = loc(1); sym(1).Node = node; } break; -case 106: { +case 107: { AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); node->commaToken = loc(2); sym(1).Node = node; } break; -case 107: { +case 108: { AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( sym(1).PropertyName, sym(3).Expression); node->colonToken = loc(2); sym(1).Node = node; } break; -case 108: { +case 109: { AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( sym(2).PropertyName, sym(6).FunctionBody); node->getSetToken = loc(1); @@ -844,7 +868,7 @@ case 108: { sym(1).Node = node; } break; -case 109: { +case 110: { AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody); node->getSetToken = loc(1); @@ -855,56 +879,56 @@ case 109: { sym(1).Node = node; } break; -case 110: { +case 111: { sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment); } break; -case 111: { +case 112: { AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList( sym(1).PropertyAssignmentList, sym(3).PropertyAssignment); node->commaToken = loc(2); sym(1).Node = node; } break; -case 112: { +case 113: { AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 113: { +case 114: { AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 114: { +case 115: { AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 115: { +case 116: { AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 151: { +case 152: { AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); node->lbracketToken = loc(2); node->rbracketToken = loc(4); sym(1).Node = node; } break; -case 152: { +case 153: { AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); node->dotToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 153: { +case 154: { AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); node->newToken = loc(1); node->lparenToken = loc(3); @@ -912,384 +936,384 @@ case 153: { sym(1).Node = node; } break; -case 155: { +case 156: { AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); node->newToken = loc(1); sym(1).Node = node; } break; -case 156: { +case 157: { AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); node->lparenToken = loc(2); node->rparenToken = loc(4); sym(1).Node = node; } break; -case 157: { +case 158: { AST::CallExpression *node = new (pool) AST::CallExpression(sym(1).Expression, sym(3).ArgumentList); node->lparenToken = loc(2); node->rparenToken = loc(4); sym(1).Node = node; } break; -case 158: { +case 159: { AST::ArrayMemberExpression *node = new (pool) AST::ArrayMemberExpression(sym(1).Expression, sym(3).Expression); node->lbracketToken = loc(2); node->rbracketToken = loc(4); sym(1).Node = node; } break; -case 159: { +case 160: { AST::FieldMemberExpression *node = new (pool) AST::FieldMemberExpression(sym(1).Expression, stringRef(3)); node->dotToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 160: { +case 161: { sym(1).Node = 0; } break; -case 161: { +case 162: { sym(1).Node = sym(1).ArgumentList->finish(); } break; -case 162: { +case 163: { sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); } break; -case 163: { +case 164: { AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 167: { +case 168: { AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); node->incrementToken = loc(2); sym(1).Node = node; } break; -case 168: { +case 169: { AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); node->decrementToken = loc(2); sym(1).Node = node; } break; -case 170: { +case 171: { AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); node->deleteToken = loc(1); sym(1).Node = node; } break; -case 171: { +case 172: { AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); node->voidToken = loc(1); sym(1).Node = node; } break; -case 172: { +case 173: { AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); node->typeofToken = loc(1); sym(1).Node = node; } break; -case 173: { +case 174: { AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); node->incrementToken = loc(1); sym(1).Node = node; } break; -case 174: { +case 175: { AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); node->decrementToken = loc(1); sym(1).Node = node; } break; -case 175: { +case 176: { AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); node->plusToken = loc(1); sym(1).Node = node; } break; -case 176: { +case 177: { AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); node->minusToken = loc(1); sym(1).Node = node; } break; -case 177: { +case 178: { AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); node->tildeToken = loc(1); sym(1).Node = node; } break; -case 178: { +case 179: { AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); node->notToken = loc(1); sym(1).Node = node; } break; -case 180: { +case 181: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Mul, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 181: { +case 182: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Div, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 182: { +case 183: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Mod, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 184: { +case 185: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Add, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 185: { +case 186: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Sub, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 187: { +case 188: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::LShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 188: { +case 189: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::RShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 189: { +case 190: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::URShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 191: { +case 192: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Lt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 192: { +case 193: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Gt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 193: { +case 194: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Le, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 194: { +case 195: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Ge, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 195: { +case 196: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 196: { +case 197: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::In, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 198: { +case 199: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Lt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 199: { +case 200: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Gt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 200: { +case 201: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Le, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 201: { +case 202: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Ge, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 202: { +case 203: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 204: { +case 205: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Equal, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 205: { +case 206: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 206: { +case 207: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 207: { +case 208: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 209: { +case 210: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Equal, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 210: { +case 211: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 211: { +case 212: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 212: { +case 213: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 214: { +case 215: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 216: { +case 217: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 218: { +case 219: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitXor, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 220: { +case 221: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitXor, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 222: { +case 223: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitOr, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 224: { +case 225: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::BitOr, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 226: { +case 227: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 228: { +case 229: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 230: { +case 231: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Or, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 232: { +case 233: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::Or, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 234: { +case 235: { AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1297,7 +1321,7 @@ case 234: { sym(1).Node = node; } break; -case 236: { +case 237: { AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1305,112 +1329,112 @@ case 236: { sym(1).Node = node; } break; -case 238: { +case 239: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 240: { +case 241: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, sym(2).ival, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 241: { +case 242: { sym(1).ival = QSOperator::Assign; } break; -case 242: { +case 243: { sym(1).ival = QSOperator::InplaceMul; } break; -case 243: { +case 244: { sym(1).ival = QSOperator::InplaceDiv; } break; -case 244: { +case 245: { sym(1).ival = QSOperator::InplaceMod; } break; -case 245: { +case 246: { sym(1).ival = QSOperator::InplaceAdd; } break; -case 246: { +case 247: { sym(1).ival = QSOperator::InplaceSub; } break; -case 247: { +case 248: { sym(1).ival = QSOperator::InplaceLeftShift; } break; -case 248: { +case 249: { sym(1).ival = QSOperator::InplaceRightShift; } break; -case 249: { +case 250: { sym(1).ival = QSOperator::InplaceURightShift; } break; -case 250: { +case 251: { sym(1).ival = QSOperator::InplaceAnd; } break; -case 251: { +case 252: { sym(1).ival = QSOperator::InplaceXor; } break; -case 252: { +case 253: { sym(1).ival = QSOperator::InplaceOr; } break; -case 254: { +case 255: { AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 255: { +case 256: { sym(1).Node = 0; } break; -case 258: { +case 259: { AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 259: { +case 260: { sym(1).Node = 0; } break; -case 276: { +case 277: { AST::Block *node = new (pool) AST::Block(sym(2).StatementList); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 277: { +case 278: { sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); } break; -case 278: { +case 279: { sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); } break; -case 279: { +case 280: { sym(1).Node = 0; } break; -case 280: { +case 281: { sym(1).Node = sym(1).StatementList->finish (); } break; -case 282: { +case 283: { AST::VariableStatement *node = new (pool) AST::VariableStatement( sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); node->declarationKindToken = loc(1); @@ -1418,76 +1442,76 @@ case 282: { sym(1).Node = node; } break; -case 283: { +case 284: { sym(1).ival = T_CONST; } break; -case 284: { +case 285: { sym(1).ival = T_VAR; } break; -case 285: { +case 286: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); } break; -case 286: { +case 287: { AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( sym(1).VariableDeclarationList, sym(3).VariableDeclaration); node->commaToken = loc(2); sym(1).Node = node; } break; -case 287: { +case 288: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); } break; -case 288: { +case 289: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); } break; -case 289: { +case 290: { AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 290: { +case 291: { AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 291: { +case 292: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 292: { +case 293: { sym(1).Node = 0; } break; -case 294: { +case 295: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 295: { +case 296: { sym(1).Node = 0; } break; -case 297: { +case 298: { AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); node->semicolonToken = loc(1); sym(1).Node = node; } break; -case 299: { +case 300: { AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 300: { +case 301: { AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1496,7 +1520,7 @@ case 300: { sym(1).Node = node; } break; -case 301: { +case 302: { AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1504,7 +1528,7 @@ case 301: { sym(1).Node = node; } break; -case 304: { +case 305: { AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); node->doToken = loc(1); node->whileToken = loc(3); @@ -1514,7 +1538,7 @@ case 304: { sym(1).Node = node; } break; -case 305: { +case 306: { AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); node->whileToken = loc(1); node->lparenToken = loc(2); @@ -1522,7 +1546,7 @@ case 305: { sym(1).Node = node; } break; -case 306: { +case 307: { AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); node->forToken = loc(1); @@ -1533,7 +1557,7 @@ case 306: { sym(1).Node = node; } break; -case 307: { +case 308: { AST::LocalForStatement *node = new (pool) AST::LocalForStatement( sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); @@ -1546,7 +1570,7 @@ case 307: { sym(1).Node = node; } break; -case 308: { +case 309: { AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, sym(5).Expression, sym(7).Statement); node->forToken = loc(1); @@ -1556,7 +1580,7 @@ case 308: { sym(1).Node = node; } break; -case 309: { +case 310: { AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); node->forToken = loc(1); @@ -1567,14 +1591,14 @@ case 309: { sym(1).Node = node; } break; -case 311: { +case 312: { AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); node->continueToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 313: { +case 314: { AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); node->continueToken = loc(1); node->identifierToken = loc(2); @@ -1582,14 +1606,14 @@ case 313: { sym(1).Node = node; } break; -case 315: { +case 316: { AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); node->breakToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 317: { +case 318: { AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); node->breakToken = loc(1); node->identifierToken = loc(2); @@ -1597,14 +1621,14 @@ case 317: { sym(1).Node = node; } break; -case 319: { +case 320: { AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); node->returnToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 320: { +case 321: { AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); node->withToken = loc(1); node->lparenToken = loc(2); @@ -1612,7 +1636,7 @@ case 320: { sym(1).Node = node; } break; -case 321: { +case 322: { AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); node->switchToken = loc(1); node->lparenToken = loc(2); @@ -1620,83 +1644,83 @@ case 321: { sym(1).Node = node; } break; -case 322: { +case 323: { AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 323: { +case 324: { AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); node->lbraceToken = loc(1); node->rbraceToken = loc(5); sym(1).Node = node; } break; -case 324: { +case 325: { sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); } break; -case 325: { +case 326: { sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); } break; -case 326: { +case 327: { sym(1).Node = 0; } break; -case 327: { +case 328: { sym(1).Node = sym(1).CaseClauses->finish (); } break; -case 328: { +case 329: { AST::CaseClause *node = new (pool) AST::CaseClause(sym(2).Expression, sym(4).StatementList); node->caseToken = loc(1); node->colonToken = loc(3); sym(1).Node = node; } break; -case 329: { +case 330: { AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); node->defaultToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 330: { +case 331: { AST::LabelledStatement *node = new (pool) AST::LabelledStatement(stringRef(1), sym(3).Statement); node->identifierToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 332: { +case 333: { AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); node->throwToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 333: { +case 334: { AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); node->tryToken = loc(1); sym(1).Node = node; } break; -case 334: { +case 335: { AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); node->tryToken = loc(1); sym(1).Node = node; } break; -case 335: { +case 336: { AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch, sym(4).Finally); node->tryToken = loc(1); sym(1).Node = node; } break; -case 336: { +case 337: { AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); node->catchToken = loc(1); node->lparenToken = loc(2); @@ -1705,20 +1729,20 @@ case 336: { sym(1).Node = node; } break; -case 337: { +case 338: { AST::Finally *node = new (pool) AST::Finally(sym(2).Block); node->finallyToken = loc(1); sym(1).Node = node; } break; -case 339: { +case 340: { AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); node->debuggerToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 341: { +case 342: { AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); node->identifierToken = loc(2); @@ -1729,7 +1753,7 @@ case 341: { sym(1).Node = node; } break; -case 342: { +case 343: { AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); if (! stringRef(2).isNull()) @@ -1741,7 +1765,7 @@ case 342: { sym(1).Node = node; } break; -case 343: { +case 344: { AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody); node->functionToken = loc(1); node->lparenToken = loc(2); @@ -1751,56 +1775,56 @@ case 343: { sym(1).Node = node; } break; -case 344: { +case 345: { AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 345: { +case 346: { AST::FormalParameterList *node = new (pool) AST::FormalParameterList(sym(1).FormalParameterList, stringRef(3)); node->commaToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 346: { +case 347: { sym(1).Node = 0; } break; -case 347: { +case 348: { sym(1).Node = sym(1).FormalParameterList->finish (); } break; -case 348: { +case 349: { sym(1).Node = 0; } break; -case 350: { +case 351: { sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); } break; -case 352: { +case 353: { sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); } break; -case 353: { +case 354: { sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); } break; -case 354: { +case 355: { sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); } break; -case 355: { +case 356: { sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); } break; -case 356: { +case 357: { sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); } break; -case 357: { +case 358: { sym(1).Node = 0; } break; diff --git a/src/qml/parser/qqmljsparser_p.h b/src/qml/parser/qqmljsparser_p.h index 7533750a53..f382cd7563 100644 --- a/src/qml/parser/qqmljsparser_p.h +++ b/src/qml/parser/qqmljsparser_p.h @@ -246,9 +246,9 @@ protected: -#define J_SCRIPT_REGEXPLITERAL_RULE1 90 +#define J_SCRIPT_REGEXPLITERAL_RULE1 91 -#define J_SCRIPT_REGEXPLITERAL_RULE2 91 +#define J_SCRIPT_REGEXPLITERAL_RULE2 92 QT_QML_END_NAMESPACE diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp index 7e4a643ffa..3ed0aa7446 100644 --- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp @@ -86,7 +86,6 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml"; - invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml"; invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.5.qml"; diff --git a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml index 319e1f5bc5..f028e5dcac 100644 --- a/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml +++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtQuick 2.0 as Qt47 -Qt.QtObject { +Qt47.QtObject { property Qt47.QtObject objectProperty property list objectPropertyList diff --git a/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml new file mode 100644 index 0000000000..5ad62edab3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/namespacedPropertyTypes.qml @@ -0,0 +1,8 @@ +import QtQuick 2.0 as MyQuick + +MyQuick.Item { + property MyQuick.Item myProp; + property list myList; + default property list myDefaultList; + signal mySignal(MyQuick.Item someItem) +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 658b4f5852..f586f7d429 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -255,6 +255,7 @@ private slots: void arrayBuffer(); void defaultListProperty(); + void namespacedPropertyTypes(); private: QQmlEngine engine; @@ -1397,7 +1398,6 @@ void tst_qqmllanguage::dynamicObjectProperties() } { QQmlComponent component(&engine, testFileUrl("dynamicObjectProperties.2.qml")); - QEXPECT_FAIL("", "QTBUG-10822", Abort); VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); @@ -4242,6 +4242,14 @@ void tst_qqmllanguage::defaultListProperty() QScopedPointer o(component.create()); } +void tst_qqmllanguage::namespacedPropertyTypes() +{ + QQmlComponent component(&engine, testFileUrl("namespacedPropertyTypes.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From 63c34dc6c1c6f24f8e83f295adc70fdcc392f8c5 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Fri, 18 Nov 2016 17:35:29 +0100 Subject: StocQt example: Use QtQuick.Layouts instead of anchors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move the StockListView delegate and the top banner to separate files. - Use QtQuick.Layouts in place of anchors for most parts, improving code readability and app scalability. Change-Id: Ie8f13ef261bb343f15e9484bd15f8b94101daeb5 Reviewed-by: Topi Reiniƶ --- examples/quick/demos/stocqt/content/Banner.qml | 86 ++++ examples/quick/demos/stocqt/content/CheckBox.qml | 1 - examples/quick/demos/stocqt/content/StockChart.qml | 535 +++++++++++---------- examples/quick/demos/stocqt/content/StockInfo.qml | 99 ++-- .../demos/stocqt/content/StockListDelegate.qml | 153 ++++++ .../quick/demos/stocqt/content/StockListView.qml | 124 +---- .../demos/stocqt/content/StockSettingsPanel.qml | 204 ++++---- examples/quick/demos/stocqt/content/StockView.qml | 67 ++- examples/quick/demos/stocqt/content/qmldir | 2 + examples/quick/demos/stocqt/stocqt.qml | 115 ++--- examples/quick/demos/stocqt/stocqt.qrc | 2 + 11 files changed, 734 insertions(+), 654 deletions(-) create mode 100644 examples/quick/demos/stocqt/content/Banner.qml create mode 100644 examples/quick/demos/stocqt/content/StockListDelegate.qml diff --git a/examples/quick/demos/stocqt/content/Banner.qml b/examples/quick/demos/stocqt/content/Banner.qml new file mode 100644 index 0000000000..8d64e88410 --- /dev/null +++ b/examples/quick/demos/stocqt/content/Banner.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Layouts 1.1 + +Rectangle { + id: banner + height: 80 + color: "#000000" + + GridLayout { + anchors.fill: parent + rows: 1 + columns: 3 + Rectangle { + Layout.leftMargin: 10 + Layout.topMargin: 20 + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Image { + id: arrow + source: "./images/icon-left-arrow.png" + visible: root.currentIndex == 1 ? true : false + + MouseArea { + anchors.fill: parent + onClicked: root.currentIndex = 0; + } + } + } + Text { + id: stocText + color: "#ffffff" + font.family: "Abel" + font.pointSize: 40 + text: "Stoc" + Layout.alignment: Qt.AlignRight + Layout.leftMargin: parent.width / 2.5 + } + Text { + id: qtText + color: "#5caa15" + font.family: "Abel" + font.pointSize: 40 + text: "Qt" + Layout.fillWidth: true + } + } +} diff --git a/examples/quick/demos/stocqt/content/CheckBox.qml b/examples/quick/demos/stocqt/content/CheckBox.qml index 5702b17709..f62eb538fb 100644 --- a/examples/quick/demos/stocqt/content/CheckBox.qml +++ b/examples/quick/demos/stocqt/content/CheckBox.qml @@ -60,7 +60,6 @@ Item { id: checkbox width: 30 height: 30 - anchors.left: parent.left border.color: "#999999" border.width: 1 antialiasing: true diff --git a/examples/quick/demos/stocqt/content/StockChart.qml b/examples/quick/demos/stocqt/content/StockChart.qml index cd8b9f3db9..e90aba3aef 100644 --- a/examples/quick/demos/stocqt/content/StockChart.qml +++ b/examples/quick/demos/stocqt/content/StockChart.qml @@ -39,20 +39,19 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQuick.Layouts 1.1 import "." Rectangle { id: chart - width: 320 - height: 200 property var stockModel: null property var startDate: new Date() property var endDate: new Date() - property string activeChart: "year" + property string activeChart: "week" property var settings property int gridSize: 4 - property real gridStep: gridSize ? (width - canvas.tickMargin) / gridSize : canvas.xGridStep + property real gridStep: gridSize ? (canvas.width - canvas.tickMargin) / gridSize : canvas.xGridStep function update() { endDate = new Date(); @@ -66,7 +65,7 @@ Rectangle { chart.startDate = new Date(chart.endDate.getFullYear(), chart.endDate.getMonth() - 1, chart.endDate.getDate()); - gridSize = 0; + gridSize = 4; } else if (chart.activeChart === "week") { chart.startDate = new Date(chart.endDate.getFullYear(), @@ -74,6 +73,18 @@ Rectangle { chart.endDate.getDate() - 7); gridSize = 0; } + else if (chart.activeChart === "halfyear") { + chart.startDate = new Date(chart.endDate.getFullYear(), + chart.endDate.getMonth() - 6, + chart.endDate.getDate()); + gridSize = 6; + } + else if (chart.activeChart === "quarter") { + chart.startDate = new Date(chart.endDate.getFullYear(), + chart.endDate.getMonth() - 3, + chart.endDate.getDate()); + gridSize = 3; + } else { chart.startDate = new Date(2005, 3, 25); gridSize = 4; @@ -82,315 +93,327 @@ Rectangle { canvas.requestPaint(); } - Row { - id: activeChartRow - anchors.left: chart.left - anchors.right: chart.right - anchors.top: chart.top - anchors.topMargin: 4 - spacing: 52 - onWidthChanged: { - var buttonsLen = maxButton.width + yearButton.width + monthButton.width + weekButton.width; - var space = (width - buttonsLen) / 3; - spacing = Math.max(space, 10); + GridLayout { + anchors.fill: parent + columns: 6 + rows: 3 + columnSpacing: 4 + Button { + id: weekButton + text: "Week" + buttonEnabled: chart.activeChart === "week" + onClicked: { + chart.activeChart = "week"; + chart.update(); + } } Button { - id: maxButton - text: "Max" - buttonEnabled: chart.activeChart === "max" + id: monthButton + text: "Month" + buttonEnabled: chart.activeChart === "month" onClicked: { - chart.activeChart = "max"; + chart.activeChart = "month"; chart.update(); } } + Button { - id: yearButton - text: "Year" - buttonEnabled: chart.activeChart === "year" + id: quarterlyButton + text: "3M" + buttonEnabled: chart.activeChart === "quarter" onClicked: { - chart.activeChart = "year"; + chart.activeChart = "quarter"; chart.update(); } } + Button { - id: monthButton - text: "Month" - buttonEnabled: chart.activeChart === "month" + id: halfYearlyButton + text: "6M" + buttonEnabled: chart.activeChart === "halfyear" onClicked: { - chart.activeChart = "month"; + chart.activeChart = "halfyear"; chart.update(); } } Button { - id: weekButton - text: "Week" - buttonEnabled: chart.activeChart === "week" + id: yearButton + text: "Year" + buttonEnabled: chart.activeChart === "year" onClicked: { - chart.activeChart = "week"; + chart.activeChart = "year"; + chart.update(); + } + } + Button { + id: maxButton + text: "Max" + buttonEnabled: chart.activeChart === "max" + onClicked: { + chart.activeChart = "max"; chart.update(); } } - } - Text { - id: fromDate - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 8 - anchors.left: parent.left - anchors.bottom: parent.bottom - text: "| " + startDate.toDateString() - } + Canvas { + id: canvas + Layout.fillWidth: true + Layout.fillHeight: true + Layout.columnSpan: 6 + // Uncomment below lines to use OpenGL hardware accelerated rendering. + // See Canvas documentation for available options. + // renderTarget: Canvas.FramebufferObject + // renderStrategy: Canvas.Threaded + + property int pixelSkip: 1 + property int numPoints: 1 + property int tickMargin: 34 + + property real xGridStep: (canvas.width - tickMargin) / numPoints + property real yGridOffset: canvas.height / 26 + property real yGridStep: canvas.height / 12 + + function drawBackground(ctx) { + ctx.save(); + ctx.fillStyle = "#ffffff"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + ctx.strokeStyle = "#d7d7d7"; + ctx.beginPath(); + // Horizontal grid lines + for (var i = 0; i < 12; i++) { + ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep); + ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep); + } - Text { - id: toDate - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 8 - anchors.right: parent.right - anchors.rightMargin: canvas.tickMargin - anchors.bottom: parent.bottom - text: endDate.toDateString() + " |" - } + // Vertical grid lines + var height = 35 * canvas.height / 36; + var yOffset = canvas.height - height; + var xOffset = 0; + for (i = 0; i < chart.gridSize; i++) { + ctx.moveTo(xOffset + i * chart.gridStep, yOffset); + ctx.lineTo(xOffset + i * chart.gridStep, height); + } + ctx.stroke(); + + // Right ticks + ctx.strokeStyle = "#666666"; + ctx.beginPath(); + var xStart = canvas.width - tickMargin; + ctx.moveTo(xStart, 0); + ctx.lineTo(xStart, canvas.height); + for (i = 0; i < 12; i++) { + ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep); + ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep); + } + ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep); + ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep); + ctx.closePath(); + ctx.stroke(); - Canvas { - id: canvas - - // Uncomment below lines to use OpenGL hardware accelerated rendering. - // See Canvas documentation for available options. - // renderTarget: Canvas.FramebufferObject - // renderStrategy: Canvas.Threaded - - anchors.top: activeChartRow.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: fromDate.top - - property int pixelSkip: 1 - property int numPoints: 1 - property int tickMargin: 34 - - property real xGridStep: (width - tickMargin) / numPoints - property real yGridOffset: height / 26 - property real yGridStep: height / 12 - - function drawBackground(ctx) { - ctx.save(); - ctx.fillStyle = "#ffffff"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - ctx.strokeStyle = "#d7d7d7"; - ctx.beginPath(); - // Horizontal grid lines - for (var i = 0; i < 12; i++) { - ctx.moveTo(0, canvas.yGridOffset + i * canvas.yGridStep); - ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep); + ctx.restore(); } - // Vertical grid lines - var height = 35 * canvas.height / 36; - var yOffset = canvas.height - height; - var xOffset = 0; - for (i = 0; i < chart.gridSize; i++) { - ctx.moveTo(xOffset + i * chart.gridStep, yOffset); - ctx.lineTo(xOffset + i * chart.gridStep, height); - } - ctx.stroke(); - - // Right ticks - ctx.strokeStyle = "#666666"; - ctx.beginPath(); - var xStart = canvas.width - tickMargin; - ctx.moveTo(xStart, 0); - ctx.lineTo(xStart, canvas.height); - for (i = 0; i < 12; i++) { - ctx.moveTo(xStart, canvas.yGridOffset + i * canvas.yGridStep); - ctx.lineTo(canvas.width, canvas.yGridOffset + i * canvas.yGridStep); + // Returns a shortened, readable version of the potentially + // large volume number. + function volumeToString(value) { + if (value < 1000) + return value; + var exponent = parseInt(Math.log(value) / Math.log(1000)); + var shortVal = parseFloat(parseFloat(value) / Math.pow(1000, exponent)).toFixed(1); + + // Drop the decimal point on 3-digit values to make it fit + if (shortVal >= 100.0) { + shortVal = parseFloat(shortVal).toFixed(0); + } + return shortVal + "KMBTG".charAt(exponent - 1); } - ctx.moveTo(0, canvas.yGridOffset + 9 * canvas.yGridStep); - ctx.lineTo(canvas.width, canvas.yGridOffset + 9 * canvas.yGridStep); - ctx.closePath(); - ctx.stroke(); - ctx.restore(); - } + function drawScales(ctx, high, low, vol) + { + ctx.save(); + ctx.strokeStyle = "#888888"; + ctx.font = "10px Open Sans" - // Returns a shortened, readable version of the potentially - // large volume number. - function volumeToString(value) { - if (value < 1000) - return value; - var exponent = parseInt(Math.log(value) / Math.log(1000)); - var shortVal = parseFloat(parseFloat(value) / Math.pow(1000, exponent)).toFixed(1); - - // Drop the decimal point on 3-digit values to make it fit - if (shortVal >= 100.0) { - shortVal = parseFloat(shortVal).toFixed(0); - } - return shortVal + "KMBTG".charAt(exponent - 1); - } + ctx.beginPath(); - function drawScales(ctx, high, low, vol) - { - ctx.save(); - ctx.strokeStyle = "#888888"; - ctx.font = "10px Open Sans" - ctx.beginPath(); - - // prices on y-axis - var x = canvas.width - tickMargin + 3; - var priceStep = (high - low) / 9.0; - for (var i = 0; i < 10; i += 2) { - var price = parseFloat(high - i * priceStep).toFixed(1); - ctx.text(price, x, canvas.yGridOffset + i * yGridStep - 2); - } + // prices on y-axis + var x = canvas.width - tickMargin + 3; + var priceStep = (high - low) / 9.0; + for (var i = 0; i < 10; i += 2) { + var price = parseFloat(high - i * priceStep).toFixed(1); + ctx.text(price, x, canvas.yGridOffset + i * yGridStep - 2); + } + + // volume scale + for (i = 0; i < 3; i++) { + var volume = volumeToString(vol - (i * (vol/3))); + ctx.text(volume, x, canvas.yGridOffset + (i + 9) * yGridStep + 10); + } - // volume scale - for (i = 0; i < 3; i++) { - var volume = volumeToString(vol - (i * (vol/3))); - ctx.text(volume, x, canvas.yGridOffset + (i + 9) * yGridStep + 10); + ctx.closePath(); + ctx.stroke(); + ctx.restore(); } - ctx.closePath(); - ctx.stroke(); - ctx.restore(); - } + function drawPrice(ctx, from, to, color, price, points, highest, lowest) + { + ctx.save(); + ctx.globalAlpha = 0.7; + ctx.strokeStyle = color; - function drawPrice(ctx, from, to, color, price, points, highest, lowest) - { - ctx.save(); - ctx.globalAlpha = 0.7; - ctx.strokeStyle = color; - ctx.lineWidth = 3; - ctx.beginPath(); + ctx.lineWidth = numPoints > 200 ? 1 : 3 - var end = points.length; + ctx.beginPath(); - var range = highest - lowest; - if (range == 0) { - range = 1; - } + var end = points.length; - for (var i = 0; i < end; i += pixelSkip) { - var x = points[i].x; - var y = points[i][price]; - var h = 9 * yGridStep; + var range = highest - lowest; + if (range == 0) { + range = 1; + } - y = h * (lowest - y)/range + h + yGridOffset; + for (var i = 0; i < end; i += pixelSkip) { + var x = points[i].x; + var y = points[i][price]; + var h = 9 * yGridStep; - if (i == 0) { - ctx.moveTo(x, y); - } else { - ctx.lineTo(x, y); + y = h * (lowest - y)/range + h + yGridOffset; + + if (i == 0) { + ctx.moveTo(x, y); + } else { + ctx.lineTo(x, y); + } } + ctx.stroke(); + ctx.restore(); } - ctx.stroke(); - ctx.restore(); - } - function drawVolume(ctx, from, to, color, price, points, highest) - { - ctx.save(); - ctx.fillStyle = color; - ctx.globalAlpha = 0.8; - ctx.lineWidth = 0; - ctx.beginPath(); + function drawVolume(ctx, from, to, color, price, points, highest) + { + ctx.save(); + ctx.fillStyle = color; + ctx.globalAlpha = 0.8; + ctx.lineWidth = 0; + ctx.beginPath(); + + var end = points.length; + var margin = 0; + + if (chart.activeChart === "month" || chart.activeChart === "week") { + margin = 8; + ctx.shadowOffsetX = 4; + ctx.shadowBlur = 3.5; + ctx.shadowColor = Qt.darker(color); + } - var end = points.length; - var margin = 0; + // To match the volume graph with price grid, skip drawing the initial + // volume of the first day on chart. + for (var i = 1; i < end; i += pixelSkip) { + var x = points[i - 1].x; + var y = points[i][price]; + y = canvas.height * (y / highest); + y = 3 * y / 12; + ctx.fillRect(x, canvas.height - y + yGridOffset, + canvas.xGridStep - margin, y); + } - if (chart.activeChart === "month" || chart.activeChart === "week") { - margin = 8; - ctx.shadowOffsetX = 4; - ctx.shadowBlur = 3.5; - ctx.shadowColor = Qt.darker(color); + ctx.stroke(); + ctx.restore(); } - // To match the volume graph with price grid, skip drawing the initial - // volume of the first day on chart. - for (var i = 1; i < end; i += pixelSkip) { - var x = points[i - 1].x; - var y = points[i][price]; - y = canvas.height * (y / highest); - y = 3 * y / 12; - ctx.fillRect(x, canvas.height - y + yGridOffset, - canvas.xGridStep - margin, y); + function drawError(ctx, msg) + { + ctx.save(); + ctx.strokeStyle = "#888888"; + ctx.font = "24px Open Sans" + ctx.textAlign = "center" + ctx.shadowOffsetX = 4; + ctx.shadowOffsetY = 4; + ctx.shadowBlur = 1.5; + ctx.shadowColor = "#aaaaaa"; + ctx.beginPath(); + + ctx.fillText(msg, (canvas.width - tickMargin) / 2, + (canvas.height - yGridOffset - yGridStep) / 2); + + ctx.closePath(); + ctx.stroke(); + ctx.restore(); } - ctx.stroke(); - ctx.restore(); - } + onPaint: { + numPoints = stockModel.indexOf(chart.startDate); - function drawError(ctx, msg) - { - ctx.save(); - ctx.strokeStyle = "#888888"; - ctx.font = "24px Open Sans" - ctx.textAlign = "center" - ctx.shadowOffsetX = 4; - ctx.shadowOffsetY = 4; - ctx.shadowBlur = 1.5; - ctx.shadowColor = "#aaaaaa"; - ctx.beginPath(); - - ctx.fillText(msg, (canvas.width - tickMargin) / 2, - (canvas.height - yGridOffset - yGridStep) / 2); - - ctx.closePath(); - ctx.stroke(); - ctx.restore(); - } + if (chart.gridSize == 0) + chart.gridSize = numPoints - onPaint: { - numPoints = stockModel.indexOf(chart.startDate); + var ctx = canvas.getContext("2d"); + ctx.globalCompositeOperation = "source-over"; + ctx.lineWidth = 1; - if (chart.gridSize == 0) - chart.gridSize = numPoints + drawBackground(ctx); - var ctx = canvas.getContext("2d"); - ctx.globalCompositeOperation = "source-over"; - ctx.lineWidth = 1; + if (!stockModel.ready) { + drawError(ctx, "No data available."); + return; + } - drawBackground(ctx); + var highestPrice = 0; + var highestVolume = 0; + var lowestPrice = -1; + var points = []; + for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) { + var price = stockModel.get(i); + if (parseFloat(highestPrice) < parseFloat(price.high)) + highestPrice = price.high; + if (parseInt(highestVolume, 10) < parseInt(price.volume, 10)) + highestVolume = price.volume; + if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low)) + lowestPrice = price.low; + points.push({ + x: j * xGridStep, + open: price.open, + close: price.close, + high: price.high, + low: price.low, + volume: price.volume + }); + } - if (!stockModel.ready) { - drawError(ctx, "No data available."); - return; + if (settings.drawHighPrice) + drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice); + if (settings.drawLowPrice) + drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice); + if (settings.drawOpenPrice) + drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice); + if (settings.drawClosePrice) + drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice); + + drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume); + drawScales(ctx, highestPrice, lowestPrice, highestVolume); } + } - var highestPrice = 0; - var highestVolume = 0; - var lowestPrice = -1; - var points = []; - for (var i = numPoints, j = 0; i >= 0 ; i -= pixelSkip, j += pixelSkip) { - var price = stockModel.get(i); - if (parseFloat(highestPrice) < parseFloat(price.high)) - highestPrice = price.high; - if (parseInt(highestVolume, 10) < parseInt(price.volume, 10)) - highestVolume = price.volume; - if (lowestPrice < 0 || parseFloat(lowestPrice) > parseFloat(price.low)) - lowestPrice = price.low; - points.push({ - x: j * xGridStep, - open: price.open, - close: price.close, - high: price.high, - low: price.low, - volume: price.volume - }); - } - if (settings.drawHighPrice) - drawPrice(ctx, 0, numPoints, settings.highColor, "high", points, highestPrice, lowestPrice); - if (settings.drawLowPrice) - drawPrice(ctx, 0, numPoints, settings.lowColor, "low", points, highestPrice, lowestPrice); - if (settings.drawOpenPrice) - drawPrice(ctx, 0, numPoints,settings.openColor, "open", points, highestPrice, lowestPrice); - if (settings.drawClosePrice) - drawPrice(ctx, 0, numPoints, settings.closeColor, "close", points, highestPrice, lowestPrice); - - drawVolume(ctx, 0, numPoints, settings.volumeColor, "volume", points, highestVolume); - drawScales(ctx, highestPrice, lowestPrice, highestVolume); + Text { + id: fromDate + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 8 + Layout.alignment: Qt.AlignLeft + text: "| " + startDate.toDateString() + } + Text { + id: toDate + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 8 + Layout.alignment: Qt.AlignRight + Layout.rightMargin: canvas.tickMargin + Layout.columnSpan: 5 + text: endDate.toDateString() + " |" } } } diff --git a/examples/quick/demos/stocqt/content/StockInfo.qml b/examples/quick/demos/stocqt/content/StockInfo.qml index 88f540fa09..2935e74db9 100644 --- a/examples/quick/demos/stocqt/content/StockInfo.qml +++ b/examples/quick/demos/stocqt/content/StockInfo.qml @@ -39,42 +39,43 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQuick.Layouts 1.1 import "." Rectangle { id: root - width: 440 - height: 160 color: "transparent" property var stock: null - Column { - id: stockColumn + GridLayout { + id: stockInfoLayout anchors.fill: parent - spacing: 4 + columns: 2 + rows: 3 + rowSpacing: 4 - Flow { - anchors { left: parent.left; right: parent.right } - spacing: 12 - - Text { - id: stockIdText - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 28 - font.weight: Font.DemiBold - text: root.stock.stockId - } + Text { + id: stockIdText + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 28 + font.weight: Font.DemiBold + text: root.stock.stockId + Layout.alignment: Qt.AlignLeft | Qt.AlignBottom + Layout.leftMargin: 10 + } - Text { - id: price - color: "#6d6d6d" - font.family: Settings.fontFamily - font.pointSize: 28 - font.weight: Font.DemiBold - text: parseFloat(root.stock.stockPrice).toFixed(2); - } + Text { + id: price + color: "#6d6d6d" + font.family: Settings.fontFamily + font.pointSize: 28 + font.weight: Font.DemiBold + text: parseFloat(root.stock.stockPrice).toFixed(2); + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignBottom + Layout.leftMargin: 5 } Text { @@ -82,38 +83,38 @@ Rectangle { color: "#0c0c0c" font.family: Settings.fontFamily font.pointSize: 16 - width: stockColumn.width elide: Text.ElideRight maximumLineCount: 3 wrapMode: Text.WordWrap text: root.stock.stockName + Layout.leftMargin: 10 + Layout.columnSpan: 2 + Layout.alignment: Qt.AlignLeft } - Flow { - anchors { left: parent.left; right: parent.right } - spacing: 12 - Text { - id: priceChange - horizontalAlignment: Text.AlignRight - color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930" - font.family: Settings.fontFamily - font.pointSize: 18 - text: parseFloat(root.stock.stockPriceChanged).toFixed(2); - } + Text { + id: priceChange + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Layout.leftMargin: 10 + color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930" + font.family: Settings.fontFamily + font.pointSize: 18 + text: parseFloat(root.stock.stockPriceChanged).toFixed(2); + } - Text { - id: priceChangePercentage - horizontalAlignment: Text.AlignRight - color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930" - font.family: Settings.fontFamily - font.pointSize: 18 - font.weight: Font.DemiBold - text: "(" + - parseFloat(root.stock.stockPriceChanged / - (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) + - "%)" - } + Text { + id: priceChangePercentage + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + color: root.stock.stockPriceChanged < 0 ? "#d40000" : "#328930" + font.family: Settings.fontFamily + font.pointSize: 18 + font.weight: Font.DemiBold + Layout.fillWidth: true + text: "(" + + parseFloat(root.stock.stockPriceChanged / + (root.stock.stockPrice - root.stock.stockPriceChanged) * 100.0).toFixed(2) + + "%)" } } } diff --git a/examples/quick/demos/stocqt/content/StockListDelegate.qml b/examples/quick/demos/stocqt/content/StockListDelegate.qml new file mode 100644 index 0000000000..f3a3ab6976 --- /dev/null +++ b/examples/quick/demos/stocqt/content/StockListDelegate.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 +import QtQuick.Layouts 1.1 +import "." + +Rectangle { + height: 102 + width: parent.width + color: "transparent" + MouseArea { + anchors.fill: parent; + onClicked: { + if (view.currentIndex == index) + mainRect.currentIndex = 1; + else + view.currentIndex = index; + } + } + GridLayout { + id: stockGrid + columns: 3 + rows: 2 + anchors.fill: parent + + Text { + id: stockIdText + Layout.alignment: Qt.AlignLeft | Qt.AlignBottom + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 20 + font.weight: Font.Bold + verticalAlignment: Text.AlignVCenter + text: stockId + } + + Text { + id: stockValueText + Layout.preferredWidth: 100 + Layout.alignment: Qt.AlignRight | Qt.AlignBottom + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 20 + font.bold: true + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: value + } + Text { + id: stockValueChangeText + Layout.preferredWidth: 135 + Layout.rightMargin: 10 + Layout.alignment: Qt.AlignRight | Qt.AlignBottom + color: "#328930" + font.family: Settings.fontFamily + font.pointSize: 20 + font.bold: true + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: change + onTextChanged: { + if (parseFloat(text) >= 0.0) + color = "#328930"; + else + color = "#d40000"; + } + } + Text { + id: stockNameText + Layout.preferredWidth: 300 + Layout.leftMargin: 10 + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 16 + font.bold: false + elide: Text.ElideRight + maximumLineCount: 1 + verticalAlignment: Text.AlignVCenter + text: name + } + + Item {Layout.fillWidth: true } + + Text { + id: stockValueChangePercentageText + Layout.fillWidth: true + Layout.alignment: Qt.AlignRight | Qt.AlignTop + Layout.rightMargin: 10 + color: "#328930" + font.family: Settings.fontFamily + font.pointSize: 18 + font.bold: false + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + text: changePercentage + onTextChanged: { + if (parseFloat(text) >= 0.0) + color = "#328930"; + else + color = "#d40000"; + } + } + } + + Rectangle { + id: endingLine + anchors.top: stockGrid.bottom + height: 1 + width: parent.width + color: "#d7d7d7" + } +} + diff --git a/examples/quick/demos/stocqt/content/StockListView.qml b/examples/quick/demos/stocqt/content/StockListView.qml index d2bd52a69d..177580cf6b 100644 --- a/examples/quick/demos/stocqt/content/StockListView.qml +++ b/examples/quick/demos/stocqt/content/StockListView.qml @@ -43,8 +43,6 @@ import "." Rectangle { id: root - width: 320 - height: 410 anchors.top: parent.top anchors.bottom: parent.bottom color: "white" @@ -55,13 +53,12 @@ Rectangle { ListView { id: view anchors.fill: parent - width: parent.width clip: true keyNavigationWraps: true highlightMoveDuration: 0 focus: true snapMode: ListView.SnapToItem - model: StockListModel{} + model: StockListModel {} currentIndex: -1 // Don't pre-select any item onCurrentIndexChanged: { @@ -71,124 +68,7 @@ Rectangle { } } - delegate: Rectangle { - height: 102 - width: parent.width - color: "transparent" - MouseArea { - anchors.fill: parent; - onClicked: { - if (view.currentIndex == index) - mainRect.currentIndex = 1; - else - view.currentIndex = index; - } - } - - Text { - id: stockIdText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.left: parent.left - anchors.leftMargin: 15 - width: 125 - height: 40 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 20 - font.weight: Font.Bold - verticalAlignment: Text.AlignVCenter - text: stockId - } - - Text { - id: stockValueText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.right: parent.right - anchors.rightMargin: 0.31 * parent.width - width: 190 - height: 40 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 20 - font.bold: true - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: value - } - - Text { - id: stockValueChangeText - anchors.top: parent.top - anchors.topMargin: 15 - anchors.right: parent.right - anchors.rightMargin: 20 - width: 135 - height: 40 - color: "#328930" - font.family: Settings.fontFamily - font.pointSize: 20 - font.bold: true - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: change - onTextChanged: { - if (parseFloat(text) >= 0.0) - color = "#328930"; - else - color = "#d40000"; - } - } - - Text { - id: stockNameText - anchors.top: stockIdText.bottom - anchors.left: parent.left - anchors.leftMargin: 15 - width: 330 - height: 30 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 16 - font.bold: false - elide: Text.ElideRight - maximumLineCount: 1 - verticalAlignment: Text.AlignVCenter - text: name - } - - Text { - id: stockValueChangePercentageText - anchors.top: stockIdText.bottom - anchors.right: parent.right - anchors.rightMargin: 20 - width: 120 - height: 30 - color: "#328930" - font.family: Settings.fontFamily - font.pointSize: 18 - font.bold: false - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: changePercentage - onTextChanged: { - if (parseFloat(text) >= 0.0) - color = "#328930"; - else - color = "#d40000"; - } - } - - Rectangle { - id: endingLine - anchors.bottom: parent.bottom - anchors.left: parent.left - height: 1 - width: parent.width - color: "#d7d7d7" - } - } + delegate: StockListDelegate {} highlight: Rectangle { width: view.width diff --git a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml index 0c34e453de..1ac1035789 100644 --- a/examples/quick/demos/stocqt/content/StockSettingsPanel.qml +++ b/examples/quick/demos/stocqt/content/StockSettingsPanel.qml @@ -39,12 +39,11 @@ ****************************************************************************/ import QtQuick 2.0 +import QtQuick.Layouts 1.1 import "." Rectangle { id: root - width: 440 - height: 160 color: "transparent" property bool drawOpenPrice: openButton.buttonEnabled @@ -58,118 +57,93 @@ Rectangle { property string lowColor: "#f30000" property string volumeColor: "#14aaff" - Text { - id: openText - anchors.left: root.left - anchors.top: root.top - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Open" - } - - Text { - id: closeText - anchors.left: root.left - anchors.top: openText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Close" - } - - Text { - id: highText - anchors.left: root.left - anchors.top: closeText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "High" - } - - Text { - id: lowText - anchors.left: root.left - anchors.top: highText.bottom - anchors.topMargin: 10 - color: "#000000" - font.family: Settings.fontFamily - font.pointSize: 19 - text: "Low" - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: openButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: openText.verticalCenter - color: openColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: closeButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: closeText.verticalCenter - color: closeColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: highButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: highText.verticalCenter - color: highColor - } - - Rectangle { - height: 4 - anchors.left: root.left - anchors.leftMargin: 114 - anchors.right: lowButton.left - anchors.rightMargin: 65 - anchors.verticalCenter: lowText.verticalCenter - color: lowColor - } - - CheckBox { - id: openButton - buttonEnabled: false - anchors.verticalCenter: openText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: closeButton - buttonEnabled: false - anchors.verticalCenter: closeText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: highButton - buttonEnabled: true - anchors.verticalCenter: highText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 - } - - CheckBox { - id: lowButton - buttonEnabled: true - anchors.verticalCenter: lowText.verticalCenter - anchors.right: root.right - anchors.rightMargin: 40 + GridLayout { + id: settingsGrid + rows: 5 + columns: 3 + rowSpacing: 4 + anchors.fill: parent + + Item { + Layout.fillHeight: true + Layout.columnSpan: 3 + } + + Text { + id: openText + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Open" + Layout.leftMargin: 10 + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: openColor + } + CheckBox { + id: openButton + buttonEnabled: false + Layout.rightMargin: 10 + } + + Text { + id: closeText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Close" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: closeColor + } + CheckBox { + id: closeButton + buttonEnabled: false + Layout.rightMargin: 10 + } + + Text { + id: highText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "High" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: highColor + } + CheckBox { + id: highButton + buttonEnabled: true + Layout.rightMargin: 10 + } + + Text { + id: lowText + Layout.leftMargin: 10 + color: "#000000" + font.family: Settings.fontFamily + font.pointSize: 19 + text: "Low" + } + Rectangle { + Layout.preferredHeight: 4 + Layout.preferredWidth: 114 + color: lowColor + } + + CheckBox { + id: lowButton + buttonEnabled: true + Layout.rightMargin: 10 + } } } diff --git a/examples/quick/demos/stocqt/content/StockView.qml b/examples/quick/demos/stocqt/content/StockView.qml index ec89c52510..d598ddd201 100644 --- a/examples/quick/demos/stocqt/content/StockView.qml +++ b/examples/quick/demos/stocqt/content/StockView.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtQuick.Window 2.1 +import QtQuick.Layouts 1.1 Rectangle { id: root @@ -60,42 +61,40 @@ Rectangle { color: "transparent" anchors.fill: parent - StockInfo { - id: stockInfo - anchors.left: parent.left - anchors.leftMargin: 10 - anchors.top: parent.top - anchors.topMargin: 15 - height: 160 - anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left - anchors.rightMargin: 20 - stock: root.stock - } + GridLayout { + anchors.fill: parent + rows: 2 + columns: Screen.primaryOrientation === Qt.PortraitOrientation ? 1 : 2 - StockChart { - id: chart - anchors.bottom: Screen.primaryOrientation === Qt.PortraitOrientation ? settingsPanel.top : parent.bottom - anchors.bottomMargin: 20 - anchors.top : Screen.primaryOrientation === Qt.PortraitOrientation ? stockInfo.bottom : parent.top - anchors.topMargin: 20 - anchors.right: parent.right - anchors.rightMargin: 20 - width: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.width - 40 : 0.6 * parent.width - stockModel: root.stock - settings: settingsPanel - } + StockInfo { + id: stockInfo + Layout.alignment: Qt.AlignTop + Layout.preferredWidth: 400 + Layout.preferredHeight: 160 + stock: root.stock + } - StockSettingsPanel { - id: settingsPanel - anchors.left: parent.left - anchors.leftMargin: 20 - anchors.right: Screen.primaryOrientation === Qt.PortraitOrientation ? parent.right : chart.left - anchors.rightMargin: 20 - anchors.bottom: parent.bottom - onDrawOpenPriceChanged: root.update() - onDrawClosePriceChanged: root.update(); - onDrawHighPriceChanged: root.update(); - onDrawLowPriceChanged: root.update(); + StockChart { + id: chart + Layout.alignment: Qt.AlignRight + Layout.margins: 5 + Layout.fillWidth: true + Layout.fillHeight: true + Layout.rowSpan: 2 + stockModel: root.stock + settings: settingsPanel + } + StockSettingsPanel { + id: settingsPanel + Layout.alignment: Qt.AlignBottom + Layout.fillHeight: true + Layout.preferredWidth: 400 + Layout.bottomMargin: 5 + onDrawOpenPriceChanged: root.update() + onDrawClosePriceChanged: root.update(); + onDrawHighPriceChanged: root.update(); + onDrawLowPriceChanged: root.update(); + } } } } diff --git a/examples/quick/demos/stocqt/content/qmldir b/examples/quick/demos/stocqt/content/qmldir index bcfa27b484..77f5ed3c56 100644 --- a/examples/quick/demos/stocqt/content/qmldir +++ b/examples/quick/demos/stocqt/content/qmldir @@ -8,3 +8,5 @@ StockListView 1.0 StockListView.qml StockModel 1.0 StockModel.qml StockSettingsPanel 1.0 StockSettingsPanel.qml StockView 1.0 StockView.qml +StockListDelegate 1.0 StockListDelegate.qml +Banner 1.0 Banner.qml diff --git a/examples/quick/demos/stocqt/stocqt.qml b/examples/quick/demos/stocqt/stocqt.qml index 6b1da1713a..a13e63fd50 100644 --- a/examples/quick/demos/stocqt/stocqt.qml +++ b/examples/quick/demos/stocqt/stocqt.qml @@ -40,6 +40,7 @@ import QtQuick 2.0 import QtQml.Models 2.1 +import QtQuick.Layouts 1.1 import "./content" Rectangle { @@ -49,90 +50,50 @@ Rectangle { property alias currentIndex: root.currentIndex - Rectangle { - id: banner - height: 80 - anchors.top: parent.top - width: parent.width - color: "#000000" + ColumnLayout { + anchors.fill: parent - Image { - id: arrow - source: "./content/images/icon-left-arrow.png" - anchors.left: banner.left - anchors.leftMargin: 20 - anchors.verticalCenter: banner.verticalCenter - visible: root.currentIndex == 1 ? true : false - - MouseArea { - anchors.fill: parent - onClicked: root.currentIndex = 0; - } - } - - Item { - id: textItem - width: stocText.width + qtText.width - height: stocText.height + qtText.height - anchors.horizontalCenter: banner.horizontalCenter - anchors.verticalCenter: banner.verticalCenter - - Text { - id: stocText - anchors.verticalCenter: textItem.verticalCenter - color: "#ffffff" - font.family: "Abel" - font.pointSize: 40 - text: "Stoc" - } - Text { - id: qtText - anchors.verticalCenter: textItem.verticalCenter - anchors.left: stocText.right - color: "#5caa15" - font.family: "Abel" - font.pointSize: 40 - text: "Qt" - } + Banner { + id: banner + Layout.fillWidth: true } - } - ListView { - id: root - width: parent.width - anchors.top: banner.bottom - anchors.bottom: parent.bottom - snapMode: ListView.SnapOneItem - highlightRangeMode: ListView.StrictlyEnforceRange - highlightMoveDuration: 250 - focus: false - orientation: ListView.Horizontal - boundsBehavior: Flickable.StopAtBounds + ListView { + id: root + Layout.fillHeight: true + Layout.fillWidth: true + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange + highlightMoveDuration: 250 + focus: false + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds - StockModel { - id: stock - stockId: listView.currentStockId - stockName: listView.currentStockName - onStockIdChanged: stock.updateStock(); - onDataReady: { - root.currentIndex = 1 - stockView.update() + StockModel { + id: stock + stockId: listView.currentStockId + stockName: listView.currentStockName + onStockIdChanged: stock.updateStock(); + onDataReady: { + root.currentIndex = 1 + stockView.update() + } } - } - model: ObjectModel { - StockListView { - id: listView - width: root.width - height: root.height - } + model: ObjectModel { + StockListView { + id: listView + width: root.width + height: root.height + } - StockView { - id: stockView - width: root.width - height: root.height - stocklist: listView - stock: stock + StockView { + id: stockView + width: root.width + height: root.height + stocklist: listView + stock: stock + } } } } diff --git a/examples/quick/demos/stocqt/stocqt.qrc b/examples/quick/demos/stocqt/stocqt.qrc index 920e56d4d0..ab7772a62a 100644 --- a/examples/quick/demos/stocqt/stocqt.qrc +++ b/examples/quick/demos/stocqt/stocqt.qrc @@ -16,5 +16,7 @@ content/StockInfo.qml content/Settings.qml content/+windows/Settings.qml + content/StockListDelegate.qml + content/Banner.qml -- cgit v1.2.3 From b19ebe1d23e1f2fd334cef4ec2731ab5cc69dbd7 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 22 Nov 2016 12:26:54 +0100 Subject: Fix SignalSpy with QQmlPropertyMap signals 2e7d4ecdc59942b484159ca827f5d5dbc8787a1b caused the regression. To fix the regression I try accessing the signal name first and if it is not a function try accessing the handler name. Comes with a unit test to test both cases. Change-Id: I3897f344df9c6219636c70259eed503d9b76f09e Reviewed-by: Qt CI Bot Reviewed-by: Simon Hausmann --- src/imports/testlib/SignalSpy.qml | 10 ++- tests/auto/auto.pro | 1 + tests/auto/quicktest/quicktest.pro | 3 + tests/auto/quicktest/signalspy/data/signalspy.qml | 60 ++++++++++++++ tests/auto/quicktest/signalspy/mypropertymap.cpp | 38 +++++++++ tests/auto/quicktest/signalspy/mypropertymap.h | 41 ++++++++++ tests/auto/quicktest/signalspy/signalspy.pro | 9 +++ tests/auto/quicktest/signalspy/tst_signalspy.cpp | 95 +++++++++++++++++++++++ 8 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 tests/auto/quicktest/quicktest.pro create mode 100644 tests/auto/quicktest/signalspy/data/signalspy.qml create mode 100644 tests/auto/quicktest/signalspy/mypropertymap.cpp create mode 100644 tests/auto/quicktest/signalspy/mypropertymap.h create mode 100644 tests/auto/quicktest/signalspy/signalspy.pro create mode 100644 tests/auto/quicktest/signalspy/tst_signalspy.cpp diff --git a/src/imports/testlib/SignalSpy.qml b/src/imports/testlib/SignalSpy.qml index 200fc725f7..8a8e844a21 100644 --- a/src/imports/testlib/SignalSpy.qml +++ b/src/imports/testlib/SignalSpy.qml @@ -230,8 +230,14 @@ Item { qtest_prevSignalName = "" } if (target != null && signalName != "") { - var handlerName = qtest_signalHandlerName(signalName) - var func = target[handlerName] + // Look for the signal name in the object + var func = target[signalName] + if (typeof func !== "function") { + // If it is not a function, try looking for signal handler + // i.e. (onSignal) this is needed for cases where there is a property + // and a signal with the same name, e.g. Mousearea.pressed + func = target[qtest_signalHandlerName(signalName)] + } if (func === undefined) { spy.qtest_valid = false console.log("Signal '" + signalName + "' not found") diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 556f5ddc7a..f25742fb14 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs SUBDIRS=\ qml \ quick \ + quicktest \ qmltest \ qmldevtools \ cmake \ diff --git a/tests/auto/quicktest/quicktest.pro b/tests/auto/quicktest/quicktest.pro new file mode 100644 index 0000000000..3b4ec23a64 --- /dev/null +++ b/tests/auto/quicktest/quicktest.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = \ + signalspy diff --git a/tests/auto/quicktest/signalspy/data/signalspy.qml b/tests/auto/quicktest/signalspy/data/signalspy.qml new file mode 100644 index 0000000000..6c365e296a --- /dev/null +++ b/tests/auto/quicktest/signalspy/data/signalspy.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.1 +import MyImport 1.0 + +Rectangle { + id:rect + width: 200 + height: 200 + color:"red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + MyPropertyMap { + id: propertyMap + objectName: "propertyMap" + } + + SignalSpy { + objectName: "mouseSpy" + target: mouseArea + signalName: "pressed" + } + + SignalSpy { + objectName: "propertyMapSpy" + target: propertyMap + signalName: "mySignal" + } +} diff --git a/tests/auto/quicktest/signalspy/mypropertymap.cpp b/tests/auto/quicktest/signalspy/mypropertymap.cpp new file mode 100644 index 0000000000..91bd93dde0 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mypropertymap.h" + +MyPropertyMap::MyPropertyMap(QObject *parent): QQmlPropertyMap(this, parent) +{ +} + +MyPropertyMap::~MyPropertyMap() +{ +} + diff --git a/tests/auto/quicktest/signalspy/mypropertymap.h b/tests/auto/quicktest/signalspy/mypropertymap.h new file mode 100644 index 0000000000..d69548fe88 --- /dev/null +++ b/tests/auto/quicktest/signalspy/mypropertymap.h @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class MyPropertyMap : public QQmlPropertyMap +{ + Q_OBJECT + +public: + MyPropertyMap(QObject *parent = nullptr); + ~MyPropertyMap(); + +Q_SIGNALS: + void mySignal(); +}; diff --git a/tests/auto/quicktest/signalspy/signalspy.pro b/tests/auto/quicktest/signalspy/signalspy.pro new file mode 100644 index 0000000000..c8f9be1f36 --- /dev/null +++ b/tests/auto/quicktest/signalspy/signalspy.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_signalspy +macos:CONFIG -= app_bundle + +SOURCES += tst_signalspy.cpp mypropertymap.cpp +HEADERS += mypropertymap.h +QT += quick testlib + +include (../../shared/util.pri) diff --git a/tests/auto/quicktest/signalspy/tst_signalspy.cpp b/tests/auto/quicktest/signalspy/tst_signalspy.cpp new file mode 100644 index 0000000000..f54da7819c --- /dev/null +++ b/tests/auto/quicktest/signalspy/tst_signalspy.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include + +#include "../../shared/util.h" +#include "mypropertymap.h" + +class tst_SignalSpy : public QQmlDataTest +{ + Q_OBJECT +public: + tst_SignalSpy(); + +private slots: + void testValid(); + void testCount(); + +private: + QQmlEngine engine; +}; + +tst_SignalSpy::tst_SignalSpy() +{ + qmlRegisterType("MyImport", 1, 0, "MyPropertyMap"); +} + +void tst_SignalSpy::testValid() +{ + QQuickView window; + window.setSource(testFileUrl("signalspy.qml")); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild("mouseSpy"); + QVERIFY(mouseSpy->property("valid").toBool()); + + QObject *propertyMapSpy = window.rootObject()->findChild("propertyMapSpy"); + QVERIFY(propertyMapSpy->property("valid").toBool()); +} + +void tst_SignalSpy::testCount() +{ + QQuickView window; + window.resize(200, 200); + window.setSource(testFileUrl("signalspy.qml")); + window.show(); + QTest::qWaitForWindowActive(&window); + QVERIFY(window.rootObject() != 0); + + QObject *mouseSpy = window.rootObject()->findChild("mouseSpy"); + QCOMPARE(mouseSpy->property("count").toInt(), 0); + + QObject *propertyMapSpy = window.rootObject()->findChild("propertyMapSpy"); + QCOMPARE(propertyMapSpy->property("count").toInt(), 0); + + QTest::mouseClick(&window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(100, 100)); + QTRY_COMPARE(mouseSpy->property("count").toInt(), 1); + + MyPropertyMap *propertyMap = static_cast(window.rootObject()->findChild("propertyMap")); + Q_EMIT propertyMap->mySignal(); + QCOMPARE(propertyMapSpy->property("count").toInt(), 1); +} + +QTEST_MAIN(tst_SignalSpy) + +#include "tst_signalspy.moc" -- cgit v1.2.3 From b8e5d7b98eeef61dccf229f6a7ad5c03f4d47e9f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 11:15:46 +0100 Subject: Precalculate and cache hasQmlDependencies Change-Id: I62b5e167847871f7ead39168ac281ba10e7f7008 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4function.cpp | 1 + src/qml/jsruntime/qv4function_p.h | 1 + src/qml/jsruntime/qv4functionobject.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index caabee322a..e3f839afd2 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -55,6 +55,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, , compilationUnit(unit) , code(codePtr) , codeData(0) + , hasQmlDependencies(function->hasQmlDependencies()) { Q_UNUSED(engine); diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index aeef9ad61b..6e0ba9d764 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -68,6 +68,7 @@ struct Q_QML_EXPORT Function { InternalClass *internalClass; uint nFormals; bool activationRequired; + bool hasQmlDependencies; Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, ReturnedValue (*codePtr)(ExecutionEngine *, const uchar *)); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 2cc58b74a6..6bff0bc5e8 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -454,7 +454,7 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call scope.result = Q_V4_PROFILE(v4, f->function()); - if (f->function()->compiledFunction->hasQmlDependencies()) + if (f->function()->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); if (v4->hasException) { @@ -481,7 +481,7 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) scope.result = Q_V4_PROFILE(v4, f->function()); - if (f->function()->compiledFunction->hasQmlDependencies()) + if (f->function()->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); } @@ -553,7 +553,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData scope.result = Q_V4_PROFILE(v4, f->function()); - if (f->function()->compiledFunction->hasQmlDependencies()) + if (f->function()->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); if (v4->hasException) { @@ -592,7 +592,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal scope.result = Q_V4_PROFILE(v4, f->function()); - if (f->function()->compiledFunction->hasQmlDependencies()) + if (f->function()->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); } -- cgit v1.2.3 From d3797d72a21269a7301b195b16c5c5936c586a44 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 14:25:52 +0100 Subject: V4: Prevent repeatedly loading a QV4::Function pointer Even with LTO on, GCC6 will not optimize out the fact that a) the d() pointer won't change here, and that d()->function is constant and not need to be checked for nullptr all the time. Also prevents allocating 0 locals, which would still run most of the jsAlloca code for no good reason. Change-Id: Iaf5257743cb57d55bef5d334d1e4355590dae7c6 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 36 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 6bff0bc5e8..2521ff32e1 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -538,22 +538,24 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData callData->thisObject = v4->newObject(ic, proto); CallContext::Data ctx = CallContext::Data::createOnStack(v4); - ctx.strictMode = f->strictMode(); - ctx.callData = callData; ctx.function = f->d(); - ctx.compilationUnit = f->function()->compilationUnit; + QV4::Function *ff = ctx.function->function; + ctx.strictMode = ff->isStrict(); + ctx.callData = callData; + ctx.compilationUnit = ff->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; ctx.constantTable = ctx.compilationUnit->constants; - ctx.outer = f->scope(); - ctx.locals = scope.alloc(f->varCount()); - for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i) + ctx.outer = ctx.function->scope; + if (unsigned varCount = f->varCount()) + ctx.locals = scope.alloc(varCount); + for (int i = callData->argc; i < static_cast(ff->nFormals); ++i) callData->args[i] = Encode::undefined(); v4->pushContext(&ctx); Q_ASSERT(v4->current == &ctx); - scope.result = Q_V4_PROFILE(v4, f->function()); + scope.result = Q_V4_PROFILE(v4, ff); - if (f->function()->hasQmlDependencies) + if (ff->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); if (v4->hasException) { @@ -577,22 +579,24 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal Scoped f(scope, static_cast(that)); CallContext::Data ctx = CallContext::Data::createOnStack(v4); - ctx.strictMode = f->strictMode(); - ctx.callData = callData; ctx.function = f->d(); - ctx.compilationUnit = f->function()->compilationUnit; + QV4::Function *ff = ctx.function->function; + ctx.strictMode = ff->isStrict(); + ctx.callData = callData; + ctx.compilationUnit = ff->compilationUnit; ctx.lookups = ctx.compilationUnit->runtimeLookups; ctx.constantTable = ctx.compilationUnit->constants; - ctx.outer = f->scope(); - ctx.locals = scope.alloc(f->varCount()); - for (int i = callData->argc; i < (int)f->formalParameterCount(); ++i) + ctx.outer = ctx.function->scope; + if (unsigned varCount = f->varCount()) + ctx.locals = scope.alloc(varCount); + for (int i = callData->argc; i < static_cast(ff->nFormals); ++i) callData->args[i] = Encode::undefined(); v4->pushContext(&ctx); Q_ASSERT(v4->current == &ctx); - scope.result = Q_V4_PROFILE(v4, f->function()); + scope.result = Q_V4_PROFILE(v4, ff); - if (f->function()->hasQmlDependencies) + if (ff->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); } -- cgit v1.2.3 From f9044963096c2876dbf2e33f85d9e8946db5df90 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 22 Nov 2016 14:02:49 +0100 Subject: V4: Do not generate runtime calls when comparing ints/doubles There is no need to restrict genertion of double comparisson instructions or integer comparisson instructions to constants or values that reside in registers. We're prefectly able to load a value into a scratch register in order to generate those instructions. Change-Id: I25e832293817eed6450cb08c98dd95640326a518 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4isel_masm.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index ed1455b086..c2ca804ffa 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -69,13 +69,6 @@ using namespace QV4::JIT; namespace { -inline bool isPregOrConst(IR::Expr *e) -{ - if (IR::Temp *t = e->asTemp()) - return t->kind == IR::Temp::PhysicalRegister; - return e->asConst() != 0; -} - class QIODevicePrintStream: public FilePrintStream { Q_DISABLE_COPY(QIODevicePrintStream) @@ -1720,9 +1713,6 @@ QT_END_NAMESPACE bool InstructionSelection::visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse) { - if (!isPregOrConst(left) || !isPregOrConst(right)) - return false; - if (_as->nextBlock() == iftrue) { Assembler::Jump target = _as->branchDouble(true, op, left, right); _as->addPatch(iffalse, target); @@ -1737,9 +1727,6 @@ bool InstructionSelection::visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Ex bool InstructionSelection::visitCJumpSInt32(IR::AluOp op, IR::Expr *left, IR::Expr *right, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse) { - if (!isPregOrConst(left) || !isPregOrConst(right)) - return false; - if (_as->nextBlock() == iftrue) { Assembler::Jump target = _as->branchInt32(true, op, left, right); _as->addPatch(iffalse, target); -- cgit v1.2.3 From 2c85acb0865ff4dc3682bbc4894216c5b058d89e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:16:02 +0100 Subject: V4: Scoped::operator-> will always return a T* There is no need to do a Value::cast, because that is already done in the constructors and in the assignment operators. Change-Id: I65b896c1eae91bf63ead3762437c35aea504ac62 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4scopedvalue_p.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 164fbb2997..4e627e003f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -298,11 +298,11 @@ struct Scoped } T *operator->() { - return ptr->cast(); + return getPointer(); } const T *operator->() const { - return ptr->cast(); + return getPointer(); } bool operator!() const { @@ -313,8 +313,13 @@ struct Scoped } T *getPointer() { - return ptr->cast(); + return reinterpret_cast(ptr); } + + const T *getPointer() const { + return reinterpret_cast(ptr); + } + Value *getRef() { return ptr; } -- cgit v1.2.3 From 808a30ed11fe4f18758080dc429fce016e27aa8a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:16:34 +0100 Subject: Make CallContext::argument const Change-Id: Ic41f6239e1a3920cacd08aba25ab01cd79670a3c Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4context_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 0b42288ccc..3bad1f03d7 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -244,11 +244,11 @@ struct Q_QML_EXPORT CallContext : public ExecutionContext Identifier * const *variables() const; unsigned int variableCount() const; - inline ReturnedValue argument(int i); + inline ReturnedValue argument(int i) const; bool needsOwnArguments() const; }; -inline ReturnedValue CallContext::argument(int i) { +inline ReturnedValue CallContext::argument(int i) const { return i < argc() ? args()[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); } -- cgit v1.2.3 From 973bace494e6694c90dc3e52f7cb230a7d428ac0 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:19:25 +0100 Subject: V4: Make the first QML profiling check as quick as possible In most cases there is no QML profiler attached, so hint the compiler about that. Change-Id: Ied75e58e608ccc689d2a9a1b0bf6e8f65769c94f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4profiling_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index e06cb64a61..d27e853343 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -86,7 +86,7 @@ QT_END_NAMESPACE engine->profiler()->trackDealloc(size, type) : false) #define Q_V4_PROFILE(engine, function)\ - (engine->profiler() &&\ + (Q_UNLIKELY(engine->profiler()) &&\ (engine->profiler()->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\ Profiling::FunctionCallProfiler::profileCall(engine->profiler(), engine, function) :\ function->code(engine, function->codeData)) -- cgit v1.2.3 From c4e248f101c3989bc06678c6b2089c49d0bf47d9 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:23:01 +0100 Subject: Reorder CallData building for better gcc codegen GCC6 with LTO will assume that the then-part is the common path. For ArrayData-to-CallData "conversion" this is not the case, so reorder that. Change-Id: I856ef9b5747e9858a35f15a23159cf7c12fd75ef Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 2521ff32e1..848b578dea 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -367,17 +367,18 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) ScopedCallData callData(scope, len); if (len) { - if (arr->arrayType() != Heap::ArrayData::Simple || arr->protoHasArray()) { - for (quint32 i = 0; i < len; ++i) - callData->args[i] = arr->getIndexed(i); - } else { - uint alen = arr->arrayData() ? arr->arrayData()->len : 0; + if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) { + auto sad = static_cast(arr->arrayData()); + uint alen = sad ? sad->len : 0; if (alen > len) alen = len; for (uint i = 0; i < alen; ++i) - callData->args[i] = static_cast(arr->arrayData())->data(i); + callData->args[i] = sad->data(i); for (quint32 i = alen; i < len; ++i) callData->args[i] = Primitive::undefinedValue(); + } else { + for (quint32 i = 0; i < len; ++i) + callData->args[i] = arr->getIndexed(i); } } -- cgit v1.2.3 From 789e7b6d864e98fb65731fa5471e587695289e78 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:24:18 +0100 Subject: Hint the compiler that exceptions are exceptional and not the hot path Change-Id: I981f0cb643a67027a37db38363e26b220d3c216f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 10 +++++----- src/qml/jsruntime/qv4runtime.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 848b578dea..ee2fe6bfd7 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -435,7 +435,7 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData) { ExecutionEngine *v4 = scope.engine; - if (v4->hasException) { + if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); return; } @@ -458,7 +458,7 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call if (f->function()->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); - if (v4->hasException) { + if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); } else if (!scope.result.isObject()) { scope.result = obj.asReturnedValue(); @@ -468,7 +468,7 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) { ExecutionEngine *v4 = scope.engine; - if (v4->hasException) { + if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); return; } @@ -524,7 +524,7 @@ void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *fu void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData) { ExecutionEngine *v4 = scope.engine; - if (v4->hasException) { + if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); return; } @@ -559,7 +559,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData if (ff->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); - if (v4->hasException) { + if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); } else if (!scope.result.isObject()) { scope.result = callData->thisObject; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 944588dd28..61ef168447 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1067,7 +1067,8 @@ ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint i Lookup *l = engine->current->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); - if (Object *o = v.objectValue()) { + Object *o = v.objectValue(); + if (Q_LIKELY(o)) { Scope scope(engine); o->call(scope, callData); return scope.result.asReturnedValue(); @@ -1170,9 +1171,9 @@ ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, u Lookup *l = engine->current->lookups + index; Value v; v = l->getter(l, engine, callData->thisObject); - if (Object *o = v.objectValue()) { + Object *o = v.objectValue(); + if (Q_LIKELY(o)) { Scope scope(engine); - ScopedValue result(scope); o->construct(scope, callData); return scope.result.asReturnedValue(); } -- cgit v1.2.3 From 8901f927bf1930cf97ce38b9ba71a5b6c418b93f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2016 15:35:20 +0100 Subject: examples\..\scenegraph.pro: Remove duplicate entry textureinsgnode Fixes build warnings: Cannot add commands to previously defined target sub-textureinsgnode-qmake_all. Cannot add commands to previously defined target sub-textureinsgnode. Cannot add commands to previously defined target sub-textureinsgnode-make_first. Change-Id: Ieaa8b688fa112d42efa05721ff3bfe251036a69b Reviewed-by: Simon Hausmann --- examples/quick/scenegraph/scenegraph.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro index e13e8198b0..2efeb5ed83 100644 --- a/examples/quick/scenegraph/scenegraph.pro +++ b/examples/quick/scenegraph/scenegraph.pro @@ -7,7 +7,6 @@ qtConfig(opengl(es1|es2)?) { sgengine \ textureinsgnode \ openglunderqml \ - textureinsgnode \ textureinthread \ twotextureproviders } -- cgit v1.2.3 From 92ba955a84c733422c02090602f7053260a8301e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2016 15:48:52 +0100 Subject: Remove reference to trusted-benchmarks.pri It appears to be legacy that is no longer found. Change-Id: Id7fa8555e32d917da617100fb8720a18eab69ae1 Reviewed-by: Simon Hausmann --- tests/benchmarks/qml/qml.pro | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro index 2cf2dff413..f1fe87e532 100644 --- a/tests/benchmarks/qml/qml.pro +++ b/tests/benchmarks/qml/qml.pro @@ -14,5 +14,3 @@ SUBDIRS += \ creation qtHaveModule(opengl): SUBDIRS += painting qquickwindow - -include(../trusted-benchmarks.pri) -- cgit v1.2.3 From a63e6ea1ccae744ed40d00aac97c4ce46e7ac6d4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 1 Dec 2016 15:40:16 +0100 Subject: Fix build of QtQuick compiler generated code with popScope() After commit 5e6bf607ee1e466eebabb7b8114c9f5e8fc40a9e we would not have an exception check template matching anymore that sets NeedsCheck to false, and consequently generated code that would try to call popScope() with an ExecutionEngine instead of a NoThrowEngine. Task-number: QTRD-2219 Change-Id: Iddf8218d1efb9af77c9a5f7ef84b9998fb167ef5 Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4runtimeapi_p.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index e06a3f5ec2..355b7890b6 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -63,6 +63,11 @@ template struct ExceptionCheck { enum { NeedsCheck = 1 }; }; +// push_catch and pop context methods shouldn't check for exceptions +template <> +struct ExceptionCheck { + enum { NeedsCheck = 0 }; +}; template struct ExceptionCheck { enum { NeedsCheck = 0 }; -- cgit v1.2.3 From aabeeda52c3b4d2e3327bfd00642d2d7c980719b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2016 15:47:36 +0100 Subject: Build benchmarks only in release mode Otherwise, a debug build will fail due to not find the release mode libraries: LINK : fatal error LNK1181: cannot open input file 'D:\dev\5-vs15-58-static\qt-58s\qtbase\lib\Qt5Gui.lib' Change-Id: I1b942db5ad0cf5fb3a949f9d39b8cf55a2dbd69a Reviewed-by: Robin Burchell Reviewed-by: Simon Hausmann --- tests/tests.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tests.pro b/tests/tests.pro index f5731b2f34..ab94786b31 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += auto benchmarks +SUBDIRS += auto +contains(QT_CONFIG, release): SUBDIRS += benchmarks -- cgit v1.2.3 From a0fd2539154dafdd512bf634658e361ca56d3004 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 2 Dec 2016 23:52:22 -0800 Subject: Fix compilation error with ICC 17: it doesn't like auto and comma The error is a warning upgraded via -Werror and the message doesn't even make sense to me: error #3373: nonstandard use of "auto" to both deduce the type from an initializer and to announce a trailing return type Intel-Issue-ID: 6000164202 Change-Id: I73fa1e59a4844c43a109fffd148caf09a1952e92 Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmlpropertycachecreator_p.h | 56 ++++++++++++++++++++------- src/qml/compiler/qv4compileddata_p.h | 8 +++- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h index 10bcd1dbc1..3c14abc019 100644 --- a/src/qml/compiler/qqmlpropertycachecreator_p.h +++ b/src/qml/compiler/qqmlpropertycachecreator_p.h @@ -118,7 +118,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::buildMetaObje bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 || obj->signalCount() != 0 || obj->functionCount() != 0; if (!needVMEMetaObject) { - for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding) { + auto binding = obj->bindingsBegin(); + auto end = obj->bindingsEnd(); + for ( ; binding != end; ++binding) { if (binding->type == QV4::CompiledData::Binding::Type_Object && (binding->flags & QV4::CompiledData::Binding::IsOnAssignment)) { // If the on assignment is inside a group property, we need to distinguish between QObject based // group properties and value type group properties. For the former the base type is derived from @@ -162,7 +164,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::buildMetaObje } if (QQmlPropertyCache *thisCache = propertyCaches->at(objectIndex)) { - for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding) + auto binding = obj->bindingsBegin(); + auto end = obj->bindingsEnd(); + for ( ; binding != end; ++binding) if (binding->type >= QV4::CompiledData::Binding::Type_Object) { QQmlBindingInstantiationContext context(objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache); QQmlCompileError error = buildMetaObjectRecursively(binding->value.objectIndex, context); @@ -296,7 +300,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj QmlIR::PropertyResolver resolver(baseTypeCache); - for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p) { + auto p = obj->propertiesBegin(); + auto pend = obj->propertiesEnd(); + for ( ; p != pend; ++p) { if (p->type == QV4::CompiledData::Property::Var) varPropCount++; @@ -306,7 +312,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj return QQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property")); } - for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) { + auto a = obj->aliasesBegin(); + auto aend = obj->aliasesEnd(); + for ( ; a != aend; ++a) { bool notInRevision = false; QQmlPropertyData *d = resolver.property(stringAt(a->nameIndex), ¬InRevision); if (d && d->isFinal()) @@ -340,7 +348,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj } // Set up notify signals for properties - first normal, then alias - for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p) { + p = obj->propertiesBegin(); + pend = obj->propertiesEnd(); + for ( ; p != pend; ++p) { auto flags = QQmlPropertyData::defaultSignalFlags(); QString changedSigName = stringAt(p->nameIndex) + QLatin1String("Changed"); @@ -349,7 +359,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj cache->appendSignal(changedSigName, flags, effectiveMethodIndex++); } - for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) { + a = obj->aliasesBegin(); + aend = obj->aliasesEnd(); + for ( ; a != aend; ++a) { auto flags = QQmlPropertyData::defaultSignalFlags(); QString changedSigName = stringAt(a->nameIndex) + QLatin1String("Changed"); @@ -359,7 +371,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj } // Dynamic signals - for (auto s = obj->signalsBegin(), end = obj->signalsEnd(); s != end; ++s) { + auto s = obj->signalsBegin(); + auto send = obj->signalsEnd(); + for ( ; s != send; ++s) { const int paramCount = s->parameterCount(); QList names; @@ -370,7 +384,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj paramTypes[0] = paramCount; int i = 0; - for (auto param = s->parametersBegin(), end = s->parametersEnd(); param != end; ++param, ++i) { + auto param = s->parametersBegin(); + auto end = s->parametersEnd(); + for ( ; param != end; ++param, ++i) { names.append(stringAt(param->nameIndex).toUtf8()); if (param->type < builtinTypeCount) { // built-in type @@ -415,7 +431,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj // Dynamic slots - for (auto function = objectContainer->objectFunctionsBegin(obj), end = objectContainer->objectFunctionsEnd(obj); function != end; ++function) { + auto function = objectContainer->objectFunctionsBegin(obj); + auto fend = objectContainer->objectFunctionsEnd(obj); + for ( ; function != fend; ++function) { auto flags = QQmlPropertyData::defaultSlotFlags(); const QString slotName = stringAt(function->nameIndex); @@ -425,7 +443,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj // protect against overriding change signals or methods with properties. QList parameterNames; - for (auto formal = function->formalsBegin(), end = function->formalsEnd(); formal != end; ++formal) { + auto formal = function->formalsBegin(); + auto end = function->formalsEnd(); + for ( ; formal != end; ++formal) { flags.hasArguments = true; parameterNames << stringAt(*formal).toUtf8(); } @@ -437,7 +457,9 @@ inline QQmlCompileError QQmlPropertyCacheCreator::createMetaObj // Dynamic properties int effectiveSignalIndex = cache->signalHandlerIndexCacheStart; int propertyIdx = 0; - for (auto p = obj->propertiesBegin(), end = obj->propertiesEnd(); p != end; ++p, ++propertyIdx) { + p = obj->propertiesBegin(); + pend = obj->propertiesEnd(); + for ( ; p != pend; ++p, ++propertyIdx) { int propertyType = 0; QQmlPropertyData::Flags propertyFlags; @@ -561,7 +583,9 @@ inline void QQmlPropertyCacheAliasCreator::appendAliasPropertie return; const auto allAliasTargetsExist = [this, &component](const CompiledObject &object) { - for (auto alias = object.aliasesBegin(), end = object.aliasesEnd(); alias != end; ++alias) { + auto alias = object.aliasesBegin(); + auto end = object.aliasesEnd(); + for ( ; alias != end; ++alias) { Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved); const int targetObjectIndex = objectForId(component, alias->targetObjectId); @@ -612,7 +636,9 @@ inline void QQmlPropertyCacheAliasCreator::collectObjectsWithAl if (object.flags & QV4::CompiledData::Object::IsComponent && objectIndex != objectContainer->rootObjectIndex()) return; - for (auto binding = object.bindingsBegin(), end = object.bindingsEnd(); binding != end; ++binding) { + auto binding = object.bindingsBegin(); + auto end = object.bindingsEnd(); + for (; binding != end; ++binding) { if (binding->type != QV4::CompiledData::Binding::Type_Object && binding->type != QV4::CompiledData::Binding::Type_AttachedProperty && binding->type != QV4::CompiledData::Binding::Type_GroupProperty) @@ -707,7 +733,9 @@ inline void QQmlPropertyCacheAliasCreator::appendAliasesToPrope int effectivePropertyIndex = propertyCache->propertyIndexCacheStart + propertyCache->propertyIndexCache.count(); int aliasIndex = 0; - for (auto alias = object.aliasesBegin(), end = object.aliasesEnd(); alias != end; ++alias, ++aliasIndex) { + auto alias = object.aliasesBegin(); + auto end = object.aliasesEnd(); + for ( ; alias != end; ++alias, ++aliasIndex) { Q_ASSERT(alias->flags & QV4::CompiledData::Alias::Resolved); int type = 0; diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 90cbe04505..3a0c83ddad 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -749,7 +749,9 @@ struct TypeReferenceMap : QHash r.errorWhenNotFound = true; } - for (auto prop = obj->propertiesBegin(), propEnd = obj->propertiesEnd(); prop != propEnd; ++prop) { + auto prop = obj->propertiesBegin(); + auto propEnd = obj->propertiesEnd(); + for ( ; prop != propEnd; ++prop) { if (prop->type >= QV4::CompiledData::Property::Custom) { // ### FIXME: We could report the more accurate location here by using prop->location, but the old // compiler can't and the tests expect it to be the object location right now. @@ -758,7 +760,9 @@ struct TypeReferenceMap : QHash } } - for (auto binding = obj->bindingsBegin(), bindingEnd = obj->bindingsEnd(); binding != bindingEnd; ++binding) { + auto binding = obj->bindingsBegin(); + auto bindingEnd = obj->bindingsEnd(); + for ( ; binding != bindingEnd; ++binding) { if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) this->add(binding->propertyNameIndex, binding->location); } -- cgit v1.2.3 From 53156ddf3811f27b265213596312ba11a725e062 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 1 Dec 2016 13:01:28 +0100 Subject: comment out all uses of QPointerUniqueId temporarily MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The next step is to rename it, but we do this first to avoid breaking CI while it's renamed in qtbase. Task-number: QTBUG-54616 Change-Id: Iae3a098b9ab5571599af838d19b1869b84b2165f Reviewed-by: Jan Arve SƦther --- src/quick/items/qquickevents.cpp | 2 +- src/quick/items/qquickevents_p_p.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index a5497f4627..9b49fcdf2a 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -552,7 +552,7 @@ void QQuickEventTouchPoint::reset(const QTouchEvent::TouchPoint &tp, ulong times QQuickEventPoint::reset(tp.state(), tp.scenePos(), tp.id(), timestamp); m_rotation = tp.rotation(); m_pressure = tp.pressure(); - m_uniqueId = tp.uniqueId(); +// m_uniqueId = tp.uniqueId(); } /*! diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 61bbb4ecda..6179791413 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -302,7 +302,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickEventTouchPoint : public QQuickEventPoint Q_OBJECT Q_PROPERTY(qreal rotation READ rotation) Q_PROPERTY(qreal pressure READ pressure) - Q_PROPERTY(QPointerUniqueId uniqueId READ uniqueId) +// TODO rename to QPointingDeviceUniqueId +// Q_PROPERTY(QPointerUniqueId uniqueId READ uniqueId) public: QQuickEventTouchPoint(QQuickPointerTouchEvent *parent); @@ -311,12 +312,12 @@ public: qreal rotation() const { return m_rotation; } qreal pressure() const { return m_pressure; } - QPointerUniqueId uniqueId() const { return m_uniqueId; } +// QPointerUniqueId uniqueId() const { return m_uniqueId; } private: qreal m_rotation; qreal m_pressure; - QPointerUniqueId m_uniqueId; +// QPointerUniqueId m_uniqueId; Q_DISABLE_COPY(QQuickEventTouchPoint) }; @@ -554,7 +555,7 @@ QML_DECLARE_TYPE(QQuickMouseEvent) QML_DECLARE_TYPE(QQuickWheelEvent) QML_DECLARE_TYPE(QQuickCloseEvent) QML_DECLARE_TYPE(QQuickPointerDevice) -QML_DECLARE_TYPE(QPointerUniqueId) +//QML_DECLARE_TYPE(QPointerUniqueId) QML_DECLARE_TYPE(QQuickPointerEvent) #endif // QQUICKEVENTS_P_P_H -- cgit v1.2.3 From 8a6383775a301c8dd8c917a936655c534932a726 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Nov 2016 15:33:48 +0100 Subject: Start cleaning up the QmlContextWrapper The class should get merged with the QV4::QmlContext class. Simplify the cleanup by moving both classes into a common file. Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1 Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_debugger/qv4debugjob.cpp | 5 +- src/qml/jsruntime/jsruntime.pri | 3 +- src/qml/jsruntime/qv4context.cpp | 31 +- src/qml/jsruntime/qv4context_p.h | 27 +- src/qml/jsruntime/qv4context_p_p.h | 83 ----- src/qml/jsruntime/qv4engine.cpp | 24 +- src/qml/jsruntime/qv4engine_p.h | 21 -- src/qml/jsruntime/qv4functionobject.cpp | 2 +- src/qml/jsruntime/qv4include.cpp | 1 - src/qml/jsruntime/qv4qmlcontext.cpp | 362 +++++++++++++++++++++ src/qml/jsruntime/qv4qmlcontext_p.h | 133 ++++++++ src/qml/jsruntime/qv4qobjectwrapper.cpp | 1 - src/qml/jsruntime/qv4runtime.cpp | 2 +- src/qml/jsruntime/qv4script.cpp | 1 - src/qml/jsruntime/qv4script_p.h | 2 +- src/qml/qml/qml.pri | 3 - src/qml/qml/qqmlbinding.cpp | 1 - src/qml/qml/qqmlcontextwrapper.cpp | 323 ------------------ src/qml/qml/qqmlcontextwrapper_p.h | 105 ------ src/qml/qml/qqmldelayedcallqueue.cpp | 1 - src/qml/qml/qqmljavascriptexpression.cpp | 4 +- src/qml/qml/qqmlobjectcreator.cpp | 3 +- src/qml/qml/qqmltypeloader.cpp | 3 +- src/qml/qml/qqmltypewrapper.cpp | 1 - src/qml/qml/qqmlvaluetypewrapper.cpp | 1 - src/qml/qml/qqmlvme.cpp | 1 - src/qml/qml/qqmlxmlhttprequest.cpp | 1 - src/qml/qml/v8/qv8engine.cpp | 1 - src/qml/types/qquickworkerscript.cpp | 16 +- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 1 + .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- 31 files changed, 540 insertions(+), 625 deletions(-) delete mode 100644 src/qml/jsruntime/qv4context_p_p.h create mode 100644 src/qml/jsruntime/qv4qmlcontext.cpp create mode 100644 src/qml/jsruntime/qv4qmlcontext_p.h delete mode 100644 src/qml/qml/qqmlcontextwrapper.cpp delete mode 100644 src/qml/qml/qqmlcontextwrapper_p.h diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index a2d2fff72b..d5cc765ea8 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -81,7 +82,7 @@ void JavaScriptJob::run() } } if (!engine->qmlContext()) { - engine->pushContext(ctx->newQmlContext(QQmlContextData::get(qmlRootContext), + engine->pushContext(QV4::QmlContext::create(ctx, QQmlContextData::get(qmlRootContext), &scopeObject)); ctx = engine->currentContext; } @@ -201,7 +202,7 @@ void ValueLookupJob::run() QV4::ExecutionEngine *engine = collector->engine(); if (engine->qmlEngine() && !engine->qmlContext()) { scopeObject.reset(new QObject); - engine->pushContext(engine->currentContext->newQmlContext( + engine->pushContext(QV4::QmlContext::create(engine->currentContext, QQmlContextData::get(engine->qmlEngine()->rootContext()), scopeObject.data())); } diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri index dcc04cbd54..0c55200c64 100644 --- a/src/qml/jsruntime/jsruntime.pri +++ b/src/qml/jsruntime/jsruntime.pri @@ -27,6 +27,7 @@ SOURCES += \ $$PWD/qv4numberobject.cpp \ $$PWD/qv4object.cpp \ $$PWD/qv4objectproto.cpp \ + $$PWD/qv4qmlcontext.cpp \ $$PWD/qv4regexpobject.cpp \ $$PWD/qv4stringobject.cpp \ $$PWD/qv4variantobject.cpp \ @@ -48,7 +49,6 @@ HEADERS += \ $$PWD/qv4global_p.h \ $$PWD/qv4engine_p.h \ $$PWD/qv4context_p.h \ - $$PWD/qv4context_p_p.h \ $$PWD/qv4math_p.h \ $$PWD/qv4persistent_p.h \ $$PWD/qv4debugging_p.h \ @@ -73,6 +73,7 @@ HEADERS += \ $$PWD/qv4numberobject_p.h \ $$PWD/qv4object_p.h \ $$PWD/qv4objectproto_p.h \ + $$PWD/qv4qmlcontext_p.h \ $$PWD/qv4regexpobject_p.h \ $$PWD/qv4stringobject_p.h \ $$PWD/qv4variantobject_p.h \ diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 390a5e7d7a..361d321a1a 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -39,7 +39,7 @@ #include #include "qv4debugging_p.h" -#include +#include #include #include #include @@ -47,6 +47,7 @@ #include "qv4function_p.h" #include "qv4errorobject_p.h" #include "qv4string_p.h" +#include "qv4qmlcontext_p.h" using namespace QV4; @@ -55,7 +56,6 @@ DEFINE_MANAGED_VTABLE(CallContext); DEFINE_MANAGED_VTABLE(WithContext); DEFINE_MANAGED_VTABLE(CatchContext); DEFINE_MANAGED_VTABLE(GlobalContext); -DEFINE_MANAGED_VTABLE(QmlContext); Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *function, CallData *callData) { @@ -102,20 +102,6 @@ Heap::CatchContext *ExecutionContext::newCatchContext(Heap::String *exceptionVar return d()->engine->memoryManager->alloc(d(), exceptionVarName, e); } -Heap::QmlContext *ExecutionContext::newQmlContext(QmlContextWrapper *qml) -{ - Heap::QmlContext *c = d()->engine->memoryManager->alloc(this, qml); - return c; -} - -Heap::QmlContext *ExecutionContext::newQmlContext(QQmlContextData *context, QObject *scopeObject) -{ - Scope scope(this); - Scoped qml(scope, QmlContextWrapper::qmlScope(scope.engine, context, scopeObject)); - Heap::QmlContext *c = d()->engine->memoryManager->alloc(this, qml); - return c; -} - void ExecutionContext::createMutableBinding(String *name, bool deletable) { Scope scope(this); @@ -182,19 +168,6 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV this->exceptionValue = exceptionValue; } -void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml) -{ - Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext); - outer = outerContext->d(); - strictMode = false; - callData = outer->callData; - lookups = outer->lookups; - constantTable = outer->constantTable; - compilationUnit = outer->compilationUnit; - - this->qml = qml->d(); -} - Identifier * const *CallContext::formals() const { diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 3bad1f03d7..487917df7d 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -55,8 +55,8 @@ QT_BEGIN_NAMESPACE -class QQmlContextData; class QObject; +class QQmlContextData; namespace QV4 { @@ -65,11 +65,12 @@ struct CompilationUnit; struct Function; } -struct QmlContextWrapper; struct Identifier; struct CallContext; struct CatchContext; struct WithContext; +struct QmlContext; +struct QmlContextWrapper; struct CallData { @@ -91,6 +92,8 @@ struct CallData namespace Heap { +struct QmlContext; + struct ExecutionContext : Base { enum ContextType { Type_GlobalContext = 0x1, @@ -177,14 +180,6 @@ struct WithContext : ExecutionContext { }; V4_ASSERT_IS_TRIVIAL(WithContext) -struct QmlContextWrapper; - -struct QmlContext : ExecutionContext { - void init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml); - - Pointer qml; -}; - } struct Q_QML_EXPORT ExecutionContext : public Managed @@ -201,8 +196,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed Heap::CallContext *newCallContext(const FunctionObject *f, CallData *callData); Heap::WithContext *newWithContext(Heap::Object *with); Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue); - Heap::QmlContext *newQmlContext(QmlContextWrapper *qml); - Heap::QmlContext *newQmlContext(QQmlContextData *context, QObject *scopeObject); void createMutableBinding(String *name, bool deletable); @@ -268,16 +261,6 @@ struct WithContext : public ExecutionContext V4_MANAGED(WithContext, ExecutionContext) }; -struct Q_QML_EXPORT QmlContext : public ExecutionContext -{ - V4_MANAGED(QmlContext, ExecutionContext) - - QObject *qmlScope() const; - QQmlContextData *qmlContext() const; - - void takeContextOwnership(); -}; - inline CallContext *ExecutionContext::asCallContext() { return d()->type >= Heap::ExecutionContext::Type_SimpleCallContext ? static_cast(this) : 0; diff --git a/src/qml/jsruntime/qv4context_p_p.h b/src/qml/jsruntime/qv4context_p_p.h deleted file mode 100644 index ca8dc0b518..0000000000 --- a/src/qml/jsruntime/qv4context_p_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QV4CONTEXT_P_P_H -#define QV4CONTEXT_P_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -// This header defines a couple of inlinable methods. -// These implementation cannot be put in qv4context_p.h, because they rely on the -// QQmlContextWrapper, which in turn is a QV4::Object subclass (so it includes qv4object_p.h), -// which includes qv4engine_p.h, that needs to include qv4context_p.h - -#include "qv4context_p.h" -#include "private/qqmlcontextwrapper_p.h" - -QT_BEGIN_NAMESPACE - -namespace QV4 { - -QObject *QmlContext::qmlScope() const -{ - return d()->qml->scopeObject; -} - -QQmlContextData *QmlContext::qmlContext() const -{ - return *d()->qml->context; -} - -void QmlContext::takeContextOwnership() { - d()->qml->ownsContext = true; -} - -} // QV4 namespace - -QT_END_NAMESPACE - -#endif // QV4CONTEXT_P_P_H diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 5c79c4ea97..698c73a910 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ #include -#include +#include #include #include #include @@ -71,7 +71,6 @@ #include "qv4typedarray_p.h" #include #include -#include #include #include #include @@ -714,6 +713,27 @@ Heap::Object *ExecutionEngine::newForEachIteratorObject(Object *o) return obj->d(); } +Heap::QmlContext *ExecutionEngine::qmlContext() const +{ + Heap::ExecutionContext *ctx = current; + + // get the correct context when we're within a builtin function + if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer) + ctx = parentContext(currentContext)->d(); + + if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !ctx->outer) + return 0; + + while (ctx->outer && ctx->outer->type != Heap::ExecutionContext::Type_GlobalContext) + ctx = ctx->outer; + + Q_ASSERT(ctx); + if (ctx->type != Heap::ExecutionContext::Type_QmlContext) + return 0; + + return static_cast(ctx); +} + QObject *ExecutionEngine::qmlScopeObject() const { Heap::QmlContext *ctx = qmlContext(); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 64bf77b1f5..bf6898001f 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -548,27 +548,6 @@ inline ExecutionContext *ExecutionEngine::parentContext(ExecutionContext *contex return o ? context - o : 0; } -inline Heap::QmlContext *ExecutionEngine::qmlContext() const -{ - Heap::ExecutionContext *ctx = current; - - // get the correct context when we're within a builtin function - if (ctx->type == Heap::ExecutionContext::Type_SimpleCallContext && !ctx->outer) - ctx = parentContext(currentContext)->d(); - - if (ctx->type != Heap::ExecutionContext::Type_QmlContext && !ctx->outer) - return 0; - - while (ctx->outer && ctx->outer->type != Heap::ExecutionContext::Type_GlobalContext) - ctx = ctx->outer; - - Q_ASSERT(ctx); - if (ctx->type != Heap::ExecutionContext::Type_QmlContext) - return 0; - - return static_cast(ctx); -} - inline void Heap::Base::mark(QV4::ExecutionEngine *engine) { diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index ee2fe6bfd7..28a9949464 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -208,7 +208,7 @@ Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlCont ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine); QV4::Scope valueScope(engine); ExecutionContext *global = valueScope.engine->rootContext(); - QV4::Scoped wrapperContext(valueScope, global->newQmlContext(qmlContext, scopeObject)); + QV4::Scoped wrapperContext(valueScope, QmlContext::create(global, qmlContext, scopeObject)); if (!signalParameters.isEmpty()) { if (error) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index be8057e9f5..1d393cf0aa 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -53,7 +53,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp new file mode 100644 index 0000000000..a4ace4c3eb --- /dev/null +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -0,0 +1,362 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qv4qmlcontext_p.h" +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace QV4; + +DEFINE_OBJECT_VTABLE(QmlContextWrapper); +DEFINE_MANAGED_VTABLE(QmlContext); + +void Heap::QmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext) +{ + Object::init(); + readOnly = true; + this->ownsContext = ownsContext; + isNullWrapper = false; + this->context = new QQmlGuardedContextData(context); + this->scopeObject.init(scopeObject); +} + +void Heap::QmlContextWrapper::destroy() +{ + if (*context && ownsContext) + (*context)->destroy(); + delete context; + scopeObject.destroy(); + Object::destroy(); +} + +ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope) +{ + Scope valueScope(v4); + + Scoped w(valueScope, v4->memoryManager->allocObject(ctxt, scope)); + return w.asReturnedValue(); +} + +ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url) +{ + Scope scope(v4); + + QQmlContextData *context = new QQmlContextData; + context->baseUrl = url; + context->baseUrlString = url.toString(); + context->isInternal = true; + context->isJSContext = true; + + Scoped w(scope, v4->memoryManager->allocObject(context, (QObject*)0, true)); + w->d()->isNullWrapper = true; + return w.asReturnedValue(); +} + +ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty) +{ + Q_ASSERT(m->as()); + const QmlContextWrapper *resource = static_cast(m); + QV4::ExecutionEngine *v4 = resource->engine(); + QV4::Scope scope(v4); + + // In V8 the JS global object would come _before_ the QML global object, + // so simulate that here. + bool hasProp; + QV4::ScopedValue result(scope, v4->globalObject->get(name, &hasProp)); + if (hasProp) { + if (hasProperty) + *hasProperty = hasProp; + return result->asReturnedValue(); + } + + if (resource->d()->isNullWrapper) + return Object::get(m, name, hasProperty); + + if (v4->callingQmlContext() != *resource->d()->context) + return Object::get(m, name, hasProperty); + + result = Object::get(m, name, &hasProp); + if (hasProp) { + if (hasProperty) + *hasProperty = hasProp; + return result->asReturnedValue(); + } + + // Its possible we could delay the calculation of the "actual" context (in the case + // of sub contexts) until it is definately needed. + QQmlContextData *context = resource->getContext(); + QQmlContextData *expressionContext = context; + + if (!context) { + if (hasProperty) + *hasProperty = true; + return result->asReturnedValue(); + } + + // Search type (attached property/enum/imported scripts) names + // while (context) { + // Search context properties + // Search scope object + // Search context object + // context = context->parent + // } + + QObject *scopeObject = resource->getScopeObject(); + + if (context->imports && name->startsWithUpper()) { + // Search for attached properties, enums and imported scripts + QQmlTypeNameCache::Result r = context->imports->query(name); + + if (r.isValid()) { + if (hasProperty) + *hasProperty = true; + if (r.scriptIndex != -1) { + QV4::ScopedObject scripts(scope, context->importedScripts.valueRef()); + return scripts->getIndexed(r.scriptIndex); + } else if (r.type) { + return QmlTypeWrapper::create(v4, scopeObject, r.type); + } else if (r.importNamespace) { + return QmlTypeWrapper::create(v4, scopeObject, context->imports, r.importNamespace); + } + Q_ASSERT(!"Unreachable"); + } + + // Fall through + } + + QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->qmlEngine()); + + while (context) { + // Search context properties + const QV4::IdentifierHash &properties = context->propertyNames(); + if (properties.count()) { + int propertyIdx = properties.value(name); + + if (propertyIdx != -1) { + + if (propertyIdx < context->idValueCount) { + + if (ep->propertyCapture) + ep->propertyCapture->captureProperty(&context->idValues[propertyIdx].bindings); + if (hasProperty) + *hasProperty = true; + return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]); + } else { + + QQmlContextPrivate *cp = context->asQQmlContextPrivate(); + + if (ep->propertyCapture) + ep->propertyCapture->captureProperty(context->asQQmlContext(), -1, propertyIdx + cp->notifyIndex); + + const QVariant &value = cp->propertyValues.at(propertyIdx); + if (hasProperty) + *hasProperty = true; + if (value.userType() == qMetaTypeId >()) { + QQmlListProperty prop(context->asQQmlContext(), (void*) qintptr(propertyIdx), + QQmlContextPrivate::context_count, + QQmlContextPrivate::context_at); + return QmlListWrapper::create(v4, prop, qMetaTypeId >()); + } else { + return scope.engine->fromVariant(cp->propertyValues.at(propertyIdx)); + } + } + } + } + + // Search scope object + if (scopeObject) { + bool hasProp = false; + QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4, context, scopeObject, + name, QV4::QObjectWrapper::CheckRevision, &hasProp)); + if (hasProp) { + if (hasProperty) + *hasProperty = true; + return result->asReturnedValue(); + } + } + scopeObject = 0; + + + // Search context object + if (context->contextObject) { + bool hasProp = false; + result = QV4::QObjectWrapper::getQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp); + if (hasProp) { + if (hasProperty) + *hasProperty = true; + return result->asReturnedValue(); + } + } + + context = context->parent; + } + + expressionContext->unresolvedNames = true; + + return Encode::undefined(); +} + +void QmlContextWrapper::put(Managed *m, String *name, const Value &value) +{ + Q_ASSERT(m->as()); + QmlContextWrapper *resource = static_cast(m); + ExecutionEngine *v4 = resource->engine(); + QV4::Scope scope(v4); + if (scope.hasException()) + return; + QV4::Scoped wrapper(scope, resource); + + uint member = wrapper->internalClass()->find(name); + if (member < UINT_MAX) { + wrapper->putValue(member, value); + return; + } + + if (wrapper->d()->isNullWrapper) { + if (wrapper && wrapper->d()->readOnly) { + QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + + QLatin1Char('"'); + ScopedString e(scope, v4->newString(error)); + v4->throwError(e); + return; + } + + Object::put(m, name, value); + return; + } + + // Its possible we could delay the calculation of the "actual" context (in the case + // of sub contexts) until it is definately needed. + QQmlContextData *context = wrapper->getContext(); + QQmlContextData *expressionContext = context; + + if (!context) + return; + + // See QV8ContextWrapper::Getter for resolution order + + QObject *scopeObject = wrapper->getScopeObject(); + + while (context) { + const QV4::IdentifierHash &properties = context->propertyNames(); + // Search context properties + if (properties.count() && properties.value(name) != -1) + return; + + // Search scope object + if (scopeObject && + QV4::QObjectWrapper::setQmlProperty(v4, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value)) + return; + scopeObject = 0; + + // Search context object + if (context->contextObject && + QV4::QObjectWrapper::setQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value)) + return; + + context = context->parent; + } + + expressionContext->unresolvedNames = true; + + if (wrapper->d()->readOnly) { + QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + + QLatin1Char('"'); + v4->throwError(error); + return; + } + + Object::put(m, name, value); +} + +void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml) +{ + Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext); + outer = outerContext->d(); + strictMode = false; + callData = outer->callData; + lookups = outer->lookups; + constantTable = outer->constantTable; + compilationUnit = outer->compilationUnit; + + this->qml = qml->d(); +} + +Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, const QUrl &source, Value *sendFunction) +{ + Scope scope(parent); + + QV4::Scoped qml(scope, QV4::QmlContextWrapper::urlScope(scope.engine, source)); + Q_ASSERT(!!qml); + + qml->setReadOnly(false); + QV4::ScopedObject api(scope, scope.engine->newObject()); + api->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("sendMessage"))), *sendFunction); + qml->QV4::Object::put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("WorkerScript"))), api); + qml->setReadOnly(true); + + Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc(parent, qml); + return c; +} + +Heap::QmlContext *QmlContext::create(ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject) +{ + Scope scope(parent); + Scoped qml(scope, QmlContextWrapper::qmlScope(scope.engine, context, scopeObject)); + Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc(parent, qml); + return c; +} + +QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h new file mode 100644 index 0000000000..15a0aafbe8 --- /dev/null +++ b/src/qml/jsruntime/qv4qmlcontext_p.h @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QV4QMLCONTEXT_P_H +#define QV4QMLCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct QmlContextWrapper; + +namespace Heap { + +struct QmlContextWrapper : Object { + void init(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false); + void destroy(); + bool readOnly; + bool ownsContext; + bool isNullWrapper; + + QQmlGuardedContextData *context; + QQmlQPointer scopeObject; +}; + +struct QmlContext : ExecutionContext { + void init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml); + + Pointer qml; +}; + +} + +struct Q_QML_EXPORT QmlContextWrapper : Object +{ + V4_OBJECT2(QmlContextWrapper, Object) + V4_NEEDS_DESTROY + + static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope); + static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &); + + void takeContextOwnership() { + d()->ownsContext = true; + } + + inline QObject *getScopeObject() const { return d()->scopeObject; } + inline QQmlContextData *getContext() const { return *d()->context; } + + void setReadOnly(bool b) { d()->readOnly = b; } + + static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static void put(Managed *m, String *name, const Value &value); +}; + +struct Q_QML_EXPORT QmlContext : public ExecutionContext +{ + V4_MANAGED(QmlContext, ExecutionContext) + + static Heap::QmlContext *createWorkerContext(QV4::ExecutionContext *parent, const QUrl &source, Value *sendFunction); + static Heap::QmlContext *create(QV4::ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject); + + QObject *qmlScope() const { + return d()->qml->scopeObject; + } + QQmlContextData *qmlContext() const { + return *d()->qml->context; + } + + void takeContextOwnership() { + d()->qml->ownsContext = true; + } +}; + +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 80607f4067..7ded931af3 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 61ef168447..b71bd4146a 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -53,7 +53,7 @@ #include "qv4numberobject_p.h" #include "private/qlocale_tools_p.h" #include "qv4scopedvalue_p.h" -#include +#include #include #include #include diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 787047806a..8c27d36f50 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -54,7 +54,6 @@ #include #include #include -#include #include #include diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 2e87a7692b..686fa49c88 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -53,7 +53,7 @@ #include "qv4global_p.h" #include "qv4engine_p.h" #include "qv4functionobject_p.h" -#include "qv4context_p.h" +#include "qv4qmlcontext_p.h" #include diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri index 8d8da3742d..412dc6cba2 100644 --- a/src/qml/qml/qml.pri +++ b/src/qml/qml/qml.pri @@ -42,7 +42,6 @@ SOURCES += \ $$PWD/qqmlabstracturlinterceptor.cpp \ $$PWD/qqmlapplicationengine.cpp \ $$PWD/qqmllistwrapper.cpp \ - $$PWD/qqmlcontextwrapper.cpp \ $$PWD/qqmlvaluetypewrapper.cpp \ $$PWD/qqmltypewrapper.cpp \ $$PWD/qqmlfileselector.cpp \ @@ -113,8 +112,6 @@ HEADERS += \ $$PWD/qqmlapplicationengine_p.h \ $$PWD/qqmlapplicationengine.h \ $$PWD/qqmllistwrapper_p.h \ - $$PWD/qqmlcontextwrapper_p.h \ - $$PWD/qqmlvaluetypewrapper_p.h \ $$PWD/qqmltypewrapper_p.h \ $$PWD/qqmlfileselector_p.h \ $$PWD/qqmlfileselector.h \ diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 203bfec838..c150b1ee29 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp deleted file mode 100644 index 2418003519..0000000000 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmlcontextwrapper_p.h" -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -using namespace QV4; - -DEFINE_OBJECT_VTABLE(QmlContextWrapper); - -void Heap::QmlContextWrapper::init(QQmlContextData *context, QObject *scopeObject, bool ownsContext) -{ - Object::init(); - readOnly = true; - this->ownsContext = ownsContext; - isNullWrapper = false; - this->context = new QQmlGuardedContextData(context); - this->scopeObject.init(scopeObject); -} - -void Heap::QmlContextWrapper::destroy() -{ - if (*context && ownsContext) - (*context)->destroy(); - delete context; - scopeObject.destroy(); - Object::destroy(); -} - -ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope) -{ - Scope valueScope(v4); - - Scoped w(valueScope, v4->memoryManager->allocObject(ctxt, scope)); - return w.asReturnedValue(); -} - -ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url) -{ - Scope scope(v4); - - QQmlContextData *context = new QQmlContextData; - context->baseUrl = url; - context->baseUrlString = url.toString(); - context->isInternal = true; - context->isJSContext = true; - - Scoped w(scope, v4->memoryManager->allocObject(context, (QObject*)0, true)); - w->d()->isNullWrapper = true; - return w.asReturnedValue(); -} - -ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty) -{ - Q_ASSERT(m->as()); - const QmlContextWrapper *resource = static_cast(m); - QV4::ExecutionEngine *v4 = resource->engine(); - QV4::Scope scope(v4); - - // In V8 the JS global object would come _before_ the QML global object, - // so simulate that here. - bool hasProp; - QV4::ScopedValue result(scope, v4->globalObject->get(name, &hasProp)); - if (hasProp) { - if (hasProperty) - *hasProperty = hasProp; - return result->asReturnedValue(); - } - - if (resource->d()->isNullWrapper) - return Object::get(m, name, hasProperty); - - if (v4->callingQmlContext() != *resource->d()->context) - return Object::get(m, name, hasProperty); - - result = Object::get(m, name, &hasProp); - if (hasProp) { - if (hasProperty) - *hasProperty = hasProp; - return result->asReturnedValue(); - } - - // Its possible we could delay the calculation of the "actual" context (in the case - // of sub contexts) until it is definately needed. - QQmlContextData *context = resource->getContext(); - QQmlContextData *expressionContext = context; - - if (!context) { - if (hasProperty) - *hasProperty = true; - return result->asReturnedValue(); - } - - // Search type (attached property/enum/imported scripts) names - // while (context) { - // Search context properties - // Search scope object - // Search context object - // context = context->parent - // } - - QObject *scopeObject = resource->getScopeObject(); - - if (context->imports && name->startsWithUpper()) { - // Search for attached properties, enums and imported scripts - QQmlTypeNameCache::Result r = context->imports->query(name); - - if (r.isValid()) { - if (hasProperty) - *hasProperty = true; - if (r.scriptIndex != -1) { - QV4::ScopedObject scripts(scope, context->importedScripts.valueRef()); - return scripts->getIndexed(r.scriptIndex); - } else if (r.type) { - return QmlTypeWrapper::create(v4, scopeObject, r.type); - } else if (r.importNamespace) { - return QmlTypeWrapper::create(v4, scopeObject, context->imports, r.importNamespace); - } - Q_ASSERT(!"Unreachable"); - } - - // Fall through - } - - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(v4->qmlEngine()); - - while (context) { - // Search context properties - const QV4::IdentifierHash &properties = context->propertyNames(); - if (properties.count()) { - int propertyIdx = properties.value(name); - - if (propertyIdx != -1) { - - if (propertyIdx < context->idValueCount) { - - if (ep->propertyCapture) - ep->propertyCapture->captureProperty(&context->idValues[propertyIdx].bindings); - if (hasProperty) - *hasProperty = true; - return QV4::QObjectWrapper::wrap(v4, context->idValues[propertyIdx]); - } else { - - QQmlContextPrivate *cp = context->asQQmlContextPrivate(); - - if (ep->propertyCapture) - ep->propertyCapture->captureProperty(context->asQQmlContext(), -1, propertyIdx + cp->notifyIndex); - - const QVariant &value = cp->propertyValues.at(propertyIdx); - if (hasProperty) - *hasProperty = true; - if (value.userType() == qMetaTypeId >()) { - QQmlListProperty prop(context->asQQmlContext(), (void*) qintptr(propertyIdx), - QQmlContextPrivate::context_count, - QQmlContextPrivate::context_at); - return QmlListWrapper::create(v4, prop, qMetaTypeId >()); - } else { - return scope.engine->fromVariant(cp->propertyValues.at(propertyIdx)); - } - } - } - } - - // Search scope object - if (scopeObject) { - bool hasProp = false; - QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4, context, scopeObject, - name, QV4::QObjectWrapper::CheckRevision, &hasProp)); - if (hasProp) { - if (hasProperty) - *hasProperty = true; - return result->asReturnedValue(); - } - } - scopeObject = 0; - - - // Search context object - if (context->contextObject) { - bool hasProp = false; - result = QV4::QObjectWrapper::getQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp); - if (hasProp) { - if (hasProperty) - *hasProperty = true; - return result->asReturnedValue(); - } - } - - context = context->parent; - } - - expressionContext->unresolvedNames = true; - - return Encode::undefined(); -} - -void QmlContextWrapper::put(Managed *m, String *name, const Value &value) -{ - Q_ASSERT(m->as()); - QmlContextWrapper *resource = static_cast(m); - ExecutionEngine *v4 = resource->engine(); - QV4::Scope scope(v4); - if (scope.hasException()) - return; - QV4::Scoped wrapper(scope, resource); - - uint member = wrapper->internalClass()->find(name); - if (member < UINT_MAX) { - wrapper->putValue(member, value); - return; - } - - if (wrapper->d()->isNullWrapper) { - if (wrapper && wrapper->d()->readOnly) { - QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + - QLatin1Char('"'); - ScopedString e(scope, v4->newString(error)); - v4->throwError(e); - return; - } - - Object::put(m, name, value); - return; - } - - // Its possible we could delay the calculation of the "actual" context (in the case - // of sub contexts) until it is definately needed. - QQmlContextData *context = wrapper->getContext(); - QQmlContextData *expressionContext = context; - - if (!context) - return; - - // See QV8ContextWrapper::Getter for resolution order - - QObject *scopeObject = wrapper->getScopeObject(); - - while (context) { - const QV4::IdentifierHash &properties = context->propertyNames(); - // Search context properties - if (properties.count() && properties.value(name) != -1) - return; - - // Search scope object - if (scopeObject && - QV4::QObjectWrapper::setQmlProperty(v4, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value)) - return; - scopeObject = 0; - - // Search context object - if (context->contextObject && - QV4::QObjectWrapper::setQmlProperty(v4, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value)) - return; - - context = context->parent; - } - - expressionContext->unresolvedNames = true; - - if (wrapper->d()->readOnly) { - QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + - QLatin1Char('"'); - v4->throwError(error); - return; - } - - Object::put(m, name, value); -} - -QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h deleted file mode 100644 index 126ffecf0d..0000000000 --- a/src/qml/qml/qqmlcontextwrapper_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLCONTEXTWRAPPER_P_H -#define QQMLCONTEXTWRAPPER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace QV4 { - -namespace Heap { - -struct QmlContextWrapper : Object { - void init(QQmlContextData *context, QObject *scopeObject, bool ownsContext = false); - void destroy(); - bool readOnly; - bool ownsContext; - bool isNullWrapper; - - QQmlGuardedContextData *context; - QQmlQPointer scopeObject; -}; - -} - -struct Q_QML_EXPORT QmlContextWrapper : Object -{ - V4_OBJECT2(QmlContextWrapper, Object) - V4_NEEDS_DESTROY - - static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope); - static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &); - - void takeContextOwnership() { - d()->ownsContext = true; - } - - inline QObject *getScopeObject() const { return d()->scopeObject; } - inline QQmlContextData *getContext() const { return *d()->context; } - - void setReadOnly(bool b) { d()->readOnly = b; } - - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, String *name, const Value &value); -}; - -} - -QT_END_NAMESPACE - -#endif // QV8CONTEXTWRAPPER_P_H - diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index d10a8c7718..7552e1e82b 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 8020bdb2be..54d9222a8e 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -374,7 +374,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scopeObje QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); QV4::Scope scope(v4); - QV4::Scoped qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, scopeObject)); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, scopeObject)); QV4::Script script(v4, qmlContext, code, filename, line); QV4::ScopedValue result(scope); script.parse(); @@ -404,7 +404,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); QV4::Scope scope(v4); - QV4::Scoped qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, qmlScope)); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope)); QV4::Script script(v4, qmlContext, code, filename, line); QV4::ScopedValue result(scope); script.parse(); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index d07be77697..76829c48c9 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -1017,7 +1016,7 @@ void QQmlObjectCreator::registerObjectWithContextById(const QV4::CompiledData::O QV4::Heap::QmlContext *QQmlObjectCreator::currentQmlContext() { if (!_qmlContext->isObject()) - _qmlContext->setM(v4->rootContext()->newQmlContext(context, _scopeObject)); + _qmlContext->setM(QV4::QmlContext::create(v4->rootContext(), context, _scopeObject)); return _qmlContext->d(); } diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 09b9dcf452..7ad18c8efb 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -39,7 +39,6 @@ #include "qqmltypeloader_p.h" #include "qqmlabstracturlinterceptor.h" -#include "qqmlcontextwrapper_p.h" #include "qqmlexpression_p.h" #include @@ -2833,7 +2832,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent return QV4::Encode::undefined(); } - QV4::Scoped qmlContext(scope, v4->rootContext()->newQmlContext(ctxt, 0)); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, 0)); qmlContext->takeContextOwnership(); m_program->qmlContext.set(scope.engine, qmlContext); diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 5c3ad6b2a6..fd1e9cc2be 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qqmltypewrapper_p.h" -#include #include #include diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index be93baf9f6..8fb1f869ff 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 01c4f476d6..72d4ab7e8f 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -62,7 +62,6 @@ #include "qqmlpropertyvalueinterceptor_p.h" #include "qqmlvaluetypeproxybinding_p.h" #include "qqmlexpression_p.h" -#include "qqmlcontextwrapper_p.h" #include #include diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 6b86e38f19..47751aa2c6 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #include diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 1df468dd49..dadff819cf 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 78e7776c9b..e095eabce8 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -42,7 +42,6 @@ #include "qqmllistmodelworkeragent_p.h" #include #include -#include #include #include @@ -318,19 +317,8 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *scri QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine); QV4::Scope scope(v4); - - QV4::Scoped w(scope, QV4::QmlContextWrapper::urlScope(v4, script->source)); - Q_ASSERT(!!w); - w->setReadOnly(false); - - QV4::ScopedObject api(scope, v4->newObject()); - api->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("sendMessage"))), QV4::ScopedValue(scope, workerEngine->sendFunction(script->id))); - - w->QV4::Object::put(QV4::ScopedString(scope, v4->newString(QStringLiteral("WorkerScript"))), api); - - w->setReadOnly(true); - - script->qmlContext.set(v4, v4->rootContext()->newQmlContext(w)); + QV4::ScopedValue v(scope, workerEngine->sendFunction(script->id)); + script->qmlContext.set(v4, QV4::QmlContext::createWorkerContext(v4->rootContext(), script->source, v)); } return script->qmlContext.value(); diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 723f575330..690b1cdf24 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "../../shared/util.h" #include "testhttpserver.h" diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index be04ec2bf3..c3845178a7 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include "testtypes.h" #include "testhttpserver.h" #include "../../shared/util.h" -- cgit v1.2.3 From f2a9579375bf5ae6f70747b9209082e504a16397 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Nov 2016 16:04:01 +0100 Subject: Inline the qmlScope and urlScope methods They are only a couple of lines and used only in one place. Change-Id: Iee9139e78d5d7fd385cae39d6dd5fad7e5d461b5 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qmlcontext.cpp | 36 ++++++---------------- src/qml/jsruntime/qv4qmlcontext_p.h | 3 -- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index a4ace4c3eb..889f4ea288 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -81,29 +81,6 @@ void Heap::QmlContextWrapper::destroy() Object::destroy(); } -ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope) -{ - Scope valueScope(v4); - - Scoped w(valueScope, v4->memoryManager->allocObject(ctxt, scope)); - return w.asReturnedValue(); -} - -ReturnedValue QmlContextWrapper::urlScope(ExecutionEngine *v4, const QUrl &url) -{ - Scope scope(v4); - - QQmlContextData *context = new QQmlContextData; - context->baseUrl = url; - context->baseUrlString = url.toString(); - context->isInternal = true; - context->isJSContext = true; - - Scoped w(scope, v4->memoryManager->allocObject(context, (QObject*)0, true)); - w->d()->isNullWrapper = true; - return w.asReturnedValue(); -} - ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); @@ -338,8 +315,14 @@ Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, cons { Scope scope(parent); - QV4::Scoped qml(scope, QV4::QmlContextWrapper::urlScope(scope.engine, source)); - Q_ASSERT(!!qml); + QQmlContextData *context = new QQmlContextData; + context->baseUrl = source; + context->baseUrlString = source.toString(); + context->isInternal = true; + context->isJSContext = true; + + Scoped qml(scope, scope.engine->memoryManager->allocObject(context, (QObject*)0, true)); + qml->d()->isNullWrapper = true; qml->setReadOnly(false); QV4::ScopedObject api(scope, scope.engine->newObject()); @@ -354,7 +337,8 @@ Heap::QmlContext *QmlContext::createWorkerContext(ExecutionContext *parent, cons Heap::QmlContext *QmlContext::create(ExecutionContext *parent, QQmlContextData *context, QObject *scopeObject) { Scope scope(parent); - Scoped qml(scope, QmlContextWrapper::qmlScope(scope.engine, context, scopeObject)); + + Scoped qml(scope, scope.engine->memoryManager->allocObject(context, scopeObject)); Heap::QmlContext *c = parent->d()->engine->memoryManager->alloc(parent, qml); return c; } diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h index 15a0aafbe8..9aec7467da 100644 --- a/src/qml/jsruntime/qv4qmlcontext_p.h +++ b/src/qml/jsruntime/qv4qmlcontext_p.h @@ -90,9 +90,6 @@ struct Q_QML_EXPORT QmlContextWrapper : Object V4_OBJECT2(QmlContextWrapper, Object) V4_NEEDS_DESTROY - static ReturnedValue qmlScope(ExecutionEngine *e, QQmlContextData *ctxt, QObject *scope); - static ReturnedValue urlScope(ExecutionEngine *v4, const QUrl &); - void takeContextOwnership() { d()->ownsContext = true; } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index c3845178a7..88a8886ecb 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3986,7 +3986,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { { QV4::Scope scope(QV8Engine::getV4((engine))); - QV4::ScopedValue temporaryScope(scope, QV4::QmlContextWrapper::qmlScope(scope.engine, scriptContext, 0)); + QV4::ScopedContext temporaryScope(scope, QV4::QmlContext::create(scope.engine->rootContext(), scriptContext, 0)); Q_UNUSED(temporaryScope) } -- cgit v1.2.3 From f7d2f276ecc1d88fd050afb1bb674cc295af21aa Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Fri, 2 Dec 2016 20:48:47 +0100 Subject: Remove unnecessary tests _canSimplify is only set during accept(), so the additional tests do not seem to have any purpose. Change-Id: I0ee337c1457ec89940d1351eecd17cbfbfc7ff83 Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmltypecompiler.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 2308e66609..393616dfac 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1570,19 +1570,15 @@ bool QQmlJavaScriptBindingExpressionSimplificationPass::simplifyBinding(QV4::IR: if (!_canSimplify) return false; } - if (!_canSimplify) - return false; } if (_returnValueOfBindingExpression == -1) return false; - if (_canSimplify) { - if (_nameOfFunctionCalled) { - if (_functionCallReturnValue != _returnValueOfBindingExpression) - return false; - return detectTranslationCallAndConvertBinding(binding); - } + if (_nameOfFunctionCalled) { + if (_functionCallReturnValue != _returnValueOfBindingExpression) + return false; + return detectTranslationCallAndConvertBinding(binding); } return false; -- cgit v1.2.3 From f5c2cb4d9860c2f0d57dbae25c30d5d482c5281a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 24 Nov 2016 14:16:35 +0100 Subject: V4: Jit: inline a toBoolean conversion for 'var' type When the type of a variable is not known at compile-time, 'var' (meaning 'anything') is used. This can still hold a boolean at run-time, so before calling the Runtime::method_toBoolean, check if this is the case. Do the same for integers. Change-Id: I582c3a46fc992d4f4f44b87e80edafe7edea4221 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4isel_masm.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index c2ca804ffa..6b8264d801 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -1164,11 +1164,41 @@ void InstructionSelection::convertTypeToBool(IR::Expr *source, IR::Expr *target) _as->storeBool(false, target); break; case IR::StringType: + generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean, + Assembler::PointerToValue(source)); + _as->storeBool(Assembler::ReturnValueRegister, target); case IR::VarType: default: + Assembler::Pointer addr = _as->loadAddress(Assembler::ScratchRegister, source); + Assembler::Pointer tagAddr = addr; + tagAddr.offset += 4; + _as->load32(tagAddr, Assembler::ReturnValueRegister); + + // checkif it's a bool: + Assembler::Jump notBool = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister, + Assembler::TrustedImm32(Value::Boolean_Type_Internal)); + _as->load32(addr, Assembler::ReturnValueRegister); + Assembler::Jump boolDone = _as->jump(); + // check if it's an int32: + notBool.link(_as); + Assembler::Jump fallback = _as->branch32(Assembler::NotEqual, Assembler::ReturnValueRegister, + Assembler::TrustedImm32(Value::Integer_Type_Internal)); + _as->load32(addr, Assembler::ReturnValueRegister); + Assembler::Jump isZero = _as->branch32(Assembler::Equal, Assembler::ReturnValueRegister, + Assembler::TrustedImm32(0)); + _as->move(Assembler::TrustedImm32(1), Assembler::ReturnValueRegister); + Assembler::Jump intDone = _as->jump(); + + // not an int: + fallback.link(_as); generateRuntimeCall(Assembler::ReturnValueRegister, toBoolean, - Assembler::PointerToValue(source)); + Assembler::PointerToValue(source)); + + isZero.link(_as); + intDone.link(_as); + boolDone.link(_as); _as->storeBool(Assembler::ReturnValueRegister, target); + break; } } -- cgit v1.2.3 From df398d105b4e0c5ecc4f62c9895f11b949d3d8e4 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 1 Dec 2016 15:10:56 +0100 Subject: V4: Simplify strict-mode setting on call context objects Previously this required an extra shift to move the bit to the lsb. Change-Id: I04674c3bad34d60af13728fe9a7dd120a188c26f Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata_p.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 90cbe04505..a6cdf4bf43 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -207,9 +207,9 @@ struct String struct Function { enum Flags : unsigned int { - HasDirectEval = 0x1, - UsesArgumentsObject = 0x2, - IsStrict = 0x4, + IsStrict = 0x1, + HasDirectEval = 0x2, + UsesArgumentsObject = 0x4, IsNamedExpression = 0x8, HasCatchOrWith = 0x10 }; -- cgit v1.2.3 From e0a3c6276a257aeb1cb3ef6d16a4dddcc65d8195 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 10:52:57 +0100 Subject: Don't read members of the binding after it has been freed Fixes a use after free valgrind error (and thus a potential crash) in tst_qqmljavascript::selfDeletingBinding that got introduced with change e7f28bd13b18cfcb36ef41804029b9b296117002 Change-Id: Ia6b69af199c0f2af1cc0d33d4f13a8593b2c6d51 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 203bfec838..e7e0cfc42e 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -250,10 +250,9 @@ protected: clearError(); } + cancelPermanentGuards(); } - cancelPermanentGuards(); - ep->dereferenceScarceResources(); } -- cgit v1.2.3 From e31e72925f857be56c77b494c0fa10e55de72cfc Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Nov 2016 14:58:48 +0100 Subject: Cleanup and reduce the number of overloads for QQmlBinding::create() Change-Id: Ibcd277bc434638e5c6e8e9ccea634aa25cde1643 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qqmlenginedebugservice.cpp | 2 +- src/qml/qml/qqmlbinding.cpp | 29 +--------------------- src/qml/qml/qqmlbinding_p.h | 4 +-- .../designer/qquickdesignercustomobjectdata.cpp | 2 +- src/quick/qtquick2.cpp | 3 ++- src/quick/util/qquickpropertychanges.cpp | 8 +++--- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 1 + tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 26 +++++++++---------- 8 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index f72b8a51f9..2b8dcc19ee 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -660,7 +660,7 @@ bool QQmlEngineDebugServiceImpl::setBinding(int objectId, filename, line, column); QQmlPropertyPrivate::takeSignalExpression(property, qmlExpression); } else if (property.isProperty()) { - QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), filename, line, column); + QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), filename, line); binding->setTarget(property); QQmlPropertyPrivate::setBinding(binding); binding->update(); diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index c150b1ee29..57fbe2dbc6 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -57,18 +57,6 @@ QT_BEGIN_NAMESPACE -QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContext *ctxt) -{ - QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); - b->setNotifyOnValueChanged(true); - b->QQmlJavaScriptExpression::setContext(QQmlContextData::get(ctxt)); - b->setScopeObject(obj); - - b->createQmlBinding(b->context(), obj, str, QString(), 0); - - return b; -} - QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt) { QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); @@ -106,26 +94,11 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr return b; } -QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, QQmlContextData *ctxt) -{ - QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); - - b->setNotifyOnValueChanged(true); - b->QQmlJavaScriptExpression::setContext(ctxt); - b->setScopeObject(obj); - - b->createQmlBinding(ctxt, obj, str, QString(), 0); - - return b; -} - QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString &str, QObject *obj, - QQmlContextData *ctxt, const QString &url, quint16 lineNumber, - quint16 columnNumber) + QQmlContextData *ctxt, const QString &url, quint16 lineNumber) { QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); - Q_UNUSED(columnNumber); b->setNotifyOnValueChanged(true); b->QQmlJavaScriptExpression::setContext(ctxt); b->setScopeObject(obj); diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 6d42a8ea8a..3454adaf50 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -72,11 +72,9 @@ class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression, { friend class QQmlAbstractBinding; public: - static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContext *); static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *); - static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *); static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *, - const QString &url, quint16 lineNumber, quint16 columnNumber); + const QString &url = QString(), quint16 lineNumber = 0); static QQmlBinding *create(const QQmlPropertyData *, const QV4::Value &, QObject *, QQmlContextData *); ~QQmlBinding(); diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp index e37254d165..ca9c1259fd 100644 --- a/src/quick/designer/qquickdesignercustomobjectdata.cpp +++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp @@ -258,7 +258,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context, if (property.isProperty()) { QQmlBinding *binding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, - expression, object(), context); + expression, object(), QQmlContextData::get(context)); binding->setTarget(property); binding->setNotifyOnValueChanged(true); diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp index 1f9305ccba..226e7bf219 100644 --- a/src/quick/qtquick2.cpp +++ b/src/quick/qtquick2.cpp @@ -130,6 +130,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context, const QString &fileName, int line, int column, bool *inBaseState) { + Q_UNUSED(column); typedef QPointer QuickStatePointer; QObject *object = property.object(); QString propertyName = property.name(); @@ -144,7 +145,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context, newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, expression.toString(), object, QQmlContextData::get(context), fileName, - line, column); + line); newBinding->setTarget(property); } diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index 37a910876e..331ba32365 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -462,7 +462,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions() // QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0; if (!newBinding) newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, - e.expression, object(), context, e.url.toString(), e.line, e.column); + e.expression, object(), context, e.url.toString(), e.line); if (d->isExplicit) { // in this case, we don't want to assign a binding, per se, @@ -629,7 +629,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString auto prop = d->property(name); QQmlBinding *newBinding = QQmlBinding::create( &QQmlPropertyPrivate::get(prop)->core, expression, object(), - qmlContext(this)); + QQmlContextData::get(qmlContext(this))); newBinding->setTarget(prop); QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); } @@ -651,7 +651,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString auto prop = d->property(name); QQmlBinding *newBinding = QQmlBinding::create( &QQmlPropertyPrivate::get(prop)->core, expression, object(), - qmlContext(this)); + QQmlContextData::get(qmlContext(this))); newBinding->setTarget(prop); QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); } else { @@ -664,7 +664,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString QQmlBinding *newBinding = QQmlBinding::create( &QQmlPropertyPrivate::get(action.property)->core, expression, - object(), qmlContext(this)); + object(), QQmlContextData::get(qmlContext(this))); if (d->isExplicit) { // don't assign the binding, merely evaluate the expression. // XXX TODO: add a static QQmlJavaScriptExpression::evaluate(QString) diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 690b1cdf24..f2b0b9973e 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index fe73610bcc..385ffc523a 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -157,7 +157,7 @@ void tst_qqmlproperty::qmlmetaproperty() QObject *obj = new QObject; - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(nullptr, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -399,7 +399,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&object); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -447,7 +447,7 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&dobject); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -504,7 +504,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&object, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -552,7 +552,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("defaultProperty")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -603,7 +603,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onClicked")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -653,7 +653,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -709,7 +709,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&object, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -757,7 +757,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&dobject, engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -814,7 +814,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); @@ -862,7 +862,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -913,7 +913,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); @@ -963,7 +963,7 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, engine.rootContext())); + QQmlAbstractBinding::Ptr binding(QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, QLatin1String("null"), 0, QQmlContextData::get(engine.rootContext()))); static_cast(binding.data())->setTarget(prop); QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); -- cgit v1.2.3 From 83aa1933c82333b7ec5128442ac9ee2161387491 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Nov 2016 15:23:34 +0100 Subject: Add a sourceLocation() accessor to QV4::Function Change-Id: I3a38ee44ce46c2416ceef153ce631bc15fd461fe Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4function_p.h | 6 ++++++ src/qml/jsruntime/qv4functionobject.cpp | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 6e0ba9d764..12094a0943 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -51,6 +51,7 @@ // #include "qv4global_p.h" +#include #include QT_BEGIN_NAMESPACE @@ -89,6 +90,11 @@ struct Q_QML_EXPORT Function { inline bool needsActivation() const { return activationRequired; } + QQmlSourceLocation sourceLocation() const + { + return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); + } + }; } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 28a9949464..8e84eaebe7 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -237,10 +237,8 @@ QQmlSourceLocation FunctionObject::sourceLocation() const Q_ASSERT(as()); return *static_cast(d())->bindingLocation; } - QV4::Function *function = d()->function; - Q_ASSERT(function); - return QQmlSourceLocation(function->sourceFile(), function->compiledFunction->location.line, function->compiledFunction->location.column); + return d()->function->sourceLocation(); } DEFINE_OBJECT_VTABLE(FunctionCtor); -- cgit v1.2.3 From 54c79346f1929ff14673e1ab40a1bfd66ba6e2c5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 29 Nov 2016 22:39:28 +0100 Subject: Use QV4::Function instead of the FunctionObject in CallContext The prepares for being able to call binding code without having to create a full FunctionObject. Change-Id: I5f0dcaa4d1ae8876554cac82597351801588bc02 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4argumentsobject.cpp | 9 +++-- src/qml/jsruntime/qv4context.cpp | 66 ++++++++++++++++---------------- src/qml/jsruntime/qv4context_p.h | 5 +++ src/qml/jsruntime/qv4function_p.h | 8 ++++ src/qml/jsruntime/qv4functionobject.cpp | 2 + 5 files changed, 53 insertions(+), 37 deletions(-) diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 0dfdf25158..74fcd30632 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -39,7 +39,8 @@ #include #include #include -#include "qv4string_p.h" +#include +#include using namespace QV4; @@ -83,7 +84,7 @@ void ArgumentsObject::fullyCreate() return; uint argCount = context()->callData->argc; - uint numAccessors = qMin(context()->function->formalParameterCount(), argCount); + uint numAccessors = qMin(context()->formalParameterCount(), argCount); ArrayData::realloc(this, Heap::ArrayData::Sparse, argCount, true); context()->engine->requireArgumentsAccessors(numAccessors); @@ -110,7 +111,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con ScopedProperty map(scope); PropertyAttributes mapAttrs; bool isMapped = false; - uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->callData->argc); + uint numAccessors = qMin((int)context()->formalParameterCount(), context()->callData->argc); if (pd && index < (uint)numAccessors) isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->engine->argumentsAccessors[index].getter(); @@ -193,7 +194,7 @@ PropertyAttributes ArgumentsObject::queryIndexed(const Managed *m, uint index) if (args->fullyCreated()) return Object::queryIndexed(m, index); - uint numAccessors = qMin((int)args->context()->function->formalParameterCount(), args->context()->callData->argc); + uint numAccessors = qMin((int)args->context()->formalParameterCount(), args->context()->callData->argc); uint argCount = args->context()->callData->argc; if (index >= argCount) return PropertyAttributes(); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 361d321a1a..5d4a1b07b5 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -66,6 +66,7 @@ Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *functi c->init(d()->engine, Heap::ExecutionContext::Type_CallContext); c->function = function->d(); + c->v4Function = function->d()->function; c->strictMode = function->strictMode(); c->outer = function->scope(); @@ -171,22 +172,22 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV Identifier * const *CallContext::formals() const { - return (d()->function && d()->function->function) ? d()->function->function->internalClass->nameMap.constData() : 0; + return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() : 0; } unsigned int CallContext::formalCount() const { - return d()->function ? d()->function->formalParameterCount() : 0; + return d()->v4Function ? d()->v4Function->nFormals : 0; } Identifier * const *CallContext::variables() const { - return (d()->function && d()->function->function) ? d()->function->function->internalClass->nameMap.constData() + d()->function->formalParameterCount() : 0; + return d()->v4Function ? d()->v4Function->internalClass->nameMap.constData() + d()->v4Function->nFormals : 0; } unsigned int CallContext::variableCount() const { - return d()->function ? d()->function->varCount() : 0; + return d()->v4Function ? d()->v4Function->compiledFunction->nLocals : 0; } @@ -220,9 +221,8 @@ bool ExecutionContext::deleteProperty(String *name) case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast(ctx->d()); - ScopedFunctionObject f(scope, c->function); - if (f->needsActivation() || hasWith) { - uint index = f->function()->internalClass->find(name); + if (c->v4Function && (c->v4Function->needsActivation() || hasWith)) { + uint index = c->v4Function->internalClass->find(name); if (index < UINT_MAX) // ### throw in strict mode? return false; @@ -245,7 +245,8 @@ bool ExecutionContext::deleteProperty(String *name) bool CallContext::needsOwnArguments() const { - return d()->function->needsActivation() || argc() < static_cast(d()->function->formalParameterCount()); + QV4::Function *f = d()->v4Function; + return (f && f->needsActivation()) || (argc() < (f ? static_cast(f->nFormals) : 0)); } void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) @@ -277,10 +278,11 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) break; case Heap::ExecutionContext::Type_CallContext: { QV4::Heap::CallContext *c = static_cast(ctx); + Q_ASSERT(c->v4Function && c->function); ctx->callData->thisObject.mark(engine); - for (int arg = 0; arg < qMax(ctx->callData->argc, (int)c->function->formalParameterCount()); ++arg) + for (int arg = 0; arg < qMax(ctx->callData->argc, (int)c->v4Function->nFormals); ++arg) ctx->callData->args[arg].mark(engine); - for (unsigned local = 0, lastLocal = c->function->varCount(); local < lastLocal; ++local) + for (unsigned local = 0, lastLocal = c->v4Function->compiledFunction->nLocals; local < lastLocal; ++local) c->locals[local].mark(engine); if (c->activation) c->activation->mark(engine); @@ -327,13 +329,13 @@ void ExecutionContext::setProperty(String *name, const Value &value) case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast(ctx->d()); - if (c->function->function) { - uint index = c->function->function->internalClass->find(name); + if (c->v4Function) { + uint index = c->v4Function->internalClass->find(name); if (index < UINT_MAX) { - if (index < c->function->formalParameterCount()) { - c->callData->args[c->function->formalParameterCount() - index - 1] = value; + if (index < c->v4Function->nFormals) { + c->callData->args[c->v4Function->nFormals - index - 1] = value; } else { - index -= c->function->formalParameterCount(); + index -= c->v4Function->nFormals; c->locals[index] = value; } return; @@ -408,13 +410,12 @@ ReturnedValue ExecutionContext::getProperty(String *name) case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast(ctx->d()); - ScopedFunctionObject f(scope, c->function); - if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { - uint index = f->function()->internalClass->find(name); + if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) { + uint index = c->v4Function->internalClass->find(name); if (index < UINT_MAX) { - if (index < c->function->formalParameterCount()) - return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); - return c->locals[index - c->function->formalParameterCount()].asReturnedValue(); + if (index < c->v4Function->nFormals) + return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue(); + return c->locals[index - c->v4Function->nFormals].asReturnedValue(); } } ScopedObject activation(scope, c->activation); @@ -424,9 +425,9 @@ ReturnedValue ExecutionContext::getProperty(String *name) if (hasProperty) return v->asReturnedValue(); } - if (f->function() && f->function()->isNamedExpression() - && name->equals(ScopedString(scope, f->function()->name()))) - return f.asReturnedValue(); + if (c->v4Function && c->v4Function->isNamedExpression() + && name->equals(ScopedString(scope, c->v4Function->name()))) + return c->function->asReturnedValue(); break; } case Heap::ExecutionContext::Type_QmlContext: { @@ -487,13 +488,12 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast(ctx->d()); - ScopedFunctionObject f(scope, c->function); - if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { - uint index = f->function()->internalClass->find(name); + if (c->v4Function && (c->v4Function->needsActivation() || hasWith || hasCatchScope)) { + uint index = c->v4Function->internalClass->find(name); if (index < UINT_MAX) { - if (index < c->function->formalParameterCount()) - return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); - return c->locals[index - c->function->formalParameterCount()].asReturnedValue(); + if (index < c->v4Function->nFormals) + return c->callData->args[c->v4Function->nFormals - index - 1].asReturnedValue(); + return c->locals[index - c->v4Function->nFormals].asReturnedValue(); } } ScopedObject activation(scope, c->activation); @@ -503,9 +503,9 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) if (hasProperty) return v->asReturnedValue(); } - if (f->function() && f->function()->isNamedExpression() - && name->equals(ScopedString(scope, f->function()->name()))) - return f.asReturnedValue(); + if (c->v4Function && c->v4Function->isNamedExpression() + && name->equals(ScopedString(scope, c->v4Function->name()))) + return c->function->asReturnedValue(); break; } case Heap::ExecutionContext::Type_QmlContext: { diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 487917df7d..e5fd67d410 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -65,6 +65,7 @@ struct CompilationUnit; struct Function; } +struct Function; struct Identifier; struct CallContext; struct CatchContext; @@ -140,11 +141,15 @@ struct CallContext : ExecutionContext { { ExecutionContext::init(engine, t); function = 0; + v4Function = 0; locals = 0; activation = 0; } + inline unsigned int formalParameterCount() const; + Pointer function; + QV4::Function *v4Function; Value *locals; Pointer activation; }; diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 12094a0943..beba5a1fd6 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -53,6 +53,7 @@ #include "qv4global_p.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -97,6 +98,13 @@ struct Q_QML_EXPORT Function { }; + +inline unsigned int Heap::CallContext::formalParameterCount() const +{ + return v4Function ? v4Function->nFormals : 0; +} + + } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 8e84eaebe7..02ea763b30 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -539,6 +539,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.function = f->d(); QV4::Function *ff = ctx.function->function; + ctx.v4Function = ff; ctx.strictMode = ff->isStrict(); ctx.callData = callData; ctx.compilationUnit = ff->compilationUnit; @@ -580,6 +581,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal CallContext::Data ctx = CallContext::Data::createOnStack(v4); ctx.function = f->d(); QV4::Function *ff = ctx.function->function; + ctx.v4Function = ff; ctx.strictMode = ff->isStrict(); ctx.callData = callData; ctx.compilationUnit = ff->compilationUnit; -- cgit v1.2.3 From b4ccdf004af8ab5b9e327abf7f87d0bd34ee13c0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Nov 2016 16:20:32 +0100 Subject: Change ExecutionContext::getFunctionObject() to getFunction() And return a QV4::Function from now on. This simplifies code in other places and provides all the info required for stack traces and debugging. Change-Id: I512a8ac3932268d8cfc60675e75c4661d1f16fd8 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qqmlnativedebugservice.cpp | 24 ++++++++-------------- .../qmltooling/qmldbg_debugger/qv4debugger.cpp | 5 ++--- src/qml/jsruntime/qv4context.cpp | 4 ++-- src/qml/jsruntime/qv4context_p.h | 2 +- src/qml/jsruntime/qv4engine.cpp | 14 +++++-------- src/qml/jsruntime/qv4vme_moth.cpp | 6 ++---- 6 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp index 5b96163b48..14dfc5356e 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlnativedebugservice.cpp @@ -336,18 +336,16 @@ void NativeDebugger::handleBacktrace(QJsonObject *response, const QJsonObject &a QJsonArray frameArray; QV4::ExecutionContext *executionContext = m_engine->currentContext; for (int i = 0; i < limit && executionContext; ++i) { - QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject(); - if (heapFunctionObject) { + if (QV4::Function *function = executionContext->getFunction()) { QJsonObject frame; frame[QStringLiteral("language")] = QStringLiteral("js"); frame[QStringLiteral("context")] = encodeContext(executionContext); - if (QV4::Function *function = heapFunctionObject->function) { - if (QV4::Heap::String *functionName = function->name()) - frame[QStringLiteral("function")] = functionName->toQString(); - frame[QStringLiteral("file")] = function->sourceFile(); - } + if (QV4::Heap::String *functionName = function->name()) + frame[QStringLiteral("function")] = functionName->toQString(); + frame[QStringLiteral("file")] = function->sourceFile(); + int line = executionContext->d()->lineNumber; frame[QStringLiteral("line")] = (line < 0 ? -line : line); @@ -667,11 +665,9 @@ void NativeDebugger::aboutToThrow() QV4::Function *NativeDebugger::getFunction() const { - QV4::Scope scope(m_engine); QV4::ExecutionContext *context = m_engine->currentContext; - QV4::ScopedFunctionObject function(scope, context->getFunctionObject()); - if (function) - return function->function(); + if (QV4::Function *function = context->getFunction()) + return function; else return context->d()->engine->globalCode; } @@ -683,10 +679,8 @@ void NativeDebugger::pauseAndWait() event.insert(QStringLiteral("event"), QStringLiteral("break")); event.insert(QStringLiteral("language"), QStringLiteral("js")); if (QV4::ExecutionContext *executionContext = m_engine->currentContext) { - QV4::Heap::FunctionObject *heapFunctionObject = executionContext->getFunctionObject(); - if (heapFunctionObject) { - if (QV4::Function *function = heapFunctionObject->function) - event.insert(QStringLiteral("file"), function->sourceFile()); + if (QV4::Function *function = executionContext->getFunction()) { + event.insert(QStringLiteral("file"), function->sourceFile()); int line = executionContext->d()->lineNumber; event.insert(QStringLiteral("line"), (line < 0 ? -line : line)); } diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp index 44810dd4cb..5cc2043cb1 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugger.cpp @@ -252,9 +252,8 @@ QV4::Function *QV4Debugger::getFunction() const { QV4::Scope scope(m_engine); QV4::ExecutionContext *context = m_engine->currentContext; - QV4::ScopedFunctionObject function(scope, context->getFunctionObject()); - if (function) - return function->function(); + if (QV4::Function *function = context->getFunction()) + return function; else return context->d()->engine->globalCode; } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 5d4a1b07b5..26f2f996a6 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -524,13 +524,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) return engine()->throwReferenceError(n); } -Heap::FunctionObject *ExecutionContext::getFunctionObject() const +Function *ExecutionContext::getFunction() const { Scope scope(d()->engine); ScopedContext it(scope, this->d()); for (; it; it = it->d()->outer) { if (const CallContext *callCtx = it->asCallContext()) - return callCtx->d()->function; + return callCtx->d()->v4Function; else if (it->asCatchContext() || it->asWithContext()) continue; // look in the parent context for a FunctionObject else diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index e5fd67d410..7bf58ab5c6 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -214,7 +214,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed inline const CatchContext *asCatchContext() const; inline const WithContext *asWithContext() const; - Heap::FunctionObject *getFunctionObject() const; + Function *getFunction() const; static void markObjects(Heap::Base *m, ExecutionEngine *e); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 698c73a910..c438b99cf0 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -780,21 +780,17 @@ QVector ExecutionEngine::stackTrace(int frameLimit) const QVector stack; ExecutionContext *c = currentContext; - ScopedFunctionObject function(scope); while (c && frameLimit) { - function = c->getFunctionObject(); + QV4::Function *function = c->getFunction(); if (function) { StackFrame frame; - if (const Function *f = function->function()) - frame.source = f->sourceFile(); + frame.source = function->sourceFile(); name = function->name(); frame.function = name->toQString(); - frame.line = -1; - frame.column = -1; - if (function->function()) - // line numbers can be negative for places where you can't set a real breakpoint - frame.line = qAbs(c->d()->lineNumber); + // line numbers can be negative for places where you can't set a real breakpoint + frame.line = qAbs(c->d()->lineNumber); + frame.column = -1; stack.append(frame); --frameLimit; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index b19c36a5bd..622359a7d9 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -169,10 +169,8 @@ static Breakpoint qt_v4LastStop; static QV4::Function *qt_v4ExtractFunction(QV4::ExecutionContext *context) { - QV4::Scope scope(context->engine()); - QV4::ScopedFunctionObject function(scope, context->getFunctionObject()); - if (function) - return function->function(); + if (QV4::Function *function = context->getFunction()) + return function; else return context->d()->engine->globalCode; } -- cgit v1.2.3 From 558bb0e3bbbd3eaca52b02946374f2106c3a3872 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 7 Dec 2016 14:19:54 +0100 Subject: QQuickWindowPrivate::dragOverThreshold(): ignore zero velocity threshold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, this would trigger a drag even if the touch point was quite steady, since a rather steady finger could report a very small velocity (usually between 0 and 1). Change so that it will ignore velocity if it's not positive. At the same time convert it to a template function since we want to also use this for QQuickEventPoint later on. Change-Id: Ibb2210813707399ae84e3422718c995897891060 Reviewed-by: Jan Arve SƦther Reviewed-by: Shawn Rutledge --- src/quick/items/qquickwindow.cpp | 10 ---------- src/quick/items/qquickwindow_p.h | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index ef079fdf92..155a52bd9b 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -2638,15 +2637,6 @@ bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent return overThreshold; } -bool QQuickWindowPrivate::dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold) -{ - QStyleHints *styleHints = qApp->styleHints(); - bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance()); - qreal velocity = axis == Qt::XAxis ? tp->velocity().x() : tp->velocity().y(); - overThreshold |= qAbs(velocity) > styleHints->startDragVelocity(); - return overThreshold; -} - /*! \qmlproperty list Window::data \default diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index 32a6939868..829fe53458 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -66,6 +66,8 @@ #include #include #include +#include +#include QT_BEGIN_NAMESPACE @@ -270,7 +272,19 @@ public: static bool defaultAlphaBuffer; static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int startDragThreshold = -1); - static bool dragOverThreshold(qreal d, Qt::Axis axis, const QTouchEvent::TouchPoint *tp, int startDragThreshold = -1); + + template + static bool dragOverThreshold(qreal d, Qt::Axis axis, const TEventPoint *p, int startDragThreshold = -1) + { + QStyleHints *styleHints = qApp->styleHints(); + bool overThreshold = qAbs(d) > (startDragThreshold >= 0 ? startDragThreshold : styleHints->startDragDistance()); + const bool dragVelocityLimitAvailable = (styleHints->startDragVelocity() > 0); + if (!overThreshold && dragVelocityLimitAvailable) { + qreal velocity = axis == Qt::XAxis ? p->velocity().x() : p->velocity().y(); + overThreshold |= qAbs(velocity) > styleHints->startDragVelocity(); + } + return overThreshold; + } // data property static void data_append(QQmlListProperty *, QObject *); -- cgit v1.2.3 From ee347ee875f69aff72df294546a0c90ffd79de93 Mon Sep 17 00:00:00 2001 From: Marco Benelli Date: Thu, 1 Dec 2016 11:02:36 +0100 Subject: qmlplugindump: avoid warnings Wrap all global variable in an anonymous namespace in order to avoid compiler warnings on the uninizialized ones. Change-Id: Ifabb790d2d76b6056d706580b9e4c0f12f5119f0 Reviewed-by: Erik Verbruggen --- tools/qmlplugindump/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index cfd14aff6d..883afa057c 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -72,11 +72,12 @@ #include #endif +namespace { -static const uint qtQmlMajorVersion = 2; -static const uint qtQmlMinorVersion = 2; -static const uint qtQuickMajorVersion = 2; -static const uint qtQuickMinorVersion = 8; +const uint qtQmlMajorVersion = 2; +const uint qtQmlMinorVersion = 2; +const uint qtQuickMajorVersion = 2; +const uint qtQuickMinorVersion = 8; const QString qtQuickQualifiedName = QString::fromLatin1("QtQuick %1.%2") .arg(qtQuickMajorVersion) @@ -89,6 +90,8 @@ bool creatable = true; QString currentProperty; QString inObjectInstantiation; +} + static QString enquote(const QString &string) { QString s = string; -- cgit v1.2.3 From 9a3b339e1c3aea4e92149706357e988979593b4d Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 7 Dec 2016 14:41:38 +0100 Subject: QQuickSpriteEngine: Optimistic speedup for updateSprites Switch from QList to QVector, and avoid using pop_front -- remove all in one operation instead. The idea here was to provide some gain to sprite-sequence in qmlbench, but any possible gain is pretty miniscule due to the lack of batching that example suffers. Still, we end up with less CPU time taken, which is a win of sorts. Change-Id: Ib7c101afa71ee617c3c4506b14701d6a4143ed3a Reviewed-by: Gunnar Sletta --- src/quick/items/qquickspriteengine.cpp | 11 ++++++----- src/quick/items/qquickspriteengine_p.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp index 10e0d51709..b1905f2cc5 100644 --- a/src/quick/items/qquickspriteengine.cpp +++ b/src/quick/items/qquickspriteengine.cpp @@ -664,13 +664,14 @@ uint QQuickStochasticEngine::updateSprites(uint time)//### would returning a lis //Sprite State Update; m_timeOffset = time; m_addAdvance = false; - while (!m_stateUpdates.isEmpty() && time >= m_stateUpdates.constFirst().first){ - const auto copy = m_stateUpdates.constFirst().second; + int i = 0; + for (; i < m_stateUpdates.count() && time >= m_stateUpdates.at(i).first; ++i) { + const auto copy = m_stateUpdates.at(i).second; for (int idx : copy) advance(idx); - m_stateUpdates.pop_front(); } + m_stateUpdates.remove(0, i); m_advanceTime.start(); m_addAdvance = true; if (m_stateUpdates.isEmpty()) @@ -760,13 +761,13 @@ void QQuickStochasticEngine::addToUpdateList(uint t, int idx) m_stateUpdates[i].second << idx; return; } else if (m_stateUpdates.at(i).first > t) { - QList tmpList; + QVector tmpList; tmpList << idx; m_stateUpdates.insert(i, qMakePair(t, tmpList)); return; } } - QList tmpList; + QVector tmpList; tmpList << idx; m_stateUpdates << qMakePair(t, tmpList); } diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h index cf50cd2d84..3b7fcfb1f1 100644 --- a/src/quick/items/qquickspriteengine_p.h +++ b/src/quick/items/qquickspriteengine_p.h @@ -254,7 +254,7 @@ protected: QVector m_goals; QVector m_duration; QVector m_startTimes; - QList > > m_stateUpdates;//### This could be done faster - priority queue? + QVector > > m_stateUpdates;//### This could be done faster - priority queue? QTime m_advanceTime; uint m_timeOffset; -- cgit v1.2.3 From 260f45d539b3ec1b28f593706ce7c164836f814c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 30 Nov 2016 10:29:06 +0100 Subject: tst_QQuickPathView, tst_QQuickListView: Fix compiler warnings Fix warnings about assignment used as truth value in Q[TRY_]VERIFY by generally pulling out the assignment in case of QVERIFY and adding parentheses in case of QTRY_VERIFY. Also fix 2 cases in which apparently QTRY_VERIFY(find()) was intended. Fixes warnings: tst_qquickpathview.cpp: In member function 'void tst_QQuickPathView::creationContext()': tst_qquickpathview.cpp:1637:100: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp: In member function 'void tst_QQuickPathView::currentOffsetOnInsertion()': tst_qquickpathview.cpp:1688:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp:1700:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquickpathview.cpp:1712:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::sectionsPositioning()': tst_qquicklistview.cpp:2392:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::itemListFlicker()': tst_qquicklistview.cpp:2979:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2981:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2983:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2988:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2990:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2992:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2997:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:2999:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:3001:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::creationContext()': tst_qquicklistview.cpp:5339:97: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5341:98: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5343:98: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5345:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::unrequestedVisibility()': tst_qquicklistview.cpp:5626:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5628:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5631:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5633:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5636:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5638:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5640:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5642:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5650:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5652:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5663:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5665:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5668:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5670:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5673:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5675:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5677:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5679:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5687:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5690:103: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5692:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5695:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5697:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5699:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5701:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5707:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5709:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5711:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5713:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5719:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5721:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5723:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5725:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5731:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5733:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5735:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5737:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5743:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5745:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5747:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:5749:104: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::displayMargin()': tst_qquicklistview.cpp:7255:100: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7259:102: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp: In member function 'void tst_QQuickListView::negativeDisplayMargin()': tst_qquicklistview.cpp:7292:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7295:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7298:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tst_qquicklistview.cpp:7303:99: warning: suggest parentheses around assignment used as truth value [-Wparentheses] Change-Id: Ic069c8336cf15db75860c6f79dfd215a5592ca79 Reviewed-by: Robin Burchell --- .../quick/qquicklistview/tst_qquicklistview.cpp | 218 +++++++++++++-------- .../quick/qquickpathview/tst_qquickpathview.cpp | 13 +- 2 files changed, 144 insertions(+), 87 deletions(-) diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index b0d903908f..61ba2caaf7 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -2373,7 +2373,7 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header + QTRY_VERIFY((topItem = findVisibleChild(contentItem, "sect_aaa"))); // section header QCOMPARE(topItem->y(), 10.); // remove section boundary @@ -2389,7 +2389,8 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(item->y(), qreal(i*20*6)); } - QVERIFY(topItem = findVisibleChild(contentItem, "sect_1")); + topItem = findVisibleChild(contentItem, "sect_1"); + QVERIFY(topItem); QTRY_COMPARE(topItem->y(), 120.); // Change the next section @@ -2974,31 +2975,38 @@ void tst_QQuickListView::itemListFlicker() QTRY_COMPARE(model->count(), 3); QTRY_COMPARE(listview->currentIndex(), 0); - QQuickItem *item; - - QVERIFY(item = findItem(contentItem, "item1")); + QQuickItem *item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(1); - QVERIFY(item = findItem(contentItem, "item1")); + item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); listview->setCurrentIndex(2); - QVERIFY(item = findItem(contentItem, "item1")); + item = findItem(contentItem, "item1"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item2")); + item = findItem(contentItem, "item2"); + QVERIFY(item); QVERIFY(delegateVisible(item)); - QVERIFY(item = findItem(contentItem, "item3")); + item = findItem(contentItem, "item3"); + QVERIFY(item); QVERIFY(delegateVisible(item)); } @@ -5335,14 +5343,17 @@ void tst_QQuickListView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem(rootItem, "listItem")); + QQuickItem *item = findItem(rootItem, "listItem"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("header")); + item = rootItem->findChild("header"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("footer")); + item = rootItem->findChild("footer"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); - QVERIFY(item = rootItem->findChild("section")); + item = rootItem->findChild("section"); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -5604,42 +5615,49 @@ void tst_QQuickListView::unrequestedVisibility() QVERIFY(QTest::qWaitForWindowExposed(window)); - QQuickListView *leftview = findItem(window->rootObject(), "leftList"); - QTRY_VERIFY(leftview != 0); + QQuickListView *leftview; + QTRY_VERIFY((leftview = findItem(window->rootObject(), "leftList"))); - QQuickListView *rightview = findItem(window->rootObject(), "rightList"); - QTRY_VERIFY(rightview != 0); + QQuickListView *rightview; + QTRY_VERIFY((rightview = findItem(window->rootObject(), "rightList"))); QQuickItem *leftContent = leftview->contentItem(); - QTRY_VERIFY(leftContent != 0); + QTRY_VERIFY((leftContent = leftview->contentItem())); - QQuickItem *rightContent = rightview->contentItem(); - QTRY_VERIFY(rightContent != 0); + QQuickItem *rightContent; + QTRY_VERIFY((rightContent = rightview->contentItem())); rightview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 100.0); - QQuickItem *item; - - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + const QString wrapperObjectName = QStringLiteral("wrapper"); + QQuickItem *item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 16)); + item = findItem(leftContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 17)); + item = findItem(leftContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 3)); + item = findItem(rightContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 4)); + item = findItem(rightContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); rightview->setCurrentIndex(0); @@ -5647,106 +5665,139 @@ void tst_QQuickListView::unrequestedVisibility() QTRY_COMPARE(leftview->contentY(), 0.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); - QVERIFY(!findItem(leftContent, "wrapper", 19)); - QVERIFY(!findItem(rightContent, "wrapper", 19)); + QVERIFY(!findItem(leftContent, wrapperObjectName, 19)); + QVERIFY(!findItem(rightContent, wrapperObjectName, 19)); leftview->setCurrentIndex(20); QTRY_COMPARE(leftview->contentY(), 100.0); QTRY_COMPARE(rightview->contentY(), 0.0); - QVERIFY(item = findItem(leftContent, "wrapper", 1)); + item = findItem(leftContent, wrapperObjectName, 1); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 3)); + item = findItem(leftContent, wrapperObjectName, 3); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(19, 1, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QTRY_VERIFY(item = findItem(leftContent, "wrapper", 1)); + QTRY_VERIFY((item = findItem(leftContent, wrapperObjectName, 1))); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(rightContent, "wrapper", 1)); + item = findItem(rightContent, wrapperObjectName, 1); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(leftContent, "wrapper", 19)); + item = findItem(leftContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 19)); + item = findItem(rightContent, wrapperObjectName, 19); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(3, 4, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(4, 3, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(16, 17, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); model.moveItems(17, 16, 1); QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); - QVERIFY(item = findItem(leftContent, "wrapper", 4)); + item = findItem(leftContent, wrapperObjectName, 4); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); - QVERIFY(item = findItem(leftContent, "wrapper", 5)); + item = findItem(leftContent, wrapperObjectName, 5); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 16)); + item = findItem(rightContent, wrapperObjectName, 16); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(rightContent, "wrapper", 17)); + item = findItem(rightContent, wrapperObjectName, 17); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); delete window; @@ -7249,14 +7300,14 @@ void tst_QQuickListView::displayMargin() QQuickItem *content = listview->contentItem(); QVERIFY(content != 0); - QQuickItem *item0; - QQuickItem *item14; - - QVERIFY(item0 = findItem(content, "delegate", 0)); + QQuickItem *item0 = findItem(content, "delegate", 0); + QVERIFY(item0); QCOMPARE(delegateVisible(item0), true); // the 14th item should be within the end margin - QVERIFY(item14 = findItem(content, "delegate", 13)); + + QQuickItem *item14 = findItem(content, "delegate", 13); + QVERIFY(item14); QCOMPARE(delegateVisible(item14), true); // the 15th item should be outside the end margin @@ -7273,7 +7324,6 @@ void tst_QQuickListView::displayMargin() void tst_QQuickListView::negativeDisplayMargin() { - QQuickItem *item; QScopedPointer window(createView()); window->setSource(testFileUrl("negativeDisplayMargin.qml")); window->show(); @@ -7289,22 +7339,26 @@ void tst_QQuickListView::negativeDisplayMargin() QQuickItem *content = innerList->contentItem(); QVERIFY(content != 0); - QVERIFY(item = findItem(content, "delegate", 0)); + QQuickItem *item = findItem(content, "delegate", 0); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(content, "delegate", 7)); + item = findItem(content, "delegate", 7); + QVERIFY(item); QCOMPARE(delegateVisible(item), true); - QVERIFY(item = findItem(content, "delegate", 8)); + item = findItem(content, "delegate", 8); + QVERIFY(item); QCOMPARE(delegateVisible(item), false); // Flick until contentY means that delegate8 should be visible listview->setProperty("contentY", 500); - QVERIFY(item = findItem(content, "delegate", 8)); + item = findItem(content, "delegate", 8); + QVERIFY(item); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 1000); - QTRY_VERIFY(item = findItem(content, "delegate", 14)); + QTRY_VERIFY((item = findItem(content, "delegate", 14))); QTRY_COMPARE(delegateVisible(item), true); listview->setProperty("contentY", 0); diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index d013d190ec..ba3d182efc 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -1633,8 +1633,8 @@ void tst_QQuickPathView::creationContext() QVERIFY(rootItem); QVERIFY(rootItem->property("count").toInt() > 0); - QQuickItem *item; - QVERIFY(item = findItem(rootItem, "listItem", 0)); + QQuickItem *item = findItem(rootItem, "listItem", 0); + QVERIFY(item); QCOMPARE(item->property("text").toString(), QString("Hello!")); } @@ -1685,7 +1685,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 1); // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); + item = findItem(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1697,7 +1698,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 2); // currentIndex is now 2 - QVERIFY(item = findItem(pathview, "wrapper", 2)); + item = findItem(pathview, "wrapper", 2); + QVERIFY(item); // verify that current item (item 2) is still at offset 0.5 QCOMPARE(item->position() + offset, start); @@ -1709,7 +1711,8 @@ void tst_QQuickPathView::currentOffsetOnInsertion() QCOMPARE(currentIndexSpy.count(), 3); // currentIndex is now 1 - QVERIFY(item = findItem(pathview, "wrapper", 1)); + item = findItem(pathview, "wrapper", 1); + QVERIFY(item); // verify that current item (item 1) is still at offset 0.5 QCOMPARE(item->position() + offset, start); -- cgit v1.2.3 From 9f4cfec74517f7ff3f65037ad04abac33e2104ba Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 Dec 2016 21:01:51 +0100 Subject: Avoid some copies of Values on the JS stack Change-Id: I1c7dca6e8d17da9f3d76b68d072370b087840f2b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 18 ++++++++---------- src/qml/jsruntime/qv4functionobject_p.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 02ea763b30..66549ffd3e 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -216,8 +216,7 @@ Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlCont runtimeFunction->updateInternalClass(engine, signalParameters); } - QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction)); - return function->d(); + return QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction); } @@ -344,11 +343,11 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) { - Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->thisObject().as()); + FunctionObject *o = ctx->thisObject().as(); if (!o) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedValue arg(scope, ctx->argument(1)); ScopedObject arr(scope, arg); @@ -387,12 +386,11 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) ReturnedValue FunctionPrototype::method_call(CallContext *ctx) { - Scope scope(ctx); - - ScopedFunctionObject o(scope, ctx->thisObject().as()); + FunctionObject *o = ctx->thisObject().as(); if (!o) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0); if (ctx->argc()) { for (int i = 1; i < ctx->argc(); ++i) @@ -406,11 +404,11 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) { - Scope scope(ctx); - ScopedFunctionObject target(scope, ctx->thisObject()); + FunctionObject *target = ctx->thisObject().as(); if (!target) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedValue boundThis(scope, ctx->argument(0)); Scoped boundArgs(scope, (Heap::MemberData *)0); if (ctx->argc() > 1) { @@ -601,7 +599,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); } -Heap::Object *SimpleScriptFunction::protoForConstructor() +Heap::Object *SimpleScriptFunction::protoForConstructor() const { Scope scope(engine()); ScopedObject p(scope, protoProperty()); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 3dcc7ab482..5c176b88b4 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -154,7 +154,7 @@ struct Q_QML_EXPORT FunctionObject: Object { static Heap::FunctionObject *createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction, const QList &signalParameters = QList(), QString *error = 0); - ReturnedValue protoProperty() { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); } + ReturnedValue protoProperty() const { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); } bool needsActivation() const { return d()->needsActivation(); } bool strictMode() const { return d()->function ? d()->function->isStrict() : false; } @@ -232,7 +232,7 @@ struct SimpleScriptFunction: FunctionObject { static void construct(const Managed *, Scope &scope, CallData *callData); static void call(const Managed *that, Scope &scope, CallData *callData); - Heap::Object *protoForConstructor(); + Heap::Object *protoForConstructor() const; }; struct ScriptFunction: SimpleScriptFunction { -- cgit v1.2.3 From 55101d6937880f4dfd8d8eb79fbb15a8e7bb508a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Nov 2016 15:35:16 +0100 Subject: Move the check whether a function is simple to QV4::Function This allows re-using the check in the QQmlJavascriptExpression code. Change-Id: I647a6edb4844911f540f08c4a067d055676dd0ed Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4function_p.h | 9 +++++++++ src/qml/jsruntime/qv4functionobject.cpp | 9 +++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index beba5a1fd6..802af43cdc 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -91,6 +91,15 @@ struct Q_QML_EXPORT Function { inline bool needsActivation() const { return activationRequired; } + inline bool canUseSimpleFunction() const { + if (needsActivation() || + compiledFunction->flags & CompiledData::Function::HasCatchOrWith || + compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || + isNamedExpression()) + return false; + return true; + } + QQmlSourceLocation sourceLocation() const { return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 66549ffd3e..21edf1d8d3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -195,12 +195,9 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e) Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) { - if (function->needsActivation() || - function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith || - function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || - function->isNamedExpression()) - return scope->d()->engine->memoryManager->allocObject(scope, function); - return scope->d()->engine->memoryManager->allocObject(scope, function, createProto); + if (function->canUseSimpleFunction()) + return scope->d()->engine->memoryManager->allocObject(scope, function, createProto); + return scope->d()->engine->memoryManager->allocObject(scope, function); } Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, Function *runtimeFunction, const QList &signalParameters, QString *error) -- cgit v1.2.3 From 68d73a253a974967e18ba23719af31fd47434585 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Nov 2016 15:37:22 +0100 Subject: Add sourceLocation() accessor to QQmlJavascriptExpression And remove it from the derived QQmlBoundSignalExpression class. Change-Id: I93cdc67136ddd916474acd2169faf380e296a900 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 3 ++- src/qml/qml/qqmlboundsignal.cpp | 13 ------------- src/qml/qml/qqmlboundsignal_p.h | 1 - src/qml/qml/qqmljavascriptexpression.cpp | 5 +++++ src/qml/qml/qqmljavascriptexpression_p.h | 2 ++ 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index d55b4df13e..5e41ea1758 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -197,6 +197,7 @@ protected: QQmlPropertyData::WriteFlags flags, QV4::Scope &scope, const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL { + Q_UNUSED(f); auto ep = QQmlEnginePrivate::get(scope.engine); ep->referenceScarceResources(); @@ -212,7 +213,7 @@ protected: if (!watcher.wasDeleted()) { if (error) { - delayedError()->setErrorLocation(f->sourceLocation()); + delayedError()->setErrorLocation(sourceLocation()); delayedError()->setErrorObject(m_target.data()); } diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 4e63790290..7b7e6562ff 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -157,19 +157,6 @@ void QQmlBoundSignalExpression::expressionChanged() // bound signals do not notify on change. } -QQmlSourceLocation QQmlBoundSignalExpression::sourceLocation() const -{ - QV4::Function *f = function(); - if (f) { - QQmlSourceLocation loc; - loc.sourceFile = f->sourceFile(); - loc.line = f->compiledFunction->location.line; - loc.column = f->compiledFunction->location.column; - return loc; - } - return QQmlSourceLocation(); -} - QString QQmlBoundSignalExpression::expression() const { if (expressionFunctionValid()) { diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index 10c59b07c1..2234f08497 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -86,7 +86,6 @@ public: void evaluate(void **a); void evaluate(const QList &args); - QQmlSourceLocation sourceLocation() const; QString expression() const; QV4::Function *function() const; QObject *target() const { return m_target; } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 54d9222a8e..f81320aa6b 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -128,6 +128,11 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged() setNotifyOnValueChanged(false); } +QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const +{ + return m_function.valueRef()->as()->sourceLocation(); +} + void QQmlJavaScriptExpression::setContext(QQmlContextData *context) { if (m_prevExpression) { diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 5f9cffb56d..038f9688a1 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -113,6 +113,8 @@ public: inline QObject *scopeObject() const; inline void setScopeObject(QObject *v); + QQmlSourceLocation sourceLocation() const; + bool isValid() const { return context() != 0; } QQmlContextData *context() const { return m_context; } -- cgit v1.2.3 From e54e4408bd03edc789370dd7670eb6da25e8a9bb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Nov 2016 15:50:47 +0100 Subject: Minor cleanup Change-Id: I091f2de77f84fb298404dc8784defcf3a812d56a Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlobjectcreator.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index f450cbf965..ba3c6600b8 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -809,13 +809,14 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con // the result is written to a value type virtual property, that contains the sub-index // of the "x" property. QQmlBinding *qmlBinding; + const QQmlPropertyData *prop = property; + const QQmlPropertyData *subprop = nullptr; if (_valueTypeProperty) { - qmlBinding = QQmlBinding::create(_valueTypeProperty, function, _scopeObject, context); - qmlBinding->setTarget(_bindingTarget, *_valueTypeProperty, property); - } else { - qmlBinding = QQmlBinding::create(property, function, _scopeObject, context); - qmlBinding->setTarget(_bindingTarget, *property, nullptr); + prop = _valueTypeProperty; + subprop = property; } + qmlBinding = QQmlBinding::create(prop, function, _scopeObject, context); + qmlBinding->setTarget(_bindingTarget, *prop, subprop); sharedState->allCreatedBindings.push(QQmlAbstractBinding::Ptr(qmlBinding)); -- cgit v1.2.3 From deec039008c4df5ec2686459ee8c00801ee9d852 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 1 Dec 2016 15:37:32 +0100 Subject: Refactor the calling code for (Simple)ScriptFunction Factor the common code out into separate methods that can later on be reused by the QQmlJavaScriptExpression. Also ensure a CallContext is safe to use with a 0 FunctionObject. Change-Id: I1181a8e320b8c931d9df5b2c91bc143d8587fb60 Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qv4datacollector.cpp | 2 +- src/qml/jsruntime/qv4context.cpp | 76 ++++++++++++++++++---- src/qml/jsruntime/qv4context_p.h | 9 ++- src/qml/jsruntime/qv4engine.cpp | 5 +- src/qml/jsruntime/qv4functionobject.cpp | 73 +++++---------------- src/qml/jsruntime/qv4script.cpp | 34 ++-------- 6 files changed, 93 insertions(+), 106 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp index b2db23d78c..aed2759383 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp @@ -60,7 +60,7 @@ QV4::CallContext *QV4DataCollector::findContext(int frame) QV4::ExecutionContext *ctx = engine()->currentContext; while (ctx) { QV4::CallContext *cCtxt = ctx->asCallContext(); - if (cCtxt && cCtxt->d()->function) { + if (cCtxt && cCtxt->d()->v4Function) { if (frame < 1) return cCtxt; --frame; diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 26f2f996a6..df0ecdd5d3 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -48,6 +48,8 @@ #include "qv4errorobject_p.h" #include "qv4string_p.h" #include "qv4qmlcontext_p.h" +#include "qv4profiling_p.h" +#include using namespace QV4; @@ -57,28 +59,30 @@ DEFINE_MANAGED_VTABLE(WithContext); DEFINE_MANAGED_VTABLE(CatchContext); DEFINE_MANAGED_VTABLE(GlobalContext); -Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *function, CallData *callData) -{ - Q_ASSERT(function->function()); +/* Function *f, int argc */ +#define requiredMemoryForExecutionContect(f, argc) \ + ((sizeof(CallContext::Data) + 7) & ~7) + \ + sizeof(Value) * (f->compiledFunction->nLocals + qMax((uint)argc, f->nFormals)) + sizeof(CallData) +Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData *callData) +{ Heap::CallContext *c = d()->engine->memoryManager->allocManaged( requiredMemoryForExecutionContect(function, callData->argc)); c->init(d()->engine, Heap::ExecutionContext::Type_CallContext); - c->function = function->d(); - c->v4Function = function->d()->function; + c->v4Function = function; - c->strictMode = function->strictMode(); - c->outer = function->scope(); + c->strictMode = function->isStrict(); + c->outer = this->d(); c->activation = 0; - c->compilationUnit = function->function()->compilationUnit; + c->compilationUnit = function->compilationUnit; c->lookups = c->compilationUnit->runtimeLookups; c->constantTable = c->compilationUnit->constants; c->locals = (Value *)((quintptr(c + 1) + 7) & ~7); - const CompiledData::Function *compiledFunction = function->function()->compiledFunction; + const CompiledData::Function *compiledFunction = function->compiledFunction; int nLocals = compiledFunction->nLocals; if (nLocals) std::fill(c->locals, c->locals + nLocals, Primitive::undefinedValue()); @@ -278,7 +282,7 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) break; case Heap::ExecutionContext::Type_CallContext: { QV4::Heap::CallContext *c = static_cast(ctx); - Q_ASSERT(c->v4Function && c->function); + Q_ASSERT(c->v4Function); ctx->callData->thisObject.mark(engine); for (int arg = 0; arg < qMax(ctx->callData->argc, (int)c->v4Function->nFormals); ++arg) ctx->callData->args[arg].mark(engine); @@ -286,7 +290,8 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) c->locals[local].mark(engine); if (c->activation) c->activation->mark(engine); - c->function->mark(engine); + if (c->function) + c->function->mark(engine); break; } case Heap::ExecutionContext::Type_QmlContext: { @@ -297,6 +302,51 @@ void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) } } +// Do a standard call with this execution context as the outer scope +void ExecutionContext::call(Scope &scope, CallData *callData, Function *function, const FunctionObject *f) +{ + ExecutionContextSaver ctxSaver(scope); + + Scoped ctx(scope, newCallContext(function, callData)); + if (f) + ctx->d()->function = f->d(); + scope.engine->pushContext(ctx); + + scope.result = Q_V4_PROFILE(scope.engine, function); + + if (function->hasQmlDependencies) + QQmlPropertyCapture::registerQmlDependencies(function->compiledFunction, scope); +} + +// Do a simple, fast call with this execution context as the outer scope +void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Function *function) +{ + Q_ASSERT(function->canUseSimpleFunction()); + + ExecutionContextSaver ctxSaver(scope); + + CallContext::Data ctx = CallContext::Data::createOnStack(scope.engine); + + ctx.strictMode = function->isStrict(); + ctx.callData = callData; + ctx.v4Function = function; + ctx.compilationUnit = function->compilationUnit; + ctx.lookups = function->compilationUnit->runtimeLookups; + ctx.constantTable = function->compilationUnit->constants; + ctx.outer = this->d(); + ctx.locals = scope.alloc(function->compiledFunction->nLocals); + for (int i = callData->argc; i < (int)function->nFormals; ++i) + callData->args[i] = Encode::undefined(); + + scope.engine->pushContext(&ctx); + Q_ASSERT(scope.engine->current == &ctx); + + scope.result = Q_V4_PROFILE(scope.engine, function); + + if (function->compiledFunction->hasQmlDependencies()) + QQmlPropertyCapture::registerQmlDependencies(function->compiledFunction, scope); +} + void ExecutionContext::setProperty(String *name, const Value &value) { Scope scope(this); @@ -425,7 +475,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) if (hasProperty) return v->asReturnedValue(); } - if (c->v4Function && c->v4Function->isNamedExpression() + if (c->function && c->v4Function->isNamedExpression() && name->equals(ScopedString(scope, c->v4Function->name()))) return c->function->asReturnedValue(); break; @@ -503,7 +553,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) if (hasProperty) return v->asReturnedValue(); } - if (c->v4Function && c->v4Function->isNamedExpression() + if (c->function && c->v4Function->isNamedExpression() && name->equals(ScopedString(scope, c->v4Function->name()))) return c->function->asReturnedValue(); break; diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 7bf58ab5c6..c985fdb24d 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -198,7 +198,7 @@ struct Q_QML_EXPORT ExecutionContext : public Managed ExecutionEngine *engine() const { return d()->engine; } - Heap::CallContext *newCallContext(const FunctionObject *f, CallData *callData); + Heap::CallContext *newCallContext(Function *f, CallData *callData); Heap::WithContext *newWithContext(Heap::Object *with); Heap::CatchContext *newCatchContext(Heap::String *exceptionVarName, ReturnedValue exceptionValue); @@ -230,6 +230,9 @@ struct Q_QML_EXPORT ExecutionContext : public Managed ReturnedValue argument(int i) const { return d()->callData->argument(i); } + + void call(Scope &scope, CallData *callData, QV4::Function *function, const QV4::FunctionObject *f = 0); + void simpleCall(Scope &scope, CallData *callData, QV4::Function *function); }; struct Q_QML_EXPORT CallContext : public ExecutionContext @@ -296,10 +299,6 @@ inline Heap::CallContext Heap::CallContext::createOnStack(ExecutionEngine *v4) return ctxt; } -/* Function *f, int argc */ -#define requiredMemoryForExecutionContect(f, argc) \ - ((sizeof(CallContext::Data) + 7) & ~7) + sizeof(Value) * (f->varCount() + qMax((uint)argc, f->formalParameterCount())) + sizeof(CallData) - } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index c438b99cf0..0520bfe216 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -866,9 +866,8 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file) ExecutionContext *c = currentContext; while (c) { CallContext *callCtx = c->asCallContext(); - if (callCtx && callCtx->d()->function) { - if (callCtx->d()->function->function) - base.setUrl(callCtx->d()->function->function->sourceFile()); + if (callCtx && callCtx->d()->v4Function) { + base.setUrl(callCtx->d()->v4Function->sourceFile()); break; } c = parentContext(c); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 21edf1d8d3..08d66bec6f 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -441,15 +441,13 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call InternalClass *ic = v4->emptyClass; ScopedObject proto(scope, f->protoForConstructor()); ScopedObject obj(scope, v4->newObject(ic, proto)); - callData->thisObject = obj.asReturnedValue(); - Scoped ctx(scope, v4->currentContext->newCallContext(f, callData)); - v4->pushContext(ctx); - scope.result = Q_V4_PROFILE(v4, f->function()); + QV4::Function *v4Function = f->function(); + Q_ASSERT(v4Function); - if (f->function()->hasQmlDependencies) - QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); + ScopedContext c(scope, f->scope()); + c->call(scope, callData, v4Function, f); if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); @@ -467,16 +465,13 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) } CHECK_STACK_LIMITS(v4, scope); - ExecutionContextSaver ctxSaver(scope); - Scoped f(scope, static_cast(that)); - Scoped ctx(scope, v4->currentContext->newCallContext(f, callData)); - v4->pushContext(ctx); - scope.result = Q_V4_PROFILE(v4, f->function()); + QV4::Function *v4Function = f->function(); + Q_ASSERT(v4Function); - if (f->function()->hasQmlDependencies) - QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); + ScopedContext c(scope, f->scope()); + c->call(scope, callData, v4Function, f); } DEFINE_OBJECT_VTABLE(SimpleScriptFunction); @@ -523,35 +518,17 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData } CHECK_STACK_LIMITS(v4, scope); - ExecutionContextSaver ctxSaver(scope); - Scoped f(scope, static_cast(that)); InternalClass *ic = scope.engine->emptyClass; ScopedObject proto(scope, f->protoForConstructor()); callData->thisObject = v4->newObject(ic, proto); - CallContext::Data ctx = CallContext::Data::createOnStack(v4); - ctx.function = f->d(); - QV4::Function *ff = ctx.function->function; - ctx.v4Function = ff; - ctx.strictMode = ff->isStrict(); - ctx.callData = callData; - ctx.compilationUnit = ff->compilationUnit; - ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.constantTable = ctx.compilationUnit->constants; - ctx.outer = ctx.function->scope; - if (unsigned varCount = f->varCount()) - ctx.locals = scope.alloc(varCount); - for (int i = callData->argc; i < static_cast(ff->nFormals); ++i) - callData->args[i] = Encode::undefined(); - v4->pushContext(&ctx); - Q_ASSERT(v4->current == &ctx); + QV4::Function *v4Function = f->function(); + Q_ASSERT(v4Function); - scope.result = Q_V4_PROFILE(v4, ff); - - if (ff->hasQmlDependencies) - QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); + ScopedContext c(scope, f->scope()); + c->simpleCall(scope, callData, v4Function); if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); @@ -569,31 +546,13 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal } CHECK_STACK_LIMITS(v4, scope); - ExecutionContextSaver ctxSaver(scope); - Scoped f(scope, static_cast(that)); - CallContext::Data ctx = CallContext::Data::createOnStack(v4); - ctx.function = f->d(); - QV4::Function *ff = ctx.function->function; - ctx.v4Function = ff; - ctx.strictMode = ff->isStrict(); - ctx.callData = callData; - ctx.compilationUnit = ff->compilationUnit; - ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.constantTable = ctx.compilationUnit->constants; - ctx.outer = ctx.function->scope; - if (unsigned varCount = f->varCount()) - ctx.locals = scope.alloc(varCount); - for (int i = callData->argc; i < static_cast(ff->nFormals); ++i) - callData->args[i] = Encode::undefined(); - v4->pushContext(&ctx); - Q_ASSERT(v4->current == &ctx); - - scope.result = Q_V4_PROFILE(v4, ff); + QV4::Function *v4Function = f->function(); + Q_ASSERT(v4Function); - if (ff->hasQmlDependencies) - QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); + ScopedContext c(scope, f->scope()); + c->simpleCall(scope, callData, v4Function); } Heap::Object *SimpleScriptFunction::protoForConstructor() const diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 8c27d36f50..25089855bb 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -72,7 +72,9 @@ struct QmlBindingWrapper : FunctionObject { struct QmlBindingWrapper : FunctionObject { V4_OBJECT2(QmlBindingWrapper, FunctionObject) - static void call(const Managed *that, Scope &scope, CallData *callData); + static void call(const Managed *that, Scope &scope, CallData *callData) { + QV4::ScriptFunction::call(that, scope, callData); + } }; } @@ -94,30 +96,6 @@ void Heap::QmlBindingWrapper::init(QV4::QmlContext *scope, Function *f) function->compilationUnit->addref(); } -void QmlBindingWrapper::call(const Managed *that, Scope &scope, CallData *callData) -{ - const QmlBindingWrapper *This = static_cast(that); - ExecutionEngine *v4 = static_cast(that)->engine(); - if (v4->hasException) { - scope.result = Encode::undefined(); - return; - } - CHECK_STACK_LIMITS(v4, scope); - - ExecutionContextSaver ctxSaver(scope); - - QV4::Function *f = This->function(); - if (!f) { - scope.result = QV4::Encode::undefined(); - return; - } - - Scoped ctx(scope, v4->currentContext->newCallContext(This, callData)); - v4->pushContext(ctx); - - scope.result = Q_V4_PROFILE(v4, f); -} - Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) , compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true) @@ -228,10 +206,12 @@ ReturnedValue Script::run() return Q_V4_PROFILE(engine, vmFunction); } else { Scoped qml(valueScope, qmlContext.value()); - ScopedFunctionObject f(valueScope, engine->memoryManager->allocObject(qml, vmFunction)); ScopedCallData callData(valueScope); callData->thisObject = Primitive::undefinedValue(); - f->call(valueScope, callData); + if (vmFunction->canUseSimpleFunction()) + qml->simpleCall(valueScope, callData, vmFunction); + else + qml->call(valueScope, callData, vmFunction); return valueScope.result.asReturnedValue(); } } -- cgit v1.2.3 From c6baaaa8e65ac82a3d644459cf42f76d03a0442d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 12:35:52 +0100 Subject: Get rid od ScriptFunction::init() It was just forwarding to the parent implementation anyway. Change-Id: I179966699978a86efdd6792b31b56eded501efbd Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 5 ----- src/qml/jsruntime/qv4functionobject_p.h | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 08d66bec6f..172b29e88b 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -420,11 +420,6 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) DEFINE_OBJECT_VTABLE(ScriptFunction); -void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) -{ - Heap::SimpleScriptFunction::init(scope, function, true); -} - void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData) { ExecutionEngine *v4 = scope.engine; diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 5c176b88b4..118caffadb 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -110,11 +110,10 @@ struct SimpleScriptFunction : FunctionObject { Index_Name = FunctionObject::Index_Prototype + 1, Index_Length }; - void init(QV4::ExecutionContext *scope, Function *function, bool createProto); + void init(QV4::ExecutionContext *scope, Function *function, bool createProto = true); }; struct ScriptFunction : SimpleScriptFunction { - void init(QV4::ExecutionContext *scope, Function *function); }; struct BoundFunction : FunctionObject { -- cgit v1.2.3 From cb56c7a35dc0b98284cd2ac2ff00c669a1e3489d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 1 Dec 2016 22:25:40 +0100 Subject: Remove unused argument Change-Id: Ie490f113b6fc48ea75eb5903a79dddb02faa7301 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 9 +++------ src/qml/qml/qqmlbinding_p.h | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 5e41ea1758..5f0f2eabcc 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -162,7 +162,7 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags) flags.setFlag(QQmlPropertyData::BypassInterceptor); QQmlBindingProfiler prof(ep->profiler, this, f); - doUpdate(watcher, flags, scope, f); + doUpdate(watcher, flags, scope); if (!watcher.wasDeleted()) setUpdatingFlag(false); @@ -177,8 +177,7 @@ class QQmlBindingBinding: public QQmlBinding { protected: void doUpdate(const DeleteWatcher &, - QQmlPropertyData::WriteFlags flags, QV4::Scope &, - const QV4::ScopedFunctionObject &) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &) Q_DECL_OVERRIDE Q_DECL_FINAL { Q_ASSERT(!m_targetIndex.hasValueTypeIndex()); QQmlPropertyData *pd = nullptr; @@ -194,10 +193,8 @@ class QQmlNonbindingBinding: public QQmlBinding { protected: void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &scope, - const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) Q_DECL_OVERRIDE Q_DECL_FINAL { - Q_UNUSED(f); auto ep = QQmlEnginePrivate::get(scope.engine); ep->referenceScarceResources(); diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 3454adaf50..fb33e3aacd 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -101,8 +101,7 @@ public: protected: virtual void doUpdate(const DeleteWatcher &watcher, - QQmlPropertyData::WriteFlags flags, QV4::Scope &scope, - const QV4::ScopedFunctionObject &f) = 0; + QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) = 0; void getPropertyData(QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const; int getPropertyType() const; -- cgit v1.2.3 From 84e86b61bfd7650993324e64d72ac73635effc77 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 9 Dec 2016 10:58:31 +0100 Subject: Bump QML cache file version After the recent data structure changes this seems appropriate to force a cache rebuild for those following the branch in release builds. Change-Id: Ie4c0534729a752137068b8f24beb9d15e7895c46 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index b9b1b1a5d5..2682365182 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE // Bump this whenever the compiler data structures change in an incompatible way. -#define QV4_DATA_STRUCTURE_VERSION 0x07 +#define QV4_DATA_STRUCTURE_VERSION 0x08 class QIODevice; class QQmlPropertyCache; -- cgit v1.2.3 From d7ef2aa02c9ba736104fe973bfce7d87e30f81af Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 7 Dec 2016 13:56:45 +0100 Subject: Qml Inspector: Avoid taking a QPointer of an object being deleted As we manually remove items to be deleted from the list of selected items, we don't need to keep them as QPointer in the first place. Change-Id: Ie416b47d4f193cb3dc7cfb07e66ab2b36ad6721c Reviewed-by: Simon Hausmann --- src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp | 4 +--- src/plugins/qmltooling/qmldbg_inspector/globalinspector.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp index 107d54c626..ca7c76ab50 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp @@ -234,9 +234,7 @@ bool GlobalInspector::syncSelectedItems(const QList &items) bool selectionChanged = false; // Disconnect and remove items that are no longer selected - foreach (const QPointer &item, m_selectedItems) { - if (!item) // Don't see how this can happen due to handling of destroyed() - continue; + foreach (QQuickItem *item, m_selectedItems) { if (items.contains(item)) continue; diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h index 338eee14c3..f7b325c454 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.h @@ -84,7 +84,7 @@ private: bool syncSelectedItems(const QList &items); // Hash< object to be destroyed, QPair > - QList > m_selectedItems; + QList m_selectedItems; QHash m_highlightItems; QList m_windowInspectors; int m_eventId; -- cgit v1.2.3 From f9b8436a07534867686627b656418d62f75ba3e5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 09:50:36 +0100 Subject: Mostly use the QV4::Function in javascript expressions Move the function() accessor from QQmlBoundSIgnal to QQmlJavaScriptExpression. Change the profiler to operate on QV4::Function objects for binding profiling. Change-Id: Ic7ce83c487ceb69cad4b16e3dab42026238b7e82 Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmlprofiler_p.h | 9 +++++++-- src/qml/qml/qqmlbinding.cpp | 20 ++++++-------------- src/qml/qml/qqmlboundsignal.cpp | 19 ++----------------- src/qml/qml/qqmlboundsignal_p.h | 3 +-- src/qml/qml/qqmljavascriptexpression.cpp | 12 ++++++++++++ src/qml/qml/qqmljavascriptexpression_p.h | 2 ++ 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h index 6643695d11..242f26ee0d 100644 --- a/src/qml/debugger/qqmlprofiler_p.h +++ b/src/qml/debugger/qqmlprofiler_p.h @@ -204,6 +204,11 @@ public: ref(new BindingRefCount(binding), QQmlRefPointer::Adopt), sent(false) {} + RefLocation(QQmlBinding *binding, QV4::Function *function) : + Location(function->sourceLocation()), locationType(Binding), + ref(new BindingRefCount(binding), QQmlRefPointer::Adopt), sent(false) + {} + RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, const QString &type) : Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url), @@ -231,7 +236,7 @@ public: typedef QHash LocationHash; - void startBinding(QQmlBinding *binding, QV4::FunctionObject *function) + void startBinding(QQmlBinding *binding, QV4::Function *function) { quintptr locationId(id(binding)); m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(), @@ -326,7 +331,7 @@ struct QQmlProfilerHelper : public QQmlProfilerDefinitions { struct QQmlBindingProfiler : public QQmlProfilerHelper { QQmlBindingProfiler(QQmlProfiler *profiler, QQmlBinding *binding, - QV4::FunctionObject *function) : + QV4::Function *function) : QQmlProfilerHelper(profiler) { Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler, diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 5f0f2eabcc..c7d185ff9a 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -155,13 +155,11 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); QV4::Scope scope(ep->v4engine()); - QV4::ScopedFunctionObject f(scope, m_function.value()); - Q_ASSERT(f); if (canUseAccessor()) flags.setFlag(QQmlPropertyData::BypassInterceptor); - QQmlBindingProfiler prof(ep->profiler, this, f); + QQmlBindingProfiler prof(ep->profiler, this, function()); doUpdate(watcher, flags, scope); if (!watcher.wasDeleted()) @@ -420,14 +418,10 @@ QVariant QQmlBinding::evaluate() QString QQmlBinding::expressionIdentifier() { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); - QV4::Scope scope(ep->v4engine()); - QV4::ScopedValue f(scope, m_function.value()); - QV4::Function *function = f->as()->function(); - - QString url = function->sourceFile(); - quint16 lineNumber = function->compiledFunction->location.line; - quint16 columnNumber = function->compiledFunction->location.column; + auto f = function(); + QString url = f->sourceFile(); + quint16 lineNumber = f->compiledFunction->location.line; + quint16 columnNumber = f->compiledFunction->location.column; return url + QString::asprintf(":%u:%u", uint(lineNumber), uint(columnNumber)); } @@ -458,9 +452,7 @@ void QQmlBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags) QString QQmlBinding::expression() const { - QV4::Scope scope(QQmlEnginePrivate::get(context()->engine)->v4engine()); - QV4::ScopedValue v(scope, m_function.value()); - return v->toQStringNoThrow(); + return QStringLiteral("function() { [code] }"); } void QQmlBinding::setTarget(const QQmlProperty &prop) diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 7b7e6562ff..e88c836ce0 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -159,26 +159,11 @@ void QQmlBoundSignalExpression::expressionChanged() QString QQmlBoundSignalExpression::expression() const { - if (expressionFunctionValid()) { - Q_ASSERT (context() && engine()); - QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine()); - QV4::ScopedValue v(scope, m_function.value()); - return v->toQStringNoThrow(); - } + if (expressionFunctionValid()) + return QStringLiteral("function() { [code] }"); return QString(); } -QV4::Function *QQmlBoundSignalExpression::function() const -{ - if (expressionFunctionValid()) { - Q_ASSERT (context() && engine()); - QV4::Scope scope(QQmlEnginePrivate::get(engine())->v4engine()); - QV4::ScopedFunctionObject v(scope, m_function.value()); - return v ? v->function() : 0; - } - return 0; -} - // Parts of this function mirror code in QQmlExpressionPrivate::value() and v8value(). // Changes made here may need to be made there and vice versa. void QQmlBoundSignalExpression::evaluate(void **a) diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index 2234f08497..b9b0c2b481 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -87,7 +87,6 @@ public: void evaluate(const QList &args); QString expression() const; - QV4::Function *function() const; QObject *target() const { return m_target; } QQmlEngine *engine() const { return context() ? context()->engine : 0; } @@ -97,7 +96,7 @@ private: void init(QQmlContextData *ctxt, QObject *scope); - bool expressionFunctionValid() const { return !m_function.isNullOrUndefined(); } + bool expressionFunctionValid() const { return function() != 0; } int m_index; QObject *m_target; diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index f81320aa6b..a694b43447 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -48,6 +48,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -131,6 +132,9 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged() QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const { return m_function.valueRef()->as()->sourceLocation(); + // Can't use the below yet, as the source location for bindings gnerated with Qt.binding() would be wrong. +// auto f = function(); +// return f ? f->sourceLocation() : QQmlSourceLocation(); } void QQmlJavaScriptExpression::setContext(QQmlContextData *context) @@ -154,6 +158,14 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context) } } +QV4::Function *QQmlJavaScriptExpression::function() const +{ + QV4::FunctionObject *f = m_function.valueRef()->as(); + if (f && f->isBinding()) + return static_cast(f)->d()->originalFunction->function; + return f ? f->function() : 0; +} + void QQmlJavaScriptExpression::refresh() { } diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 038f9688a1..3e00d6be24 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -120,6 +120,8 @@ public: QQmlContextData *context() const { return m_context; } void setContext(QQmlContextData *context); + QV4::Function *function() const; + virtual void refresh(); class DeleteWatcher { -- cgit v1.2.3 From 9de7d0e9f170ed0a4baedaa33b3a68e166901a8a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 09:56:57 +0100 Subject: Change signature of QQmlBinding::create to take a FunctionObject * This is what's in the Value in all cases anyway. Change-Id: I212c4c4076050e8d0ea4cf6f72a1683e132cd51b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 +- src/qml/qml/qqmlbinding.cpp | 4 ++-- src/qml/qml/qqmlbinding_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 2 +- src/quick/util/qquickpropertychanges.cpp | 2 +- tests/auto/qml/qqmllanguage/testtypes.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 7ded931af3..235f2fee5a 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -393,7 +393,7 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP QV4::Scoped bindingFunction(scope, (const Value &)f); bindingFunction->initBindingLocation(); - newBinding = QQmlBinding::create(property, value, object, callingQmlContext); + newBinding = QQmlBinding::create(property, f, object, callingQmlContext); newBinding->setTarget(object, *property, nullptr); } } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index c7d185ff9a..f21d68b8a9 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -108,7 +108,7 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString return b; } -QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Value &functionPtr, QObject *obj, QQmlContextData *ctxt) +QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::FunctionObject *function, QObject *obj, QQmlContextData *ctxt) { QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); @@ -116,7 +116,7 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Va b->QQmlJavaScriptExpression::setContext(ctxt); b->setScopeObject(obj); - b->m_function.set(functionPtr.as()->engine(), functionPtr); + b->m_function.set(function->engine(), *function); return b; } diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index fb33e3aacd..23ad06b8c2 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -75,7 +75,7 @@ public: static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *); static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *, const QString &url = QString(), quint16 lineNumber = 0); - static QQmlBinding *create(const QQmlPropertyData *, const QV4::Value &, QObject *, QQmlContextData *); + static QQmlBinding *create(const QQmlPropertyData *, const QV4::FunctionObject *function, QObject *, QQmlContextData *); ~QQmlBinding(); void setTarget(const QQmlProperty &); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 8fb1f869ff..fe1bd584de 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -455,7 +455,7 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) QV4::Scoped bindingFunction(scope, (const Value &)f); bindingFunction->initBindingLocation(); - QQmlBinding *newBinding = QQmlBinding::create(&cacheData, value, reference->d()->object, context); + QQmlBinding *newBinding = QQmlBinding::create(&cacheData, f, reference->d()->object, context); newBinding->setTarget(reference->d()->object, cacheData, pd); QQmlPropertyPrivate::setBinding(newBinding); return; diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index 331ba32365..6930b3973d 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -455,7 +455,7 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions() QQmlBinding *newBinding = 0; if (e.id != QQmlBinding::Invalid) { QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions.at(e.id))); + QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions.at(e.id))); newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, function, object(), context); } diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 3af7645ff7..91c7cfe305 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -129,7 +129,7 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); + QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); QQmlProperty property(m_target, name, qmlContext(this)); QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, -- cgit v1.2.3 From 8fb453c5e68c32c8a15c766dd0995679e28d88d5 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 11:00:23 +0100 Subject: Avoid using the FunctionObject in QQmlJavaScriptExpression::evaluate() Rather directly execute the call on the QV4::Function. Change-Id: I1de52075760be6b3a0358af83270ebd4e1d1e8ae Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index a694b43447..cb36758f74 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -176,13 +176,14 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin { Q_ASSERT(m_context && m_context->engine); - QV4::Value *f = m_function.valueRef(); - if (!f || f->isUndefined()) { + QV4::Function *v4Function = function(); + if (!v4Function) { if (isUndefined) *isUndefined = true; return; } + QV4::FunctionObject *f = static_cast(m_function.valueRef()); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_context->engine); // All code that follows must check with watcher before it accesses data members @@ -208,7 +209,13 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin callData->thisObject = value; } - f->as()->call(scope, callData); + QV4::ScopedContext outer(scope, f->scope()); + if (v4Function->canUseSimpleFunction()) { + outer->simpleCall(scope, callData, v4Function); + } else { + outer->call(scope, callData, v4Function); + } + if (scope.hasException()) { if (watcher.wasDeleted()) scope.engine->catchException(); // ignore exception -- cgit v1.2.3 From b4f4caababf3c561dbf61a4c75450598cb424ca0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 12:43:09 +0100 Subject: Remove some dead code Change-Id: Ibf6d50926edd85ebee545bcfdfcd14cb0eeab969 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlboundsignal.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index e88c836ce0..18d1e6bb4a 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -99,10 +99,6 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, function += QLatin1String(") { ") + expression + QLatin1String(" })"); m_function.set(v4, evalFunction(context(), scopeObject(), function, fileName, line)); - - if (m_function.isNullOrUndefined()) - return; // could not evaluate function. Not valid. - } QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function) -- cgit v1.2.3 From f1dca03794f8db353655d44e742a2960f1f69070 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 12:47:28 +0100 Subject: Don't create a QML function is the signal parameters are invalid Moves the error checking to where the error occurs. Change-Id: I2590d3a9d41f41c16d19e4f5883b78a8b28a883c Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 4 +++- src/qml/qml/qqmlboundsignal.cpp | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 172b29e88b..c65882ed7a 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -208,8 +208,10 @@ Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlCont QV4::Scoped wrapperContext(valueScope, QmlContext::create(global, qmlContext, scopeObject)); if (!signalParameters.isEmpty()) { - if (error) + if (error) { QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, error); + return 0; + } runtimeFunction->updateInternalClass(engine, signalParameters); } diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 18d1e6bb4a..91b3f89825 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -122,10 +122,8 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QString error; QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error)); - if (!error.isEmpty()) { + if (!error.isEmpty()) qmlInfo(scopeObject()) << error; - m_function.clear(); - } } void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope) -- cgit v1.2.3 From 1eee98f1c1c59f8c45387684e269629713958bd4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 14:23:04 +0100 Subject: Limit access to m_function to QQmlJavaScriptExpression Change-Id: I070f73f106440667fce2c7fe33310369a6aa1376 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 6 ++++-- src/qml/qml/qqmlboundsignal.cpp | 10 +++++++--- src/qml/qml/qqmlexpression.cpp | 4 +++- src/qml/qml/qqmljavascriptexpression.cpp | 15 ++++++++++++--- src/qml/qml/qqmljavascriptexpression_p.h | 3 ++- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index f21d68b8a9..a8232904fe 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -85,7 +85,9 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(b->context()->engine)->v4engine(); if (runtimeFunction) { - b->m_function.set(v4, QV4::FunctionObject::createQmlFunction(ctxtdata, b->scopeObject(), runtimeFunction)); + QV4::Scope scope(v4); + QV4::ScopedFunctionObject f(scope, QV4::FunctionObject::createQmlFunction(ctxtdata, b->scopeObject(), runtimeFunction)); + b->setFunctionObject(f); } else { QString code = scriptPrivate->script; b->createQmlBinding(b->context(), b->scopeObject(), code, url, scriptPrivate->lineNumber); @@ -116,7 +118,7 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Fu b->QQmlJavaScriptExpression::setContext(ctxt); b->setScopeObject(obj); - b->m_function.set(function->engine(), *function); + b->setFunctionObject(function); return b; } diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 91b3f89825..974bd3404a 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -98,7 +98,9 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, function += parameterString; function += QLatin1String(") { ") + expression + QLatin1String(" })"); - m_function.set(v4, evalFunction(context(), scopeObject(), function, fileName, line)); + QV4::Scope valueScope(v4); + QV4::ScopedFunctionObject f(valueScope, evalFunction(context(), scopeObject(), function, fileName, line)); + setFunctionObject(f); } QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function) @@ -106,7 +108,7 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, m_index(index), m_target(target) { - m_function.set(function.as()->engine(), function); + setFunctionObject(function.as()); init(ctxt, scope); } @@ -121,7 +123,9 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index); QString error; QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); - m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error)); + QV4::Scope valueScope(engine); + QV4::ScopedFunctionObject f(valueScope, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error)); + setFunctionObject(f); if (!error.isEmpty()) qmlInfo(scopeObject()) << error; } diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 6afbd05e3e..2a9d0a7b90 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -75,7 +75,9 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu { expressionFunctionValid = true; QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); - m_function.set(engine, QV4::FunctionObject::createQmlFunction(ctxt, me, runtimeFunction)); + QV4::Scope scope(engine); + QV4::ScopedFunctionObject f(scope, QV4::FunctionObject::createQmlFunction(ctxt, me, runtimeFunction)); + setFunctionObject(f); QQmlJavaScriptExpression::setContext(ctxt); setScopeObject(me); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index cb36758f74..9616a088ae 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -160,7 +160,10 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context) QV4::Function *QQmlJavaScriptExpression::function() const { - QV4::FunctionObject *f = m_function.valueRef()->as(); + QV4::Value *v = m_function.valueRef(); + if (!v) + return 0; + QV4::FunctionObject *f = v->as(); if (f && f->isBinding()) return static_cast(f)->d()->originalFunction->function; return f ? f->function() : 0; @@ -430,7 +433,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope)); QV4::Script script(v4, qmlContext, code, filename, line); - QV4::ScopedValue result(scope); + QV4::ScopedFunctionObject result(scope); script.parse(); if (!v4->hasException) result = script.qmlBinding(); @@ -446,7 +449,13 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * ep->warning(error); result = QV4::Encode::undefined(); } - m_function.set(v4, result); + setFunctionObject(result); +} + +void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) +{ + if (o) + m_function.set(o->engine(), o->d()); } diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 3e00d6be24..887672b925 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -158,6 +158,8 @@ protected: } } + void setFunctionObject(const QV4::FunctionObject *o); + private: friend class QQmlContextData; friend class QQmlPropertyCapture; @@ -177,7 +179,6 @@ private: QQmlJavaScriptExpression *m_nextExpression; bool m_permanentDependenciesRegistered = false; -protected: QV4::PersistentValue m_function; }; -- cgit v1.2.3 From 421d21a0334002f6497ce105876856dc0647c8ff Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 15:02:39 +0100 Subject: Don't store a FunctionObject in QQmlJavaScriptExpression anymore Instead store the QmlContext, the QV4::Function and a source location. Change-Id: Iafa54c09b9be7e78bace3498673ca94a2a145c97 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 42 +++++++++++++++++++------------- src/qml/qml/qqmljavascriptexpression_p.h | 5 +++- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 9616a088ae..dc7c1cb8e1 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -95,7 +95,9 @@ QQmlJavaScriptExpression::QQmlJavaScriptExpression() : m_error(0), m_context(0), m_prevExpression(0), - m_nextExpression(0) + m_nextExpression(0), + m_v4Function(0), + m_sourceLocation(0) { } @@ -111,6 +113,8 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression() clearPermanentGuards(); if (m_scopeObject.isT2()) // notify DeleteWatcher of our deletion. m_scopeObject.asT2()->_s = 0; + + delete m_sourceLocation; } void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v) @@ -131,10 +135,11 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged() QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const { - return m_function.valueRef()->as()->sourceLocation(); - // Can't use the below yet, as the source location for bindings gnerated with Qt.binding() would be wrong. -// auto f = function(); -// return f ? f->sourceLocation() : QQmlSourceLocation(); + if (m_sourceLocation) + return *m_sourceLocation; + if (m_v4Function) + return m_v4Function->sourceLocation(); + return QQmlSourceLocation(); } void QQmlJavaScriptExpression::setContext(QQmlContextData *context) @@ -160,13 +165,7 @@ void QQmlJavaScriptExpression::setContext(QQmlContextData *context) QV4::Function *QQmlJavaScriptExpression::function() const { - QV4::Value *v = m_function.valueRef(); - if (!v) - return 0; - QV4::FunctionObject *f = v->as(); - if (f && f->isBinding()) - return static_cast(f)->d()->originalFunction->function; - return f ? f->function() : 0; + return m_v4Function; } void QQmlJavaScriptExpression::refresh() @@ -186,7 +185,6 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin return; } - QV4::FunctionObject *f = static_cast(m_function.valueRef()); QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_context->engine); // All code that follows must check with watcher before it accesses data members @@ -212,7 +210,7 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin callData->thisObject = value; } - QV4::ScopedContext outer(scope, f->scope()); + QV4::ExecutionContext *outer = static_cast(m_qmlScope.valueRef()); if (v4Function->canUseSimpleFunction()) { outer->simpleCall(scope, callData, v4Function); } else { @@ -454,10 +452,20 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) { - if (o) - m_function.set(o->engine(), o->d()); -} + if (!o) + return; + m_qmlScope.set(o->engine(), o->d()->scope); + + m_v4Function = o->d()->function; + if (o->isBinding()) { + const QV4::QQmlBindingFunction *b = static_cast(o); + m_sourceLocation = new QQmlSourceLocation(*b->d()->bindingLocation); + m_v4Function = b->d()->originalFunction->function; + } + Q_ASSERT(m_v4Function); + m_compilationUnit = m_v4Function->compilationUnit; +} void QQmlJavaScriptExpression::clearActiveGuards() { diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 887672b925..36024082c9 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -179,7 +179,10 @@ private: QQmlJavaScriptExpression *m_nextExpression; bool m_permanentDependenciesRegistered = false; - QV4::PersistentValue m_function; + QV4::PersistentValue m_qmlScope; + QQmlRefPointer m_compilationUnit; + QV4::Function *m_v4Function; + QQmlSourceLocation *m_sourceLocation; // used for Qt.binding() created functions }; class QQmlPropertyCapture -- cgit v1.2.3 From c953f8b550b7ea9e7989f9fddaaa14324354aea3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 2 Dec 2016 15:19:45 +0100 Subject: Avoid the creation of a FunctionObject for most bindings Change-Id: Ia62d380945250015009d9c2b6ed65f6d830277ef Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlbinding.cpp | 15 +++++++++++++++ src/qml/qml/qqmlbinding_p.h | 2 ++ src/qml/qml/qqmljavascriptexpression.cpp | 9 +++++++++ src/qml/qml/qqmljavascriptexpression_p.h | 1 + src/qml/qml/qqmlobjectcreator.cpp | 6 +++--- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index a8232904fe..aabdf00f6e 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -123,6 +123,21 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::Fu return b; } +QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function *function, + QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext) +{ + QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); + + b->setNotifyOnValueChanged(true); + b->QQmlJavaScriptExpression::setContext(ctxt); + b->setScopeObject(obj); + + Q_ASSERT(sharedContext); + b->setupFunction(sharedContext, function); + + return b; +} + QQmlBinding::~QQmlBinding() { } diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 23ad06b8c2..889f2ad0af 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -76,6 +76,8 @@ public: static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *, const QString &url = QString(), quint16 lineNumber = 0); static QQmlBinding *create(const QQmlPropertyData *, const QV4::FunctionObject *function, QObject *, QQmlContextData *); + static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function, + QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext); ~QQmlBinding(); void setTarget(const QQmlProperty &); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index dc7c1cb8e1..5c6c0a0dce 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -467,6 +467,15 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_compilationUnit = m_v4Function->compilationUnit; } +void QQmlJavaScriptExpression::setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f) +{ + if (!qmlContext || !f) + return; + m_qmlScope.set(qmlContext->engine(), *qmlContext); + m_v4Function = f; + m_compilationUnit = m_v4Function->compilationUnit; +} + void QQmlJavaScriptExpression::clearActiveGuards() { while (QQmlJavaScriptExpressionGuard *g = activeGuards.takeFirst()) diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 36024082c9..8a230efeeb 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -159,6 +159,7 @@ protected: } void setFunctionObject(const QV4::FunctionObject *o); + void setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f); private: friend class QQmlContextData; diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index ba3c6600b8..be6a197414 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -792,10 +792,10 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex]; QV4::Scope scope(v4); - QV4::ScopedContext qmlContext(scope, currentQmlContext()); - QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false)); + QV4::Scoped qmlContext(scope, currentQmlContext()); if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) { + QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false)); int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex()); QQmlBoundSignal *bs = new QQmlBoundSignal(_bindingTarget, signalIndex, _scopeObject, engine); QQmlBoundSignalExpression *expr = new QQmlBoundSignalExpression(_bindingTarget, signalIndex, @@ -815,7 +815,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con prop = _valueTypeProperty; subprop = property; } - qmlBinding = QQmlBinding::create(prop, function, _scopeObject, context); + qmlBinding = QQmlBinding::create(prop, runtimeFunction, _scopeObject, context, qmlContext); qmlBinding->setTarget(_bindingTarget, *prop, subprop); sharedState->allCreatedBindings.push(QQmlAbstractBinding::Ptr(qmlBinding)); -- cgit v1.2.3 From bf661342652b02177fc1a5cd29195a443dac5bc1 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 10:50:55 +0100 Subject: Don't create a FunctionObject in createQmlBinding() This also removes the last use of the QmlBindingWrapper, so remove that class as well. Change-Id: I2ec795b6ab695a689fb24d64c9b8809b651c2b37 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4script.cpp | 47 -------------------------------- src/qml/jsruntime/qv4script_p.h | 1 - src/qml/qml/qqmljavascriptexpression.cpp | 7 ++--- 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 25089855bb..5d7df9a9d7 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -58,44 +58,8 @@ #include #include -QT_BEGIN_NAMESPACE - -namespace QV4 { -namespace Heap { - -struct QmlBindingWrapper : FunctionObject { - void init(QV4::QmlContext *scope, Function *f); -}; - -} - -struct QmlBindingWrapper : FunctionObject { - V4_OBJECT2(QmlBindingWrapper, FunctionObject) - - static void call(const Managed *that, Scope &scope, CallData *callData) { - QV4::ScriptFunction::call(that, scope, callData); - } -}; - -} - -QT_END_NAMESPACE - using namespace QV4; -DEFINE_OBJECT_VTABLE(QmlBindingWrapper); - -void Heap::QmlBindingWrapper::init(QV4::QmlContext *scope, Function *f) -{ - Heap::FunctionObject::init(scope, scope->d()->engine->id_eval(), /*createProto = */ false); - - Q_ASSERT(scope->inUse()); - - function = f; - if (function) - function->compilationUnit->addref(); -} - Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) , compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true) @@ -280,17 +244,6 @@ QQmlRefPointer Script::precompile(IR::Module return isel->compile(/*generate unit data*/false); } -ReturnedValue Script::qmlBinding() -{ - if (!parsed) - parse(); - ExecutionEngine *v4 = scope->engine(); - Scope valueScope(v4); - Scoped qml(valueScope, qmlContext.value()); - ScopedObject v(valueScope, v4->memoryManager->allocObject(qml, vmFunction)); - return v.asReturnedValue(); -} - QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext) { QV4::Scope scope(engine); diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 686fa49c88..f96f0254a5 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -136,7 +136,6 @@ struct Q_QML_EXPORT Script { void parse(); ReturnedValue run(); - ReturnedValue qmlBinding(); Function *function(); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 5c6c0a0dce..96a9f5b6b1 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -431,10 +431,7 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxt, qmlScope)); QV4::Script script(v4, qmlContext, code, filename, line); - QV4::ScopedFunctionObject result(scope); script.parse(); - if (!v4->hasException) - result = script.qmlBinding(); if (v4->hasException) { QQmlError error = v4->catchExceptionAsQmlError(); if (error.description().isEmpty()) @@ -445,9 +442,9 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * error.setUrl(QUrl::fromLocalFile(filename)); error.setObject(qmlScope); ep->warning(error); - result = QV4::Encode::undefined(); + return; } - setFunctionObject(result); + setupFunction(qmlContext, script.vmFunction); } void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) -- cgit v1.2.3 From 82ee8341fba141e2e1e44948d2161a694add1584 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 12:42:41 +0100 Subject: Get rid of FunctionObject::createQmlFunction Instead, simply create a QmlContext, and setup the bindings with the QV4::Function itself. Change-Id: I9db93b15112e43a6d5e275d126fb20f9c8833e8f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 19 ------------------- src/qml/jsruntime/qv4functionobject_p.h | 2 -- src/qml/qml/qqmlbinding.cpp | 4 ++-- src/qml/qml/qqmlboundsignal.cpp | 20 ++++++++++++++------ src/qml/qml/qqmlexpression.cpp | 4 ++-- src/quick/util/qquickpropertychanges.cpp | 4 ++-- tests/auto/qml/qqmllanguage/testtypes.cpp | 7 +++---- 7 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index c65882ed7a..0f2a0ebf86 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -200,25 +200,6 @@ Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *sco return scope->d()->engine->memoryManager->allocObject(scope, function); } -Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, Function *runtimeFunction, const QList &signalParameters, QString *error) -{ - ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(qmlContext->engine); - QV4::Scope valueScope(engine); - ExecutionContext *global = valueScope.engine->rootContext(); - QV4::Scoped wrapperContext(valueScope, QmlContext::create(global, qmlContext, scopeObject)); - - if (!signalParameters.isEmpty()) { - if (error) { - QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, error); - return 0; - } - runtimeFunction->updateInternalClass(engine, signalParameters); - } - - return QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction); -} - - bool FunctionObject::isBinding() const { return d()->vtable() == QQmlBindingFunction::staticVTable(); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 118caffadb..56e3cb92f7 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -150,8 +150,6 @@ struct Q_QML_EXPORT FunctionObject: Object { static void call(const Managed *that, Scope &scope, CallData *d); static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true); - static Heap::FunctionObject *createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction, - const QList &signalParameters = QList(), QString *error = 0); ReturnedValue protoProperty() const { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index aabdf00f6e..f85680f080 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -86,8 +86,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QQmlScr QV4::ExecutionEngine *v4 = QQmlEnginePrivate::get(b->context()->engine)->v4engine(); if (runtimeFunction) { QV4::Scope scope(v4); - QV4::ScopedFunctionObject f(scope, QV4::FunctionObject::createQmlFunction(ctxtdata, b->scopeObject(), runtimeFunction)); - b->setFunctionObject(f); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(v4->rootContext(), ctxtdata, b->scopeObject())); + b->setupFunction(qmlContext, runtimeFunction); } else { QString code = scriptPrivate->script; b->createQmlBinding(b->context(), b->scopeObject(), code, url, scriptPrivate->lineNumber); diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 974bd3404a..1ae5a76f09 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -120,14 +120,22 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, // It's important to call init first, because m_index gets remapped in case of cloned signals. init(ctxt, scope); - QMetaMethod signal = QMetaObjectPrivate::signal(m_target->metaObject(), m_index); - QString error; QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); + + QList signalParameters = QMetaObjectPrivate::signal(m_target->metaObject(), m_index).parameterNames(); + if (!signalParameters.isEmpty()) { + QString error; + QQmlPropertyCache::signalParameterStringForJS(engine, signalParameters, &error); + if (!error.isEmpty()) { + qmlInfo(scopeObject()) << error; + return; + } + runtimeFunction->updateInternalClass(engine, signalParameters); + } + QV4::Scope valueScope(engine); - QV4::ScopedFunctionObject f(valueScope, QV4::FunctionObject::createQmlFunction(ctxt, scope, runtimeFunction, signal.parameterNames(), &error)); - setFunctionObject(f); - if (!error.isEmpty()) - qmlInfo(scopeObject()) << error; + QV4::Scoped qmlContext(valueScope, QV4::QmlContext::create(engine->rootContext(), ctxt, scope)); + setupFunction(qmlContext, runtimeFunction); } void QQmlBoundSignalExpression::init(QQmlContextData *ctxt, QObject *scope) diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index 2a9d0a7b90..94b1eaab52 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -76,8 +76,8 @@ void QQmlExpressionPrivate::init(QQmlContextData *ctxt, QV4::Function *runtimeFu expressionFunctionValid = true; QV4::ExecutionEngine *engine = QQmlEnginePrivate::getV4Engine(ctxt->engine); QV4::Scope scope(engine); - QV4::ScopedFunctionObject f(scope, QV4::FunctionObject::createQmlFunction(ctxt, me, runtimeFunction)); - setFunctionObject(f); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(engine->rootContext(), ctxt, me)); + setupFunction(qmlContext, runtimeFunction); QQmlJavaScriptExpression::setContext(ctxt); setScopeObject(me); diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index 6930b3973d..3d51269bc9 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -455,9 +455,9 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions() QQmlBinding *newBinding = 0; if (e.id != QQmlBinding::Invalid) { QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions.at(e.id))); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, object())); newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, - function, object(), context); + d->compilationUnit->runtimeFunctions.at(e.id), object(), context, qmlContext); } // QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0; if (!newBinding) diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 91c7cfe305..bc8c192a61 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -128,12 +128,11 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); - QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, compilationUnit->runtimeFunctions[bindingId])); - QQmlProperty property(m_target, name, qmlContext(this)); + QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); + QV4::Scoped qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, m_target)); QQmlBinding *qmlBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, - function, m_target, context); + compilationUnit->runtimeFunctions[bindingId], m_target, context, qmlContext); qmlBinding->setTarget(property); QQmlPropertyPrivate::setBinding(property, qmlBinding); } -- cgit v1.2.3 From 3d582fd5c17b011a606001fe8635e732e4609328 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 13:17:52 +0100 Subject: Add a setSourceLocation() method Change-Id: I611ab4fe5dd59cb8e07b0fa69ce22c7df5a6c3f2 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 9 ++++++++- src/qml/qml/qqmljavascriptexpression_p.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 96a9f5b6b1..a9e309396e 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -142,6 +142,13 @@ QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const return QQmlSourceLocation(); } +void QQmlJavaScriptExpression::setSourceLocation(const QQmlSourceLocation &location) +{ + if (m_sourceLocation) + delete m_sourceLocation; + m_sourceLocation = new QQmlSourceLocation(location); +} + void QQmlJavaScriptExpression::setContext(QQmlContextData *context) { if (m_prevExpression) { @@ -457,7 +464,7 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_v4Function = o->d()->function; if (o->isBinding()) { const QV4::QQmlBindingFunction *b = static_cast(o); - m_sourceLocation = new QQmlSourceLocation(*b->d()->bindingLocation); + setSourceLocation(*b->d()->bindingLocation); m_v4Function = b->d()->originalFunction->function; } Q_ASSERT(m_v4Function); diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 8a230efeeb..4d88c987b8 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -114,6 +114,7 @@ public: inline void setScopeObject(QObject *v); QQmlSourceLocation sourceLocation() const; + void setSourceLocation(const QQmlSourceLocation &location); bool isValid() const { return context() != 0; } -- cgit v1.2.3 From 91ac4a8d099d10fdfd5aa631da02727b7917d85f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 13:28:26 +0100 Subject: Don't store a source location in the QQmlBindingFunction anymore It's not needed anymore as we now store this in the binding directly. Change-Id: I518c83207f219b690f31200e4d17251075bbd322 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 5 ----- src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 +- src/qml/qml/qqmljavascriptexpression.cpp | 1 - src/qml/qml/qqmlvaluetypewrapper.cpp | 2 +- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 6 ++---- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 8 +------- 6 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 0f2a0ebf86..5bbe2d5f9a 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -212,11 +212,6 @@ bool FunctionObject::isBoundFunction() const QQmlSourceLocation FunctionObject::sourceLocation() const { - if (isBinding()) { - Q_ASSERT(as()); - return *static_cast(d())->bindingLocation; - } - return d()->function->sourceLocation(); } diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 235f2fee5a..888983d7c7 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -391,9 +391,9 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP QQmlContextData *callingQmlContext = scope.engine->callingQmlContext(); QV4::Scoped bindingFunction(scope, (const Value &)f); - bindingFunction->initBindingLocation(); newBinding = QQmlBinding::create(property, f, object, callingQmlContext); + newBinding->setSourceLocation(bindingFunction->currentLocation()); newBinding->setTarget(object, *property, nullptr); } } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index a9e309396e..e10b4ef946 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -464,7 +464,6 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_v4Function = o->d()->function; if (o->isBinding()) { const QV4::QQmlBindingFunction *b = static_cast(o); - setSourceLocation(*b->d()->bindingLocation); m_v4Function = b->d()->originalFunction->function; } Q_ASSERT(m_v4Function); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index fe1bd584de..4ce7f67760 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -453,9 +453,9 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) cacheData.setCoreIndex(reference->d()->property); QV4::Scoped bindingFunction(scope, (const Value &)f); - bindingFunction->initBindingLocation(); QQmlBinding *newBinding = QQmlBinding::create(&cacheData, f, reference->d()->object, context); + newBinding->setSourceLocation(bindingFunction->currentLocation()); newBinding->setTarget(reference->d()->object, cacheData, pd); QQmlPropertyPrivate::setBinding(newBinding); return; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 7bab2415c5..aa2b8a24ec 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1304,15 +1304,13 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction) { QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name()); - bindingLocation = new QQmlSourceLocation; this->originalFunction = originalFunction->d(); } -void QQmlBindingFunction::initBindingLocation() +QQmlSourceLocation QQmlBindingFunction::currentLocation() const { QV4::StackFrame frame = engine()->currentStackFrame(); - d()->bindingLocation->sourceFile = frame.source; - d()->bindingLocation->line = frame.line; + return QQmlSourceLocation(frame.source, frame.line, 0); } void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index f84c819e6a..dc2cd04cbe 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -82,13 +82,7 @@ struct ConsoleObject : Object { struct QQmlBindingFunction : FunctionObject { void init(const QV4::FunctionObject *originalFunction); - void destroy() { - delete bindingLocation; - Object::destroy(); - } Pointer originalFunction; - // Set when the binding is created later - QQmlSourceLocation *bindingLocation; }; } @@ -187,7 +181,7 @@ struct QQmlBindingFunction : public QV4::FunctionObject V4_OBJECT2(QQmlBindingFunction, FunctionObject) V4_NEEDS_DESTROY - void initBindingLocation(); // from caller stack trace + QQmlSourceLocation currentLocation() const; // from caller stack trace static void call(const Managed *that, Scope &scope, CallData *callData); -- cgit v1.2.3 From ef90db10a8c943d4684a98035465e92327513130 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:22:04 +0100 Subject: Fix the init() function in Heap::FunctionObject One of the overloads took a QV4::Function * and was so far apparently unused (as it couldn't have worked since change 3b14e2ffdd8eb4b7f7f4508768b75f2acc399370). Fix it since it's getting some use again in the next change. Change-Id: I3eabb332f9e3f2262a5710d43016346b7138f7e7 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 5bbe2d5f9a..93f707392c 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -81,7 +81,8 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto) { Object::init(); - function = nullptr; + this->function = function; + function->compilationUnit->addref(); this->scope = scope->d(); Scope s(scope->engine()); ScopedString name(s, function->name()); -- cgit v1.2.3 From a11be5881a38933d36facfbc4f8baa1becd22546 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:23:09 +0100 Subject: Directly store the referenced QV4::Function pointer in the binding function There's no need to store a pointer to the original function here, we can simplify the code when storing the pointer to the QV4::Function directly. Change-Id: I377aaecf56a0118606713c26cc7da4da001766b1 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 4 ---- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 19 +++---------------- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 6 ------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index e10b4ef946..6383b631cd 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -462,10 +462,6 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_qmlScope.set(o->engine(), o->d()->scope); m_v4Function = o->d()->function; - if (o->isBinding()) { - const QV4::QQmlBindingFunction *b = static_cast(o); - m_v4Function = b->d()->originalFunction->function; - } Q_ASSERT(m_v4Function); m_compilationUnit = m_v4Function->compilationUnit; } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index aa2b8a24ec..19dc100f40 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1303,8 +1303,9 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction) { - QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name()); - this->originalFunction = originalFunction->d(); + Scope scope(originalFunction->engine()); + ScopedContext context(scope, originalFunction->scope()); + FunctionObject::init(context, originalFunction->function()); } QQmlSourceLocation QQmlBindingFunction::currentLocation() const @@ -1313,20 +1314,6 @@ QQmlSourceLocation QQmlBindingFunction::currentLocation() const return QQmlSourceLocation(frame.source, frame.line, 0); } -void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData) -{ - ScopedFunctionObject function(scope, static_cast(that)->d()->originalFunction); - function->call(scope, callData); -} - -void QQmlBindingFunction::markObjects(Heap::Base *that, ExecutionEngine *e) -{ - QQmlBindingFunction::Data *This = static_cast(that); - if (This->originalFunction) - This->originalFunction->mark(e); - QV4::FunctionObject::markObjects(that, e); -} - DEFINE_OBJECT_VTABLE(QQmlBindingFunction); /*! diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index dc2cd04cbe..fe43532647 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -82,7 +82,6 @@ struct ConsoleObject : Object { struct QQmlBindingFunction : FunctionObject { void init(const QV4::FunctionObject *originalFunction); - Pointer originalFunction; }; } @@ -179,13 +178,8 @@ struct Q_QML_PRIVATE_EXPORT GlobalExtensions { struct QQmlBindingFunction : public QV4::FunctionObject { V4_OBJECT2(QQmlBindingFunction, FunctionObject) - V4_NEEDS_DESTROY QQmlSourceLocation currentLocation() const; // from caller stack trace - - static void call(const Managed *that, Scope &scope, CallData *callData); - - static void markObjects(Heap::Base *that, ExecutionEngine *e); }; } -- cgit v1.2.3 From b45ebc6f456cf26912b14bb3809d14d696d9809a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:31:50 +0100 Subject: Avoid passing a FunctionObject to QQmlBinding::create() Like this we can remove the QQmlBinding::create() overload that takes a FunctionObject. Change-Id: Ib6c37395ded325e68cf0fbf3afd08fb6dd6efa3b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 3 ++- src/qml/qml/qqmlbinding.cpp | 19 +++---------------- src/qml/qml/qqmlbinding_p.h | 3 +-- src/qml/qml/qqmljavascriptexpression.cpp | 2 +- src/qml/qml/qqmljavascriptexpression_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 3 ++- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 888983d7c7..5f66b56a42 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -392,7 +392,8 @@ void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, QQmlP QV4::Scoped bindingFunction(scope, (const Value &)f); - newBinding = QQmlBinding::create(property, f, object, callingQmlContext); + QV4::ScopedContext ctx(scope, bindingFunction->scope()); + newBinding = QQmlBinding::create(property, bindingFunction->function(), object, callingQmlContext, ctx); newBinding->setSourceLocation(bindingFunction->currentLocation()); newBinding->setTarget(object, *property, nullptr); } diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index f85680f080..ab6cb60c7b 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -110,21 +110,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QString return b; } -QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, const QV4::FunctionObject *function, QObject *obj, QQmlContextData *ctxt) -{ - QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); - - b->setNotifyOnValueChanged(true); - b->QQmlJavaScriptExpression::setContext(ctxt); - b->setScopeObject(obj); - - b->setFunctionObject(function); - - return b; -} - QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function *function, - QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext) + QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope) { QQmlBinding *b = newBinding(QQmlEnginePrivate::get(ctxt), property); @@ -132,8 +119,8 @@ QQmlBinding *QQmlBinding::create(const QQmlPropertyData *property, QV4::Function b->QQmlJavaScriptExpression::setContext(ctxt); b->setScopeObject(obj); - Q_ASSERT(sharedContext); - b->setupFunction(sharedContext, function); + Q_ASSERT(scope); + b->setupFunction(scope, function); return b; } diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 889f2ad0af..af95bbb5db 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -75,9 +75,8 @@ public: static QQmlBinding *create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *); static QQmlBinding *create(const QQmlPropertyData *, const QString &, QObject *, QQmlContextData *, const QString &url = QString(), quint16 lineNumber = 0); - static QQmlBinding *create(const QQmlPropertyData *, const QV4::FunctionObject *function, QObject *, QQmlContextData *); static QQmlBinding *create(const QQmlPropertyData *property, QV4::Function *function, - QObject *obj, QQmlContextData *ctxt, QV4::QmlContext *sharedContext); + QObject *obj, QQmlContextData *ctxt, QV4::ExecutionContext *scope); ~QQmlBinding(); void setTarget(const QQmlProperty &); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 6383b631cd..c521e0793a 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -466,7 +466,7 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_compilationUnit = m_v4Function->compilationUnit; } -void QQmlJavaScriptExpression::setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f) +void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f) { if (!qmlContext || !f) return; diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 4d88c987b8..8cbaf891a4 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -160,7 +160,7 @@ protected: } void setFunctionObject(const QV4::FunctionObject *o); - void setupFunction(QV4::QmlContext *qmlContext, QV4::Function *f); + void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f); private: friend class QQmlContextData; diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 4ce7f67760..bbef62186a 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -454,7 +454,8 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) QV4::Scoped bindingFunction(scope, (const Value &)f); - QQmlBinding *newBinding = QQmlBinding::create(&cacheData, f, reference->d()->object, context); + QV4::ScopedContext ctx(scope, bindingFunction->scope()); + QQmlBinding *newBinding = QQmlBinding::create(&cacheData, bindingFunction->function(), reference->d()->object, context, ctx); newBinding->setSourceLocation(bindingFunction->currentLocation()); newBinding->setTarget(reference->d()->object, cacheData, pd); QQmlPropertyPrivate::setBinding(newBinding); -- cgit v1.2.3 From 4c901a6fd14d5b7783c058aa7a21015a32cfdc8b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:47:48 +0100 Subject: Pass a QV4::Function to the QQmlBoundSignalExpression constructor And avoid the creation of a temporary FunctionObject Change-Id: Idaacfd978ac4ee26960bdf185272cc44d6618a71 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlboundsignal.cpp | 7 ++++--- src/qml/qml/qqmlboundsignal_p.h | 2 +- src/qml/qml/qqmlobjectcreator.cpp | 3 +-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 1ae5a76f09..2b0b3f8048 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -103,13 +103,14 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, setFunctionObject(f); } -QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, const QV4::Value &function) +QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scopeObject, + QV4::Function *function, QV4::ExecutionContext *scope) : QQmlJavaScriptExpression(), m_index(index), m_target(target) { - setFunctionObject(function.as()); - init(ctxt, scope); + setupFunction(scope, function); + init(ctxt, scopeObject); } QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction) diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h index b9b0c2b481..173c0f7288 100644 --- a/src/qml/qml/qqmlboundsignal_p.h +++ b/src/qml/qml/qqmlboundsignal_p.h @@ -73,7 +73,7 @@ public: const QString ¶meterString = QString()); QQmlBoundSignalExpression(QObject *target, int index, - QQmlContextData *ctxt, QObject *scope, const QV4::Value &function); + QQmlContextData *ctxt, QObject *scopeObject, QV4::Function *function, QV4::ExecutionContext *scope); QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scope, QV4::Function *runtimeFunction); diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index be6a197414..2e2a3fb303 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -795,11 +795,10 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QV4::Scoped qmlContext(scope, currentQmlContext()); if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerExpression) { - QV4::ScopedFunctionObject function(scope, QV4::FunctionObject::createScriptFunction(qmlContext, runtimeFunction, /*createProto*/ false)); int signalIndex = _propertyCache->methodIndexToSignalIndex(property->coreIndex()); QQmlBoundSignal *bs = new QQmlBoundSignal(_bindingTarget, signalIndex, _scopeObject, engine); QQmlBoundSignalExpression *expr = new QQmlBoundSignalExpression(_bindingTarget, signalIndex, - context, _scopeObject, function); + context, _scopeObject, runtimeFunction, qmlContext); bs->takeExpression(expr); } else { -- cgit v1.2.3 From a36677bbcfe7861a18e6ed9e4aa457d41e05a1f2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:47:58 +0100 Subject: Fix coding style Change-Id: I2d6d67273533930aaa9fc61c5f4cdbef2f0bcf53 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlproperty_p.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 2565ec0ce6..53062a2f13 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -115,30 +115,26 @@ public: }; Q_DECLARE_FLAGS(BindingFlags, BindingFlag) - static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None, QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding); + static void setBinding(QQmlAbstractBinding *binding, BindingFlags flags = None, + QQmlPropertyData::WriteFlags writeFlags = QQmlPropertyData::DontRemoveBinding); static void removeBinding(const QQmlProperty &that); static void removeBinding(QObject *o, QQmlPropertyIndex index); static void removeBinding(QQmlAbstractBinding *b); static QQmlAbstractBinding *binding(QObject *, QQmlPropertyIndex index); - static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, - QQmlContextData *); + static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, QQmlContextData *); int signalIndex() const; - static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { - return p.d; - } + static inline QQmlPropertyPrivate *get(const QQmlProperty &p) { return p.d; } // "Public" (to QML) methods static QQmlAbstractBinding *binding(const QQmlProperty &that); static void setBinding(const QQmlProperty &that, QQmlAbstractBinding *); static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that); - static void setSignalExpression(const QQmlProperty &that, - QQmlBoundSignalExpression *); - static void takeSignalExpression(const QQmlProperty &that, - QQmlBoundSignalExpression *); + static void setSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *); + static void takeSignalExpression(const QQmlProperty &that, QQmlBoundSignalExpression *); static bool write(const QQmlProperty &that, const QVariant &, QQmlPropertyData::WriteFlags); static QQmlPropertyIndex propertyIndex(const QQmlProperty &that); static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); -- cgit v1.2.3 From 1ababa4a756dc4cc0ae474b15cccfbfa8727e505 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 15:02:43 +0100 Subject: Get rid of QQmlJavaScriptExpression::setFunctionObject() It was only used in one place now, and the code is actually cleaner when calling setupFunction() instead. Change-Id: Idfe2842b81e765569f2c70f3d5dcd1862442a2ee Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlboundsignal.cpp | 3 ++- src/qml/qml/qqmljavascriptexpression.cpp | 12 ------------ src/qml/qml/qqmljavascriptexpression_p.h | 1 - 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 2b0b3f8048..c4af82133a 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -100,7 +100,8 @@ QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, function += QLatin1String(") { ") + expression + QLatin1String(" })"); QV4::Scope valueScope(v4); QV4::ScopedFunctionObject f(valueScope, evalFunction(context(), scopeObject(), function, fileName, line)); - setFunctionObject(f); + QV4::ScopedContext context(valueScope, f->scope()); + setupFunction(context, f->function()); } QQmlBoundSignalExpression::QQmlBoundSignalExpression(QObject *target, int index, QQmlContextData *ctxt, QObject *scopeObject, diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index c521e0793a..17cccc0bbd 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -454,18 +454,6 @@ void QQmlJavaScriptExpression::createQmlBinding(QQmlContextData *ctxt, QObject * setupFunction(qmlContext, script.vmFunction); } -void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) -{ - if (!o) - return; - - m_qmlScope.set(o->engine(), o->d()->scope); - - m_v4Function = o->d()->function; - Q_ASSERT(m_v4Function); - m_compilationUnit = m_v4Function->compilationUnit; -} - void QQmlJavaScriptExpression::setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f) { if (!qmlContext || !f) diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 8cbaf891a4..0724038382 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -159,7 +159,6 @@ protected: } } - void setFunctionObject(const QV4::FunctionObject *o); void setupFunction(QV4::ExecutionContext *qmlContext, QV4::Function *f); private: -- cgit v1.2.3 From d3bff5843b14a4e0640fb7429b0d8685d5d25b46 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Dec 2016 12:31:57 +0100 Subject: Avoid one additional check when retrieving the Heap object from a Value Change-Id: Ief43d899e47cbfd865458a38aab8c466f6c2c76f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4value_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index e9a5b569a2..e59ab9af0b 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -302,6 +302,7 @@ public: inline bool isUndefined() const { return _val == 0; } inline bool isDouble() const { return (_val >> IsDouble_Shift); } inline bool isManaged() const { return !isUndefined() && ((_val >> IsManagedOrUndefined_Shift) == 0); } + inline bool isManagedOrUndefined() const { return ((_val >> IsManagedOrUndefined_Shift) == 0); } inline bool integerCompatible() const { return (_val >> IsIntegerConvertible_Shift) == 3; @@ -317,6 +318,7 @@ public: inline bool isUndefined() const { return tag() == Managed_Type_Internal && value() == 0; } inline bool isDouble() const { return (tag() & NotDouble_Mask) != NotDouble_Mask; } inline bool isManaged() const { return tag() == Managed_Type_Internal && !isUndefined(); } + inline bool isManagedOrUndefined() const { return tag() == Managed_Type_Internal; } inline bool integerCompatible() const { return (tag() & ConvertibleToInt) == ConvertibleToInt; } static inline bool integerCompatible(Value a, Value b) { return ((a.tag() & b.tag()) & ConvertibleToInt) == ConvertibleToInt; @@ -387,7 +389,7 @@ public: return reinterpret_cast(const_cast(this)); } QML_NEARLY_ALWAYS_INLINE Heap::Base *heapObject() const { - return isManaged() ? m() : nullptr; + return isManagedOrUndefined() ? m() : nullptr; } static inline Value fromHeapObject(Heap::Base *m) @@ -485,15 +487,13 @@ V4_ASSERT_IS_TRIVIAL(Value) inline bool Value::isString() const { - if (!isManaged()) - return false; - return m()->vtable()->isString; + Heap::Base *b = heapObject(); + return b && b->vtable()->isString; } inline bool Value::isObject() const { - if (!isManaged()) - return false; - return m()->vtable()->isObject; + Heap::Base *b = heapObject(); + return b && b->vtable()->isObject; } inline bool Value::isPrimitive() const -- cgit v1.2.3 From 8c322d89ee13f15141f3115dcb5ee9567270ba32 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Dec 2016 14:46:49 +0100 Subject: Some smaller optimizations for indexed property access Saves around 1% of instructions on crypto.js Change-Id: Iccef08b204e6e752d827242baf156efd9a4d58a7 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 55 ++++++++++++++++++++++++----------------- src/qml/jsruntime/qv4value_p.h | 15 +++++++++++ 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 0b0b2685b3..8d322e69d1 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -118,7 +118,8 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs ReturnedValue Lookup::indexedGetterGeneric(Lookup *l, const Value &object, const Value &index) { - if (object.isObject() && index.asArrayIndex() < UINT_MAX) { + uint idx; + if (object.isObject() && index.asArrayIndex(idx)) { l->indexedGetter = indexedGetterObjectInt; return indexedGetterObjectInt(l, object, index); } @@ -129,11 +130,12 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons { Q_UNUSED(l); Scope scope(l->engine); - uint idx = index.asArrayIndex(); + uint idx; + bool isInt = index.asArrayIndex(idx); ScopedObject o(scope, object); if (!o) { - if (idx < UINT_MAX) { + if (isInt) { if (const String *str = object.as()) { if (idx >= (uint)str->toQString().length()) { return Encode::undefined(); @@ -153,7 +155,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons return Encode::undefined(); } - if (idx < UINT_MAX) { + if (isInt) { if (o->d()->arrayData && !o->d()->arrayData->attrs) { ScopedValue v(scope, Scoped(scope, o->arrayData())->get(idx)); if (!v->isEmpty()) @@ -173,14 +175,17 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, const Value &index) { - uint idx = index.asArrayIndex(); - if (idx != UINT_MAX) { - if (Object *o = object.objectValue()) { - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { - Heap::SimpleArrayData *s = o->d()->arrayData.cast(); - if (idx < s->len) - if (!s->data(idx).isEmpty()) - return s->data(idx).asReturnedValue(); + uint idx; + if (index.asArrayIndex(idx)) { + if (Heap::Base *b = object.heapObject()) { + if (b->vtable()->isObject) { + Heap::Object *o = static_cast(b); + if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) { + Heap::SimpleArrayData *s = o->arrayData.cast(); + if (idx < s->len) + if (!s->data(idx).isEmpty()) + return s->data(idx).asReturnedValue(); + } } } } @@ -191,7 +196,8 @@ ReturnedValue Lookup::indexedGetterObjectInt(Lookup *l, const Value &object, con void Lookup::indexedSetterGeneric(Lookup *l, const Value &object, const Value &index, const Value &v) { if (Object *o = object.objectValue()) { - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex() < UINT_MAX) { + uint idx; + if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple && index.asArrayIndex(idx)) { l->indexedSetter = indexedSetterObjectInt; indexedSetterObjectInt(l, object, index, v); return; @@ -207,8 +213,8 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value & if (scope.engine->hasException) return; - uint idx = index.asArrayIndex(); - if (idx < UINT_MAX) { + uint idx; + if (index.asArrayIndex(idx)) { if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { Heap::SimpleArrayData *s = o->d()->arrayData.cast(); if (idx < s->len) { @@ -226,14 +232,17 @@ void Lookup::indexedSetterFallback(Lookup *l, const Value &object, const Value & void Lookup::indexedSetterObjectInt(Lookup *l, const Value &object, const Value &index, const Value &v) { - uint idx = index.asArrayIndex(); - if (idx != UINT_MAX) { - if (Object *o = object.objectValue()) { - if (o->d()->arrayData && o->d()->arrayData->type == Heap::ArrayData::Simple) { - Heap::SimpleArrayData *s = o->d()->arrayData.cast(); - if (idx < s->len) { - s->data(idx) = v; - return; + uint idx; + if (index.asArrayIndex(idx)) { + if (Heap::Base *b = object.heapObject()) { + if (b->vtable()->isObject) { + Heap::Object *o = static_cast(b); + if (o->arrayData && o->arrayData->type == Heap::ArrayData::Simple) { + Heap::SimpleArrayData *s = o->arrayData.cast(); + if (idx < s->len) { + s->data(idx) = v; + return; + } } } } diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index e59ab9af0b..816b8fb11b 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -453,6 +453,7 @@ public: } inline uint asArrayIndex() const; + inline bool asArrayIndex(uint &idx) const; #ifndef V4_BOOTSTRAP uint asArrayLength(bool *ok) const; #endif @@ -531,6 +532,20 @@ inline uint Value::asArrayIndex() const return UINT_MAX; return idx; } + +inline bool Value::asArrayIndex(uint &idx) const +{ + if (!isDouble()) { + if (isInteger() && int_32() >= 0) { + idx = (uint)int_32(); + return true; + } + return false; + } + double d = doubleValue(); + idx = (uint)d; + return (idx == d); +} #endif inline -- cgit v1.2.3 From 4dd13bb4c3b8da79c7ae7f68d930cabff381ead0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Dec 2016 10:47:57 +0100 Subject: Get rid of SimpleScriptFunction Now that the code paths are very similar, we can simply to the check whether to do a fast or slow function call in ScriptFunction::call/contruct. To make this fast, cache the result of the required check in QV4::Function Change-Id: I03085ca2beb83b1721b60b0d7b2ab4c9266d1e48 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4engine.cpp | 8 ++-- src/qml/jsruntime/qv4engine_p.h | 2 +- src/qml/jsruntime/qv4function.cpp | 3 ++ src/qml/jsruntime/qv4function_p.h | 10 +---- src/qml/jsruntime/qv4functionobject.cpp | 80 +++++++-------------------------- src/qml/jsruntime/qv4functionobject_p.h | 22 +++------ 6 files changed, 31 insertions(+), 94 deletions(-) diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 0520bfe216..2b90b43eab 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -281,10 +281,10 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) jsObjects[FunctionProto] = memoryManager->allocObject(functionProtoClass, objectPrototype()); functionClass = emptyClass->addMember(id_prototype(), Attr_NotEnumerable|Attr_NotConfigurable, &index); Q_ASSERT(index == Heap::FunctionObject::Index_Prototype); - simpleScriptFunctionClass = functionClass->addMember(id_name(), Attr_ReadOnly, &index); - Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Name); - simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length(), Attr_ReadOnly, &index); - Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Length); + scriptFunctionClass = functionClass->addMember(id_name(), Attr_ReadOnly, &index); + Q_ASSERT(index == Heap::ScriptFunction::Index_Name); + scriptFunctionClass = scriptFunctionClass->addMember(id_length(), Attr_ReadOnly, &index); + Q_ASSERT(index == Heap::ScriptFunction::Index_Length); protoClass = emptyClass->addMember(id_constructor(), Attr_NotEnumerable, &index); Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor); diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index bf6898001f..1c20ad30aa 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -255,7 +255,7 @@ public: InternalClass *stringClass; InternalClass *functionClass; - InternalClass *simpleScriptFunctionClass; + InternalClass *scriptFunctionClass; InternalClass *protoClass; InternalClass *regExpExecArrayClass; diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index e3f839afd2..358c2d079c 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -84,6 +84,9 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, internalClass = internalClass->addMember(compilationUnit->runtimeStrings[localsIndices[i]]->identifier, Attr_NotConfigurable); activationRequired = compiledFunction->nInnerFunctions > 0 || (compiledFunction->flags & (CompiledData::Function::HasDirectEval | CompiledData::Function::UsesArgumentsObject)); + + canUseSimpleCall = !needsActivation() && !(compiledFunction->flags & CompiledData::Function::HasCatchOrWith) && + !(compiledFunction->nFormals > QV4::Global::ReservedArgumentCount) && !isNamedExpression(); } Function::~Function() diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 802af43cdc..54d0528c42 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -71,6 +71,7 @@ struct Q_QML_EXPORT Function { uint nFormals; bool activationRequired; bool hasQmlDependencies; + bool canUseSimpleCall; Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, ReturnedValue (*codePtr)(ExecutionEngine *, const uchar *)); @@ -91,14 +92,7 @@ struct Q_QML_EXPORT Function { inline bool needsActivation() const { return activationRequired; } - inline bool canUseSimpleFunction() const { - if (needsActivation() || - compiledFunction->flags & CompiledData::Function::HasCatchOrWith || - compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || - isNamedExpression()) - return false; - return true; - } + inline bool canUseSimpleFunction() const { return canUseSimpleCall; } QQmlSourceLocation sourceLocation() const { diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 93f707392c..0c1dc21347 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -194,10 +194,8 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e) Object::markObjects(that, e); } -Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) +Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function) { - if (function->canUseSimpleFunction()) - return scope->d()->engine->memoryManager->allocObject(scope, function, createProto); return scope->d()->engine->memoryManager->allocObject(scope, function); } @@ -421,7 +419,10 @@ void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *call Q_ASSERT(v4Function); ScopedContext c(scope, f->scope()); - c->call(scope, callData, v4Function, f); + if (v4Function->canUseSimpleCall) + c->simpleCall(scope, callData, v4Function); + else + c->call(scope, callData, v4Function, f); if (Q_UNLIKELY(v4->hasException)) { scope.result = Encode::undefined(); @@ -445,12 +446,13 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) Q_ASSERT(v4Function); ScopedContext c(scope, f->scope()); - c->call(scope, callData, v4Function, f); + if (v4Function->canUseSimpleCall) + c->simpleCall(scope, callData, v4Function); + else + c->call(scope, callData, v4Function, f); } -DEFINE_OBJECT_VTABLE(SimpleScriptFunction); - -void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *function, bool createProto) +void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) { FunctionObject::init(); this->scope = scope->d(); @@ -463,16 +465,10 @@ void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *fu Scope s(scope); ScopedFunctionObject f(s, this); - if (createProto) { - ScopedString name(s, function->name()); - f->init(name, createProto); - f->defineReadonlyProperty(scope->d()->engine->id_length(), Primitive::fromInt32(f->formalParameterCount())); - } else { - Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length); - Q_ASSERT(internalClass && internalClass->find(s.engine->id_name()) == Index_Name); - *propertyData(Index_Name) = function->name(); - *propertyData(Index_Length) = Primitive::fromInt32(f->formalParameterCount()); - } + ScopedString name(s, function->name()); + f->init(name, true); + Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()) == Index_Length); + *propertyData(Index_Length) = Primitive::fromInt32(f->formalParameterCount()); if (scope->d()->strictMode) { ScopedProperty pd(s); @@ -483,53 +479,7 @@ void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *fu } } -void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData) -{ - ExecutionEngine *v4 = scope.engine; - if (Q_UNLIKELY(v4->hasException)) { - scope.result = Encode::undefined(); - return; - } - CHECK_STACK_LIMITS(v4, scope); - - Scoped f(scope, static_cast(that)); - - InternalClass *ic = scope.engine->emptyClass; - ScopedObject proto(scope, f->protoForConstructor()); - callData->thisObject = v4->newObject(ic, proto); - - QV4::Function *v4Function = f->function(); - Q_ASSERT(v4Function); - - ScopedContext c(scope, f->scope()); - c->simpleCall(scope, callData, v4Function); - - if (Q_UNLIKELY(v4->hasException)) { - scope.result = Encode::undefined(); - } else if (!scope.result.isObject()) { - scope.result = callData->thisObject; - } -} - -void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) -{ - ExecutionEngine *v4 = scope.engine; - if (v4->hasException) { - scope.result = Encode::undefined(); - return; - } - CHECK_STACK_LIMITS(v4, scope); - - Scoped f(scope, static_cast(that)); - - QV4::Function *v4Function = f->function(); - Q_ASSERT(v4Function); - - ScopedContext c(scope, f->scope()); - c->simpleCall(scope, callData, v4Function); -} - -Heap::Object *SimpleScriptFunction::protoForConstructor() const +Heap::Object *ScriptFunction::protoForConstructor() const { Scope scope(engine()); ScopedObject p(scope, protoProperty()); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 56e3cb92f7..ee11d3c07e 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -105,15 +105,12 @@ struct IndexedBuiltinFunction : FunctionObject { uint index; }; -struct SimpleScriptFunction : FunctionObject { +struct ScriptFunction : FunctionObject { enum { Index_Name = FunctionObject::Index_Prototype + 1, Index_Length }; - void init(QV4::ExecutionContext *scope, Function *function, bool createProto = true); -}; - -struct ScriptFunction : SimpleScriptFunction { + void init(QV4::ExecutionContext *scope, Function *function); }; struct BoundFunction : FunctionObject { @@ -149,7 +146,7 @@ struct Q_QML_EXPORT FunctionObject: Object { static void construct(const Managed *that, Scope &scope, CallData *); static void call(const Managed *that, Scope &scope, CallData *d); - static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true); + static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function); ReturnedValue protoProperty() const { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); } @@ -222,9 +219,9 @@ void Heap::IndexedBuiltinFunction::init(QV4::ExecutionContext *scope, uint index } -struct SimpleScriptFunction: FunctionObject { - V4_OBJECT2(SimpleScriptFunction, FunctionObject) - V4_INTERNALCLASS(simpleScriptFunctionClass) +struct ScriptFunction : FunctionObject { + V4_OBJECT2(ScriptFunction, FunctionObject) + V4_INTERNALCLASS(scriptFunctionClass) static void construct(const Managed *, Scope &scope, CallData *callData); static void call(const Managed *that, Scope &scope, CallData *callData); @@ -232,13 +229,6 @@ struct SimpleScriptFunction: FunctionObject { Heap::Object *protoForConstructor() const; }; -struct ScriptFunction: SimpleScriptFunction { - V4_OBJECT2(ScriptFunction, FunctionObject) - - static void construct(const Managed *, Scope &scope, CallData *callData); - static void call(const Managed *that, Scope &scope, CallData *callData); -}; - struct BoundFunction: FunctionObject { V4_OBJECT2(BoundFunction, FunctionObject) -- cgit v1.2.3 From cf4e4899d268b8a39578fc9713fa3c56ceecdf0b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Dec 2016 11:10:40 +0100 Subject: Clean up the amount of init() methods on FunctionObject Remove some unused ones and simplify the version taking a QString Change-Id: I682b4a06d4da84c2d6be7e4a9a3e831dbd11c9c4 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 47 ++++----------------------------- src/qml/jsruntime/qv4functionobject_p.h | 7 ++--- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 0c1dc21347..18365e1ce6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -92,46 +92,9 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto) { - Object::init(); - function = nullptr; - this->scope = scope->d(); - Scope s(scope->engine()); - ScopedFunctionObject f(s, this); - ScopedString n(s, s.engine->newString(name)); - f->init(n, createProto); -} - -void Heap::FunctionObject::init(ExecutionContext *scope, const QString &name, bool createProto) -{ - Object::init(); - function = nullptr; - this->scope = scope; - Scope s(scope->engine); - ScopedFunctionObject f(s, this); - ScopedString n(s, s.engine->newString(name)); - f->init(n, createProto); -} - -void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const ReturnedValue name) -{ - Object::init(); - function = nullptr; - this->scope = scope->d(); - Scope s(scope); - ScopedFunctionObject f(s, this); - ScopedString n(s, name); - f->init(n, false); -} - -void Heap::FunctionObject::init(ExecutionContext *scope, const ReturnedValue name) -{ - Object::init(); - function = nullptr; - this->scope = scope; - Scope s(scope->engine); - ScopedFunctionObject f(s, this); - ScopedString n(s, name); - f->init(n, false); + Scope valueScope(scope); + ScopedString s(valueScope, valueScope.engine->newString(name)); + init(scope, s, createProto); } void Heap::FunctionObject::init() @@ -166,8 +129,8 @@ void FunctionObject::init(String *n, bool createProto) *propertyData(Heap::FunctionObject::Index_Prototype) = Encode::undefined(); } - ScopedValue v(s, n); - defineReadonlyProperty(s.engine->id_name(), v); + if (n) + defineReadonlyProperty(s.engine->id_name(), *n); } ReturnedValue FunctionObject::name() const diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index ee11d3c07e..c720632153 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -69,12 +69,9 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object { Index_ProtoConstructor = 0 }; - void init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false); + void init(QV4::ExecutionContext *scope, QV4::String *name = 0, bool createProto = false); void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false); - void init(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false); - void init(ExecutionContext *scope, const QString &name = QString(), bool createProto = false); - void init(QV4::ExecutionContext *scope, const ReturnedValue name); - void init(ExecutionContext *scope, const ReturnedValue name); + void init(QV4::ExecutionContext *scope, const QString &name, bool createProto = false); void init(); void destroy(); -- cgit v1.2.3 From 5ac14981b03c9c73c08194b1eb992107a096f774 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 27 Oct 2016 16:11:01 +0200 Subject: Example: Improve the localstorage example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - insert/update/delete instead of only insert - database connection and sql handled in Database.js Change-Id: I513b23061e569f4511dd166ed79898db7f628139 Reviewed-by: Topi Reiniƶ --- .../quick/localstorage/doc/src/localstorage.qdoc | 11 +- .../quick/localstorage/localstorage/Database.js | 97 ++++++++++ .../quick/localstorage/localstorage/Header.qml | 173 +++++++++++++++++ .../quick/localstorage/localstorage/MyButton.qml | 76 ++++++++ .../quick/localstorage/localstorage/MyDelegate.qml | 74 ++++++++ .../quick/localstorage/localstorage/MyModel.qml | 35 ++++ examples/quick/localstorage/localstorage/hello.qml | 78 -------- .../localstorage/localstorage/localstorage.qml | 209 +++++++++++++++++---- .../localstorage/localstorage.qmlproject | 16 -- .../localstorage/localstorage/localstorage.qrc | 8 +- examples/quick/localstorage/localstorage/main.cpp | 65 +++---- .../localstorage/qml-localstorage-example.png | Bin 0 -> 46168 bytes 12 files changed, 669 insertions(+), 173 deletions(-) create mode 100644 examples/quick/localstorage/localstorage/Database.js create mode 100644 examples/quick/localstorage/localstorage/Header.qml create mode 100644 examples/quick/localstorage/localstorage/MyButton.qml create mode 100644 examples/quick/localstorage/localstorage/MyDelegate.qml create mode 100644 examples/quick/localstorage/localstorage/MyModel.qml delete mode 100644 examples/quick/localstorage/localstorage/hello.qml delete mode 100644 examples/quick/localstorage/localstorage/localstorage.qmlproject create mode 100644 examples/quick/localstorage/localstorage/qml-localstorage-example.png diff --git a/examples/quick/localstorage/doc/src/localstorage.qdoc b/examples/quick/localstorage/doc/src/localstorage.qdoc index b52e0afd80..1bfba147e1 100644 --- a/examples/quick/localstorage/doc/src/localstorage.qdoc +++ b/examples/quick/localstorage/doc/src/localstorage.qdoc @@ -35,8 +35,13 @@ \include examples-run.qdocinc - \section1 Hello World + \section1 Activity Tracker - \e {Hello World} demonstrates creating a simple SQL table and doing - insert and select operations. + \e {Activity tracker} allows you to keep track of walks, hikes, or bike trips. + + All database transactions are handled in Database.js. The database is + checked at startup, and created if it does not exist. LocalStorage uses + SQLite, which is a self-contained, serverless, public-domain database. + Opening a connection to the database is handled at the beginning of each + function that manipulates or retrieves data. */ diff --git a/examples/quick/localstorage/localstorage/Database.js b/examples/quick/localstorage/localstorage/Database.js new file mode 100644 index 0000000000..387033795f --- /dev/null +++ b/examples/quick/localstorage/localstorage/Database.js @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +function dbInit() +{ + var db = LocalStorage.openDatabaseSync("Activity_Tracker_DB", "", "Track exercise", 1000000) + try { + db.transaction(function (tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS trip_log (date text,trip_desc text,distance numeric)') + }) + } catch (err) { + console.log("Error creating table in database: " + err) + }; +} + +function dbGetHandle() +{ + try { + var db = LocalStorage.openDatabaseSync("Activity_Tracker_DB", "", + "Track exercise", 1000000) + } catch (err) { + console.log("Error opening database: " + err) + } + return db +} + +function dbInsert(Pdate, Pdesc, Pdistance) +{ + var db = dbGetHandle() + var rowid = 0; + db.transaction(function (tx) { + tx.executeSql('INSERT INTO trip_log VALUES(?, ?, ?)', + [Pdate, Pdesc, Pdistance]) + var result = tx.executeSql('SELECT last_insert_rowid()') + rowid = result.insertId + }) + return rowid; +} + +function dbReadAll() +{ + var db = dbGetHandle() + db.transaction(function (tx) { + var results = tx.executeSql( + 'SELECT rowid,date,trip_desc,distance FROM trip_log order by rowid desc') + for (var i = 0; i < results.rows.length; i++) { + listModel.append({ + id: results.rows.item(i).rowid, + checked: " ", + date: results.rows.item(i).date, + trip_desc: results.rows.item(i).trip_desc, + distance: results.rows.item(i).distance + }) + } + }) +} + +function dbUpdate(Pdate, Pdesc, Pdistance, Prowid) +{ + var db = dbGetHandle() + db.transaction(function (tx) { + tx.executeSql( + 'update trip_log set date=?, trip_desc=?, distance=? where rowid = ?', [Pdate, Pdesc, Pdistance, Prowid]) + }) +} + +function dbDeleteRow(Prowid) +{ + var db = dbGetHandle() + db.transaction(function (tx) { + tx.executeSql('delete from trip_log where rowid = ?', [Prowid]) + }) +} diff --git a/examples/quick/localstorage/localstorage/Header.qml b/examples/quick/localstorage/localstorage/Header.qml new file mode 100644 index 0000000000..e0e465ebc9 --- /dev/null +++ b/examples/quick/localstorage/localstorage/Header.qml @@ -0,0 +1,173 @@ + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.7 +import QtQuick.Window 2.0 +import QtQuick.LocalStorage 2.0 +import "Database.js" as JS +import QtQuick.Layouts 1.1 + +Item { + id: root + width: Screen.width / 2 + height: Screen.height / 7 + + function insertrec() { + var rowid = parseInt(JS.dbInsert(dateInput.text, descInput.text, distInput.text), 10) + if (rowid) { + listView.model.setProperty(listView.currentIndex, "id", rowid) + listView.forceLayout() + } + return rowid; + } + + function editrec(Pdate, Pdesc, Pdistance, Prowid) { + dateInput.text = Pdate + descInput.text = Pdesc + distInput.text = Pdistance + } + + function initrec_new() { + dateInput.text = "" + descInput.text = "" + distInput.text = "" + listView.model.insert(0, { + date: "", + trip_desc: "", + distance: "" + }) + listView.currentIndex = 0 + dateInput.forceActiveFocus() + } + + function initrec() { + dateInput.text = "" + descInput.text = "" + distInput.text = "" + } + + function setlistview() { + listView.model.setProperty(listView.currentIndex, "date", + dateInput.text) + listView.model.setProperty(listView.currentIndex, "trip_desc", + descInput.text) + listView.model.setProperty(listView.currentIndex, "distance", + distInput.text) + } + + Rectangle { + id: rootrect + border.width: 10 + color: "#161616" + + ColumnLayout { + id: mainLayout + anchors.fill: parent + + Rectangle { + id: gridBox + Layout.fillWidth: true + + GridLayout { + id: gridLayout + rows: 3 + flow: GridLayout.TopToBottom + anchors.fill: parent + + Text { + text: "Date" + font.pixelSize: 22 + rightPadding: 10 + } + + Text { + text: "Description" + font.pixelSize: 22 + rightPadding: 10 + } + + Text { + text: "Distance" + font.pixelSize: 22 + } + + TextInput { + id: dateInput + font.pixelSize: 22 + activeFocusOnPress: true + activeFocusOnTab: true + validator: RegExpValidator { + regExp: /[0-9/,:.]+/ + } + onEditingFinished: { + if (dateInput.text == "") { + statustext.text = "Please fill in the date" + dateInput.forceActiveFocus() + } + } + } + + TextInput { + id: descInput + font.pixelSize: 22 + activeFocusOnPress: true + activeFocusOnTab: true + onEditingFinished: { + if (descInput.text.length < 8) { + statustext.text = "Enter a description of minimum 8 characters" + descInput.forceActiveFocus() + } else { + statustext.text = "" + } + } + } + + TextInput { + id: distInput + font.pixelSize: 22 + activeFocusOnPress: true + activeFocusOnTab: true + validator: RegExpValidator { + regExp: /\d{1,3}/ + } + onEditingFinished: { + if (distInput.text == "") { + statustext.text = "Please fill in the distance" + distInput.forceActiveFocus() + } + } + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: dateInput.forceActiveFocus() + } + } + } +} diff --git a/examples/quick/localstorage/localstorage/MyButton.qml b/examples/quick/localstorage/localstorage/MyButton.qml new file mode 100644 index 0000000000..4659b45f64 --- /dev/null +++ b/examples/quick/localstorage/localstorage/MyButton.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: button + + property bool checked: false + property alias text: buttonText.text + + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Button + Accessible.onPressAction: button.clicked() + + signal clicked + + implicitWidth: buttonText.implicitWidth + 20 + implicitHeight: 30 + gradient: Gradient { + GradientStop { + position: 0.0 + color: "grey" + } + GradientStop { + position: 1.0 + color: button.focus ? "red" : "grey" + } + } + + radius: 5 + antialiasing: true + + Text { + id: buttonText + text: parent.description + anchors.centerIn: parent + font.pixelSize: parent.height * .5 + style: enabled ? Text.Sunken : Text.Normal + color: enabled ? "white" : "#555" + styleColor: "black" + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: parent.clicked() + } + + Keys.onSpacePressed: clicked() +} diff --git a/examples/quick/localstorage/localstorage/MyDelegate.qml b/examples/quick/localstorage/localstorage/MyDelegate.qml new file mode 100644 index 0000000000..9a4ac1cc46 --- /dev/null +++ b/examples/quick/localstorage/localstorage/MyDelegate.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 +import QtQuick.Layouts 1.1 +import "Database.js" as JS + +Item { + width: parent.width + height: rDate.implicitHeight + + Rectangle { + id: baseRec + anchors.fill: parent + opacity: 0.8 + color: index % 2 ? "lightgrey" : "grey" + + MouseArea { + anchors.fill: parent + onClicked: listView.currentIndex = index + } + GridLayout { + anchors.fill:parent + columns: 3 + + Text { + id: rDate + text: date + font.pixelSize: 22 + Layout.preferredWidth: parent.width / 4 + color: "black" + } + Text { + id: rDesc + text: trip_desc + Layout.fillWidth: true + font.pixelSize: 22 + color: "black" + } + Text { + id: rDistance + text: distance + font.pixelSize: 22 + Layout.alignment: Qt.AlignRight + color: "black" + } + } + } +} diff --git a/examples/quick/localstorage/localstorage/MyModel.qml b/examples/quick/localstorage/localstorage/MyModel.qml new file mode 100644 index 0000000000..0677ec74d6 --- /dev/null +++ b/examples/quick/localstorage/localstorage/MyModel.qml @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 +import "Database.js" as JS + +ListModel { + id: listModel + Component.onCompleted: JS.dbReadAll() +} diff --git a/examples/quick/localstorage/localstorage/hello.qml b/examples/quick/localstorage/localstorage/hello.qml deleted file mode 100644 index d4f82ba2fe..0000000000 --- a/examples/quick/localstorage/localstorage/hello.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 - -Rectangle { - width: 200 - height: 100 - - Text { - text: "?" - anchors.horizontalCenter: parent.horizontalCenter - - function findGreetings() { - var db = LocalStorage.openDatabaseSync("QQmlExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() - } -} -//![0] diff --git a/examples/quick/localstorage/localstorage/localstorage.qml b/examples/quick/localstorage/localstorage/localstorage.qml index 61e9eff8b6..b85fad4764 100644 --- a/examples/quick/localstorage/localstorage/localstorage.qml +++ b/examples/quick/localstorage/localstorage/localstorage.qml @@ -1,54 +1,183 @@ - /**************************************************************************** +/**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. +** This file is part of the documentation of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.0 -import "../../shared" as Examples +import QtQuick 2.5 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.LocalStorage 2.0 +import "Database.js" as JS + +Window { + visible: true + width: Screen.width / 2 + height: Screen.height / 1.8 + color: "#161616" -Item { - height: 480 - width: 320 - Examples.LauncherList { - id: ll + property bool creatingNewEntry: false + property bool editingEntry: false + + Rectangle { anchors.fill: parent - Component.onCompleted: { - addExample("Hello World", "Simple SQL operations with local storage API", Qt.resolvedUrl("hello.qml")); + + ColumnLayout { + anchors.fill: parent + + Header { + id: input + Layout.fillWidth: true + } + RowLayout { + MyButton { + text: "New" + onClicked: { + input.initrec_new() + creatingNewEntry = true + listView.model.setProperty(listView.currentIndex, "id", 0) + } + } + MyButton { + id: saveButton + enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1 + text: "Save" + onClicked: { + var insertedRow = false; + if (listView.model.get(listView.currentIndex).id < 1) { + //insert mode + if (input.insertrec()) { + // Successfully inserted a row. + input.setlistview() + insertedRow = true + } else { + // Failed to insert a row; display an error message. + statustext.text = "Failed to insert row" + } + } else { + // edit mode + input.setlistview() + JS.dbUpdate(listView.model.get(listView.currentIndex).date, + listView.model.get(listView.currentIndex).trip_desc, + listView.model.get(listView.currentIndex).distance, + listView.model.get(listView.currentIndex).id) + } + + if (insertedRow) { + input.initrec() + creatingNewEntry = false + editingEntry = false + listView.forceLayout() + } + } + } + MyButton { + id: editButton + text: "Edit" + enabled: !creatingNewEntry && !editingEntry && listView.currentIndex != -1 + onClicked: { + input.editrec(listView.model.get(listView.currentIndex).date, + listView.model.get(listView.currentIndex).trip_desc, + listView.model.get(listView.currentIndex).distance, + listView.model.get(listView.currentIndex).id) + + editingEntry = true + } + } + MyButton { + id: deleteButton + text: "Delete" + enabled: !creatingNewEntry && listView.currentIndex != -1 + onClicked: { + JS.dbDeleteRow(listView.model.get(listView.currentIndex).id) + listView.model.remove(listView.currentIndex, 1) + if (listView.count == 0) { + // ListView doesn't automatically set its currentIndex to -1 + // when the count becomes 0. + listView.currentIndex = -1 + } + } + } + MyButton { + id: cancelButton + text: "Cancel" + enabled: (creatingNewEntry || editingEntry) && listView.currentIndex != -1 + onClicked: { + if (listView.model.get(listView.currentIndex).id === 0) { + // This entry had an id of 0, which means it was being created and hadn't + // been saved to the database yet, so we can safely remove it from the model. + listView.model.remove(listView.currentIndex, 1) + } + listView.forceLayout() + creatingNewEntry = false + editingEntry = false + input.initrec() + } + } + MyButton { + text: "Exit" + onClicked: Qt.quit() + } + } + Component { + id: highlightBar + Rectangle { + width: listView.currentItem.width + height: listView.currentItem.height + color: "lightgreen" + } + } + ListView { + id: listView + Layout.fillWidth: true + Layout.fillHeight: true + model: MyModel {} + delegate: MyDelegate {} + // Don't allow changing the currentIndex while the user is creating/editing values. + enabled: !creatingNewEntry && !editingEntry + + highlight: highlightBar + highlightFollowsCurrentItem: true + focus: true + + header: Component { + Text { + text: "Saved activities" + } + } + } + Text { + id: statustext + color: "red" + Layout.fillWidth: true + font.bold: true + font.pointSize: 20 + + } } } + Component.onCompleted: { + JS.dbInit() + } } diff --git a/examples/quick/localstorage/localstorage/localstorage.qmlproject b/examples/quick/localstorage/localstorage/localstorage.qmlproject deleted file mode 100644 index 6835d23503..0000000000 --- a/examples/quick/localstorage/localstorage/localstorage.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.0 - -Project { - mainFile: "localstorage.qml" - /* Include .qml, .js, and image files from current directory and subdirectories */ - - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} \ No newline at end of file diff --git a/examples/quick/localstorage/localstorage/localstorage.qrc b/examples/quick/localstorage/localstorage/localstorage.qrc index 09ac2de033..079438be2b 100644 --- a/examples/quick/localstorage/localstorage/localstorage.qrc +++ b/examples/quick/localstorage/localstorage/localstorage.qrc @@ -1,6 +1,10 @@ - - hello.qml + + Header.qml + Database.js + MyModel.qml + MyButton.qml + MyDelegate.qml localstorage.qml diff --git a/examples/quick/localstorage/localstorage/main.cpp b/examples/quick/localstorage/localstorage/main.cpp index 6e522753e9..9f8adbb7a5 100644 --- a/examples/quick/localstorage/localstorage/main.cpp +++ b/examples/quick/localstorage/localstorage/main.cpp @@ -1,41 +1,38 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(localstorage/localstorage/localstorage) +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/localstorage.qml"))); + + return app.exec(); +} diff --git a/examples/quick/localstorage/localstorage/qml-localstorage-example.png b/examples/quick/localstorage/localstorage/qml-localstorage-example.png new file mode 100644 index 0000000000..7d7edafe63 Binary files /dev/null and b/examples/quick/localstorage/localstorage/qml-localstorage-example.png differ -- cgit v1.2.3 From f893d66382549b4d1285ae98b66a1fdd4719036a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 12 Dec 2016 12:59:28 +0100 Subject: Initialize idx in QV4::Lookup::indexedGetterFallback() Change-Id: If7fe6635155937fa3e8c94ac081a267d96563859 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4lookup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 8d322e69d1..52ed449664 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -130,7 +130,7 @@ ReturnedValue Lookup::indexedGetterFallback(Lookup *l, const Value &object, cons { Q_UNUSED(l); Scope scope(l->engine); - uint idx; + uint idx = 0; bool isInt = index.asArrayIndex(idx); ScopedObject o(scope, object); -- cgit v1.2.3 From 612ad6b08db2d96f6adad26c6b04d56b3bd01271 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Dec 2016 09:26:36 +0100 Subject: Optimize Arguments Object Avoid creation of the Array in most cases. Fix FunctionObject::method_apply so that it correctly recognizes this case and does the right thing. Add a getLength() method to ArgumentsObject to speed up the lookup of that property. Improves the RayTrace benchmark by around 15%. Change-Id: I53eb34a1f9515e59a191ee6f0eb23a3f4c6882d1 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4argumentsobject.cpp | 10 ++++++++-- src/qml/jsruntime/qv4argumentsobject_p.h | 2 ++ src/qml/jsruntime/qv4functionobject.cpp | 9 ++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 74fcd30632..5a190d6690 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -57,8 +57,6 @@ void Heap::ArgumentsObject::init(QV4::CallContext *context) Scope scope(v4); Scoped args(scope, this); - args->setArrayType(Heap::ArrayData::Complex); - if (context->d()->strictMode) { Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee())); Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller())); @@ -246,3 +244,11 @@ void ArgumentsObject::markObjects(Heap::Base *that, ExecutionEngine *e) Object::markObjects(that, e); } + +uint ArgumentsObject::getLength(const Managed *m) +{ + const ArgumentsObject *a = static_cast(m); + if (a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->isInteger()) + return a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->integerValue(); + return Primitive::toUInt32(a->propertyData(Heap::ArgumentsObject::LengthPropertyIndex)->doubleValue()); +} diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index 37a8d0a94a..0a2ea3b42a 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -132,8 +132,10 @@ struct ArgumentsObject: Object { static bool deleteIndexedProperty(Managed *m, uint index); static PropertyAttributes queryIndexed(const Managed *m, uint index); static void markObjects(Heap::Base *that, ExecutionEngine *e); + static uint getLength(const Managed *m); void fullyCreate(); + }; } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 18365e1ce6..2da05f6217 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -47,6 +47,7 @@ #include "qv4arrayobject_p.h" #include "qv4scopedvalue_p.h" +#include "qv4argumentsobject_p.h" #include #include @@ -301,7 +302,13 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) ScopedCallData callData(scope, len); if (len) { - if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) { + if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast()->fullyCreated()) { + QV4::ArgumentsObject *a = arr->cast(); + int l = qMin(len, (uint)a->d()->context->callData->argc); + memcpy(callData->args, a->d()->context->callData->args, l*sizeof(Value)); + for (quint32 i = l; i < len; ++i) + callData->args[i] = Primitive::undefinedValue(); + } else if (arr->arrayType() == Heap::ArrayData::Simple && !arr->protoHasArray()) { auto sad = static_cast(arr->arrayData()); uint alen = sad ? sad->len : 0; if (alen > len) -- cgit v1.2.3 From cf960d2ce277798e1d4f372c6187405fffeaee76 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Dec 2016 09:38:13 +0100 Subject: Streamline code allocating MemberData Saves around 1% in the Splay benchmark. Change-Id: I32c8807d6688351beea2a34d945e8ef87b31355f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4memberdata.cpp | 30 ++++++++---------------------- src/qml/jsruntime/qv4memberdata_p.h | 3 +-- src/qml/jsruntime/qv4object.cpp | 11 +++-------- src/qml/jsruntime/qv4object_p.h | 2 -- 4 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/qml/jsruntime/qv4memberdata.cpp b/src/qml/jsruntime/qv4memberdata.cpp index 5646a44891..d5f75415cc 100644 --- a/src/qml/jsruntime/qv4memberdata.cpp +++ b/src/qml/jsruntime/qv4memberdata.cpp @@ -52,30 +52,16 @@ void MemberData::markObjects(Heap::Base *that, ExecutionEngine *e) m->data[i].mark(e); } -static Heap::MemberData *reallocateHelper(ExecutionEngine *e, Heap::MemberData *old, uint n) +Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n, Heap::MemberData *old) { + Q_ASSERT(!old || old->size < n); + uint alloc = sizeof(Heap::MemberData) + (n)*sizeof(Value); - Scope scope(e); - Scoped newMemberData(scope, e->memoryManager->allocManaged(alloc)); + Heap::MemberData *m = e->memoryManager->allocManaged(alloc); if (old) - memcpy(newMemberData->d_unchecked(), old, sizeof(Heap::MemberData) + old->size * sizeof(Value)); + memcpy(m, old, sizeof(Heap::MemberData) + old->size * sizeof(Value)); else - newMemberData->d_unchecked()->init(); - newMemberData->d()->size = n; - return newMemberData->d(); -} - -Heap::MemberData *MemberData::allocate(ExecutionEngine *e, uint n) -{ - return reallocateHelper(e, 0, n); -} - -Heap::MemberData *MemberData::reallocate(ExecutionEngine *e, Heap::MemberData *old, uint n) -{ - uint s = old ? old->size : 0; - if (n < s) - return old; - - // n is multiplied by two to leave room for growth - return reallocateHelper(e, old, qMax((uint)4, 2*n)); + m->init(); + m->size = n; + return m; } diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h index 969eee3619..5c89dfe8ec 100644 --- a/src/qml/jsruntime/qv4memberdata_p.h +++ b/src/qml/jsruntime/qv4memberdata_p.h @@ -79,8 +79,7 @@ struct MemberData : Managed Value *data() { return d()->data; } inline uint size() const { return d()->size; } - static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n); - static Heap::MemberData *reallocate(QV4::ExecutionEngine *e, Heap::MemberData *old, uint n); + static Heap::MemberData *allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old = 0); static void markObjects(Heap::Base *that, ExecutionEngine *e); }; diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 00e6d230da..8acca16dd0 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -61,7 +61,9 @@ DEFINE_OBJECT_VTABLE(Object); void Object::setInternalClass(InternalClass *ic) { d()->internalClass = ic; - ensureMemberData(); + if ((ic->size > d()->inlineMemberSize && !d()->memberData) || + (d()->memberData && d()->memberData->size < ic->size - d()->inlineMemberSize)) + d()->memberData = MemberData::allocate(ic->engine, ic->size - d()->inlineMemberSize, d()->memberData); } void Object::getProperty(uint index, Property *p, PropertyAttributes *attrs) const @@ -225,13 +227,6 @@ void Object::markObjects(Heap::Base *that, ExecutionEngine *e) o->prototype->mark(e); } -void Object::ensureMemberData() -{ - QV4::InternalClass *ic = internalClass(); - if (ic->size > d()->inlineMemberSize) - d()->memberData = MemberData::reallocate(ic->engine, d()->memberData, ic->size - d()->inlineMemberSize); -} - void Object::insertMember(String *s, const Property *p, PropertyAttributes attributes) { uint idx; diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 91d9f03ad1..6c679deb10 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -367,8 +367,6 @@ protected: static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static uint getLength(const Managed *m); - void ensureMemberData(); - private: ReturnedValue internalGet(String *name, bool *hasProperty) const; ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const; -- cgit v1.2.3 From 4ccba8ea25312e0b635df21ce3fea7624744ee34 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Dec 2016 10:48:32 +0100 Subject: Micro optimization Avoid checking whether the object is a Managed if we already know that. Change-Id: I78234b47269d3eb1a322fdafe7654f91dae7545a Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4managed_p.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 86caac3ebe..5c764e7ff0 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -211,6 +211,13 @@ public: return m(); } + template inline T *cast() { + return static_cast(this); + } + template inline const T *cast() const { + return static_cast(this); + } + private: friend class MemoryManager; friend struct Identifiers; -- cgit v1.2.3 From 180decaf11ea6fb1147825a78a95c455400f7c7e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Dec 2016 10:49:55 +0100 Subject: Optimize code in instanceOf() of FunctionObject::protoForConstructor() Saves around 1.5% instructions for the Earley Boyer benchmark Change-Id: I552d324d5e1713f655ab9909f30c9527bb4ff777 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 9 ++++----- src/qml/jsruntime/qv4functionobject_p.h | 4 ++-- src/qml/jsruntime/qv4runtime.cpp | 21 +++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 2da05f6217..64f7b98618 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -451,11 +451,10 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function Heap::Object *ScriptFunction::protoForConstructor() const { - Scope scope(engine()); - ScopedObject p(scope, protoProperty()); - if (p) - return p->d(); - return scope.engine->objectPrototype()->d(); + const Object *o = d()->protoProperty(); + if (o) + return o->d(); + return engine()->objectPrototype()->d(); } diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index c720632153..a02e89e883 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -79,6 +79,8 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object { unsigned int varCount() { return function ? function->compiledFunction->nLocals : 0; } bool needsActivation() const { return function ? function->needsActivation() : false; } + const QV4::Object *protoProperty() const { return propertyData(Index_Prototype)->cast(); } + Pointer scope; Function *function; }; @@ -145,8 +147,6 @@ struct Q_QML_EXPORT FunctionObject: Object { static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function); - ReturnedValue protoProperty() const { return propertyData(Heap::FunctionObject::Index_Prototype)->asReturnedValue(); } - bool needsActivation() const { return d()->needsActivation(); } bool strictMode() const { return d()->function ? d()->function->isStrict() : false; } bool isBinding() const; diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index b71bd4146a..57ad181030 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -345,28 +345,29 @@ ReturnedValue Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex) QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Value &left, const Value &right) { - Scope scope(engine); - ScopedFunctionObject f(scope, right.as()); - if (!f) + const FunctionObject *function = right.as(); + if (!function) return engine->throwTypeError(); - if (f->isBoundFunction()) - f = static_cast(f.getPointer())->target(); + Heap::FunctionObject *f = function->d(); + if (function->isBoundFunction()) + f = function->cast()->target(); - ScopedObject v(scope, left.as()); - if (!v) + const Object *o = left.as(); + if (!o) return Encode(false); + Heap::Object *v = o->d(); - ScopedObject o(scope, f->protoProperty()); + o = f->protoProperty(); if (!o) return engine->throwTypeError(); while (v) { - v = v->prototype(); + v = v->prototype; if (!v) break; - else if (o->d() == v->d()) + else if (o->d() == v) return Encode(true); } -- cgit v1.2.3 From 798b3e6fa65f0a35e22c446ea8582803f6ecf4d2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 12 Dec 2016 12:34:56 +0100 Subject: Minor optimization Use the pre-computed hasQmlDependencies boolean in QV4::Function instead of checking three integers. Change-Id: Ib7194ccf9e9eb58b0d3c692388adc0cfa4cd3891 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index df0ecdd5d3..544d39339b 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -343,7 +343,7 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio scope.result = Q_V4_PROFILE(scope.engine, function); - if (function->compiledFunction->hasQmlDependencies()) + if (function->hasQmlDependencies) QQmlPropertyCapture::registerQmlDependencies(function->compiledFunction, scope); } -- cgit v1.2.3 From 97e4d5d5aeb0d415db18c075f905763ae5ba5f18 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 7 Dec 2016 16:22:55 +0100 Subject: Accept PUA characters, ZWNJ and ZWJ as input in TextInput/Edit Private Use Area characters are quite valid input characters when used in combination with a custom font. Joiners also serve an important language purpose in semitic writing systems. [ChangeLog][QtWidgets][Input] Support characters in Private Use Area, as well as zero-width joiners and zero-width non-joiners in input in TextInput and TextEdit. Task-number: QTBUG-42074 Task-number: QTBUG-57003 Change-Id: I4a9d6b9ea172d29375c20abfb7aebb6748c5d300 Reviewed-by: Lars Knoll Reviewed-by: Konstantin Ritt --- src/quick/items/qquicktextcontrol.cpp | 7 +++---- src/quick/items/qquicktextcontrol_p.h | 3 ++- src/quick/items/qquicktextinput.cpp | 8 +++++--- src/quick/items/qquicktextinput_p_p.h | 2 ++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 887cc6fea7..66936b0943 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -608,7 +608,7 @@ void QQuickTextControl::clear() } QQuickTextControl::QQuickTextControl(QTextDocument *doc, QObject *parent) - : QObject(*new QQuickTextControlPrivate, parent) + : QInputControl(TextEdit, *new QQuickTextControlPrivate, parent) { Q_D(QQuickTextControl); Q_ASSERT(doc); @@ -980,8 +980,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) process: { - QString text = e->text(); - if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) { + if (q->isAcceptableInput(e)) { if (overwriteMode // no need to call deleteChar() if we have a selection, insertText // does it already @@ -990,7 +989,7 @@ process: cursor.deleteChar(); } - cursor.insertText(text); + cursor.insertText(e->text()); selectionChanged(); } else { e->ignore(); diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h index 7992d2943b..9bc5d057c7 100644 --- a/src/quick/items/qquicktextcontrol_p.h +++ b/src/quick/items/qquicktextcontrol_p.h @@ -59,6 +59,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -71,7 +72,7 @@ class QAbstractScrollArea; class QEvent; class QTimerEvent; -class Q_AUTOTEST_EXPORT QQuickTextControl : public QObject +class Q_AUTOTEST_EXPORT QQuickTextControl : public QInputControl { Q_OBJECT Q_DECLARE_PRIVATE(QQuickTextControl) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 96a46df2f4..b3c7da1e3e 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -63,6 +63,7 @@ #endif #include +#include QT_BEGIN_NAMESPACE @@ -2695,6 +2696,8 @@ void QQuickTextInputPrivate::init() option.setUseDesignMetrics(renderType != QQuickTextInput::NativeRendering); m_textLayout.setTextOption(option); } + + m_inputControl = new QInputControl(QInputControl::LineEdit, q); } void QQuickTextInputPrivate::resetInputMethod() @@ -4528,8 +4531,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) } if (unknown && !m_readOnly) { - QString t = event->text(); - if (!t.isEmpty() && t.at(0).isPrint()) { + if (m_inputControl->isAcceptableInput(event)) { if (overwriteMode // no need to call del() if we have a selection, insert // does it already @@ -4538,7 +4540,7 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event) del(); } - insert(t); + insert(event->text()); event->accept(); return; } diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index d1aaefa6a7..0bf5779a53 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE class QQuickTextNode; +class QInputControl; class Q_QUICK_PRIVATE_EXPORT QQuickTextInputPrivate : public QQuickImplicitSizeItemPrivate { @@ -228,6 +229,7 @@ public: QQuickItem *cursorItem; QQuickTextNode *textNode; MaskInputData *m_maskData; + QInputControl *m_inputControl; QList m_transactions; QVector m_history; -- cgit v1.2.3 From 16c81bb0d493af00bc376784bcb7e03a4a037b04 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 13 Dec 2016 12:55:40 +0100 Subject: Example: correction initialization fields Header.qml Error msg: Can't assign to existing role 'distance' of different type [String -> Number] Change-Id: I28842ed25a56077e52496a229294ef992406ca1d Reviewed-by: Mitch Curtis --- examples/quick/localstorage/localstorage/Header.qml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/quick/localstorage/localstorage/Header.qml b/examples/quick/localstorage/localstorage/Header.qml index e0e465ebc9..a08645a170 100644 --- a/examples/quick/localstorage/localstorage/Header.qml +++ b/examples/quick/localstorage/localstorage/Header.qml @@ -52,22 +52,22 @@ Item { } function initrec_new() { - dateInput.text = "" - descInput.text = "" - distInput.text = "" + dateInput.clear() + descInput.clear() + distInput.clear() listView.model.insert(0, { date: "", trip_desc: "", - distance: "" + distance: 0 }) listView.currentIndex = 0 dateInput.forceActiveFocus() } function initrec() { - dateInput.text = "" - descInput.text = "" - distInput.text = "" + dateInput.clear() + descInput.clear() + distInput.clear() } function setlistview() { @@ -76,7 +76,7 @@ Item { listView.model.setProperty(listView.currentIndex, "trip_desc", descInput.text) listView.model.setProperty(listView.currentIndex, "distance", - distInput.text) + parseInt(distInput.text,10)) } Rectangle { -- cgit v1.2.3