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 d236661940b09194cc6a864ffbe687569922787e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:35:57 +0100 Subject: Fix qrc test Make this test pass when we have the time stamp available in the qrc data (since commit d20773824529d191e7b483b505107dce6c1b1c3d in qtbase) or when not (when the engine falls back to the program executable). Change-Id: Idb9a6951d76515a2482d573b40da99871bc442cd Reviewed-by: Lars Knoll --- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index e2c0055ea1..f8698f0afa 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -563,7 +563,11 @@ void tst_qmldiskcache::cacheResources() QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast(&unit), sizeof(unit)) == sizeof(unit)); - QCOMPARE(qint64(unit.sourceTimeStamp), QFileInfo(QCoreApplication::applicationFilePath()).lastModified().toMSecsSinceEpoch()); + + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); + if (!referenceTimeStamp.isValid()) + referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); + QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); } } -- 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 eb7ec4fb9492b51d8371d8689b9538d6d22d13fd Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 15:53:07 +0100 Subject: Fix handling of qrc:/// urls with disk caching Use the right function for converting a qrc:/// url to a local path. QUrl::toLocalFile() gives us an empty path, which prevents us from getting a time stamp and comparing it against the stamp in the cache file. This fixes disk caching with samegame. Change-Id: Id3eb270f1f7a7f25143d2f075a45f32bdb0384c5 Reviewed-by: Lars Knoll --- src/qml/compiler/qv4compileddata.cpp | 2 +- tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index e815c41a86..f8668b48e4 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -397,7 +397,7 @@ bool CompilationUnit::loadFromDisk(const QUrl &url, EvalISelFactory *iselFactory return false; } - const QString sourcePath = url.toLocalFile(); + const QString sourcePath = QQmlFile::urlToLocalFileOrQrc(url); QScopedPointer cacheFile(new CompilationUnitMapper()); CompiledData::Unit *mappedUnit = cacheFile->open(cacheFilePath(url), sourcePath, errorString); diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp index f8698f0afa..8af446173d 100644 --- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp +++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp @@ -549,7 +549,6 @@ void tst_qmldiskcache::cacheResources() { CleanlyLoadingComponent component(&engine, QUrl("qrc:/test.qml")); - qDebug() << component.errorString(); QScopedPointer obj(component.create()); QVERIFY(!obj.isNull()); QCOMPARE(obj->property("value").toInt(), 20); @@ -558,17 +557,37 @@ void tst_qmldiskcache::cacheResources() const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); QCOMPARE(entries.count(), 1); + QDateTime cacheFileTimeStamp; + { QFile cacheFile(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()); QVERIFY2(cacheFile.open(QIODevice::ReadOnly), qPrintable(cacheFile.errorString())); QV4::CompiledData::Unit unit; QVERIFY(cacheFile.read(reinterpret_cast(&unit), sizeof(unit)) == sizeof(unit)); + cacheFileTimeStamp = QFileInfo(cacheFile.fileName()).lastModified(); + QDateTime referenceTimeStamp = QFileInfo(":/test.qml").lastModified(); if (!referenceTimeStamp.isValid()) referenceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified(); QCOMPARE(qint64(unit.sourceTimeStamp), referenceTimeStamp.toMSecsSinceEpoch()); } + + waitForFileSystem(); + + { + CleanlyLoadingComponent component(&engine, QUrl("qrc:///test.qml")); + QScopedPointer obj(component.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("value").toInt(), 20); + } + + { + const QStringList entries = QDir(qmlCacheDirectory).entryList(QDir::NoDotAndDotDot | QDir::Files); + QCOMPARE(entries.count(), 1); + + QCOMPARE(QFileInfo(qmlCacheDirectory + QLatin1Char('/') + entries.constFirst()).lastModified().toMSecsSinceEpoch(), cacheFileTimeStamp.toMSecsSinceEpoch()); + } } void tst_qmldiskcache::stableOrderOfDependentCompositeTypes() -- cgit v1.2.3 From d274cff81027983de6cac3553bed38e712976210 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 22 Nov 2016 16:49:06 +0100 Subject: Fix up QML grammar file Commit 45bd04ba73bd3e71c070e5724535ba87f6771323 changed the embedded license headers to the $LGPL tag but accidentally removed the header that is embedded in the output. In addition there have been changes to the generated code that were not reflected in the .g file. With these changes the qlalr output matches the files that are checked in. Change-Id: I693e20cf5237098425ba79182089d213179e6dfa Reviewed-by: Lars Knoll --- src/qml/parser/qqmljs.g | 85 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index 161c8ffcde..a562ecdfa5 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -5,27 +5,33 @@ -- -- This file is part of the QtQml module of the Qt Toolkit. -- --- $QT_BEGIN_LICENSE:LGPL21$ +-- $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 http://www.qt.io/terms-conditions. For further --- information use the contact form at http://www.qt.io/contact-us. +-- 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 2.1 or version 3 as published by the Free --- Software Foundation and appearing in the file LICENSE.LGPLv21 and --- LICENSE.LGPLv3 included in the packaging of this file. Please review the --- following information to ensure the GNU Lesser General Public License --- requirements will be met: https://www.gnu.org/licenses/lgpl.html and --- http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +-- 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. -- --- As a special exception, The Qt Company gives you certain additional --- rights. These rights are described in The Qt Company LGPL Exception --- version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +-- 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$ -- @@ -136,6 +142,57 @@ ** ****************************************************************************/ +#include "qqmljsengine_p.h" +#include "qqmljslexer_p.h" +#include "qqmljsast_p.h" +#include "qqmljsmemorypool_p.h" + +#include +#include + +#include + +./ + +/:/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + // // W A R N I N G @@ -273,7 +330,7 @@ public: inline DiagnosticMessage diagnosticMessage() const { - foreach (const DiagnosticMessage &d, diagnostic_messages) { + for (const DiagnosticMessage &d : diagnostic_messages) { if (d.kind != DiagnosticMessage::Warning) return d; } @@ -3003,7 +3060,7 @@ PropertyAssignmentListOpt: PropertyAssignmentList ; yylloc.startColumn += yylloc.length; yylloc.length = 0; - //const QString msg = qApp->translate("QQmlParser", "Missing `;'"); + //const QString msg = QCoreApplication::translate("QQmlParser", "Missing `;'"); //diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, yylloc, msg)); first_token = &token_buffer[0]; -- cgit v1.2.3 From 7b7fb7fe3ab8ce5db744329b2f138fd8b2a811ea Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Nov 2016 09:47:48 +0100 Subject: Fix support for QML declared default list properties The grammar was not permitting to write default property list myChildren; and instead developers had to work around it with an alias property list myChildrenData; default property alias myChildren: myChildrenData which is not nice. Fortunately this is easy to fix in the grammar. Task-number: QTBUG-10822 Change-Id: I4e914ddb9588913da09e9fb6c6aa154cf8a9e18f Reviewed-by: Lars Knoll --- src/qml/parser/qqmljs.g | 17 + src/qml/parser/qqmljsgrammar.cpp | 1781 ++++++++++---------- src/qml/parser/qqmljsgrammar_p.h | 12 +- src/qml/parser/qqmljsparser.cpp | 389 ++--- src/qml/parser/qqmljsparser_p.h | 4 +- .../qml/qqmllanguage/data/QtObjectWithChildren.qml | 5 + .../qml/qqmllanguage/data/defaultListProperty.qml | 6 + tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 9 + 8 files changed, 1150 insertions(+), 1073 deletions(-) create mode 100644 tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml create mode 100644 tests/auto/qml/qqmllanguage/data/defaultListProperty.qml diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index a562ecdfa5..a3ca9c44d0 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -1026,6 +1026,23 @@ case $rule_number: { } break; ./ +UiObjectMember: T_DEFAULT T_PROPERTY T_IDENTIFIER T_LT UiPropertyType T_GT JsIdentifier T_AUTOMATIC_SEMICOLON ; +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)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->typeModifier = stringRef(3); + node->propertyToken = loc(2); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(7); + node->semicolonToken = loc(8); + sym(1).Node = node; +} break; +./ + UiObjectMember: T_PROPERTY UiPropertyType JsIdentifier T_COLON UiScriptStatement ; /. case $rule_number: { diff --git a/src/qml/parser/qqmljsgrammar.cpp b/src/qml/parser/qqmljsgrammar.cpp index d7fea7d815..fdcd94b472 100644 --- a/src/qml/parser/qqmljsgrammar.cpp +++ b/src/qml/parser/qqmljsgrammar.cpp @@ -63,35 +63,35 @@ const short QQmlJSGrammar::lhs [] = { 130, 130, 130, 130, 130, 130, 130, 111, 138, 138, 138, 139, 139, 140, 140, 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, + 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, 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, 153, 153, + 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, 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, 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, @@ -100,111 +100,112 @@ const short QQmlJSGrammar::rhs [] = { 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, 5, 6, 6, 10, 6, - 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 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, - 2, 3, 3, 4, 5, 3, 4, 3, 1, 1, - 2, 3, 4, 1, 2, 3, 7, 8, 1, 3, + 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, 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, + 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, 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, + 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, 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, 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, 185, 252, - 216, 224, 220, 164, 236, 212, 3, 149, 82, 165, - 228, 232, 153, 182, 163, 168, 148, 202, 189, 0, - 89, 90, 85, 0, 79, 74, 356, 0, 0, 0, - 0, 87, 0, 0, 83, 86, 78, 0, 0, 75, - 77, 80, 76, 88, 81, 0, 84, 0, 0, 178, - 0, 0, 165, 184, 167, 166, 0, 0, 0, 180, - 181, 179, 183, 0, 213, 0, 0, 0, 0, 203, - 0, 0, 0, 0, 0, 0, 193, 0, 0, 0, - 187, 188, 186, 191, 195, 194, 192, 190, 205, 204, - 206, 0, 221, 0, 217, 0, 0, 159, 146, 158, - 147, 115, 116, 117, 142, 118, 143, 119, 120, 121, - 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 144, 132, 133, 134, 135, 136, 137, 138, 139, 140, - 141, 145, 0, 0, 157, 253, 160, 0, 161, 0, - 162, 156, 0, 249, 242, 240, 247, 248, 246, 245, - 251, 244, 243, 241, 250, 237, 0, 225, 0, 0, - 229, 0, 0, 233, 0, 0, 159, 151, 0, 150, - 0, 155, 169, 0, 345, 345, 346, 0, 343, 0, - 344, 0, 347, 260, 267, 266, 274, 262, 0, 263, - 0, 348, 0, 355, 264, 265, 82, 270, 268, 352, - 349, 354, 271, 0, 282, 0, 0, 0, 0, 339, - 0, 356, 254, 296, 0, 0, 0, 283, 0, 0, - 272, 273, 0, 261, 269, 297, 298, 0, 345, 0, - 0, 347, 0, 340, 341, 0, 329, 353, 0, 313, - 314, 315, 316, 0, 309, 310, 311, 312, 337, 338, - 0, 0, 0, 0, 0, 301, 302, 303, 258, 256, - 218, 226, 222, 238, 214, 259, 0, 165, 230, 234, - 207, 196, 0, 0, 215, 0, 0, 0, 0, 208, - 0, 0, 0, 0, 0, 200, 198, 201, 199, 197, - 210, 209, 211, 0, 223, 0, 219, 0, 257, 165, - 0, 239, 254, 255, 0, 254, 0, 0, 305, 0, - 0, 0, 307, 0, 227, 0, 0, 231, 0, 0, - 235, 294, 0, 286, 295, 289, 0, 293, 0, 254, - 287, 0, 254, 0, 0, 306, 0, 0, 0, 308, - 0, 0, 0, 300, 0, 299, 82, 109, 357, 0, - 0, 114, 276, 279, 0, 115, 282, 118, 143, 120, - 121, 85, 125, 126, 79, 127, 130, 83, 86, 254, - 80, 88, 133, 81, 135, 84, 137, 138, 283, 140, - 141, 145, 0, 111, 110, 113, 97, 112, 96, 0, - 106, 277, 275, 0, 0, 0, 347, 0, 107, 153, - 154, 159, 0, 152, 0, 317, 318, 0, 345, 0, - 0, 347, 0, 108, 0, 0, 0, 320, 325, 323, - 326, 0, 0, 324, 325, 0, 321, 0, 322, 278, - 328, 0, 278, 327, 0, 330, 331, 0, 278, 332, - 333, 0, 0, 334, 0, 0, 0, 335, 336, 171, - 170, 0, 0, 0, 304, 0, 0, 0, 319, 291, - 284, 0, 292, 288, 0, 290, 280, 0, 281, 285, - 0, 0, 347, 0, 342, 100, 0, 0, 104, 91, - 0, 93, 102, 0, 94, 103, 105, 95, 101, 92, - 0, 98, 175, 173, 177, 174, 172, 176, 350, 6, - 351, 4, 2, 72, 99, 0, 0, 75, 77, 76, - 37, 5, 0, 73, 0, 51, 50, 49, 0, 0, - 64, 0, 65, 41, 42, 43, 44, 46, 47, 68, - 45, 0, 51, 0, 0, 0, 0, 0, 60, 0, - 61, 0, 0, 32, 0, 0, 69, 33, 0, 36, - 34, 30, 0, 35, 31, 0, 62, 0, 63, 153, - 0, 66, 70, 0, 0, 0, 0, 153, 278, 0, - 67, 82, 115, 282, 118, 143, 120, 121, 85, 125, - 126, 127, 130, 83, 86, 254, 88, 133, 81, 135, - 84, 137, 138, 283, 140, 141, 145, 71, 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, 358}; + 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}; const short QQmlJSGrammar::goto_default [] = { - 7, 641, 211, 198, 209, 521, 509, 636, 649, 508, - 635, 639, 637, 645, 22, 642, 640, 638, 18, 520, - 562, 552, 559, 554, 539, 193, 197, 199, 204, 234, - 212, 231, 543, 613, 612, 203, 233, 26, 487, 486, + 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, 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, @@ -215,870 +216,896 @@ const short QQmlJSGrammar::goto_default [] = { 0}; const short QQmlJSGrammar::action_index [] = { - 264, 1225, 2708, 2708, 2606, 938, 94, 104, 119, -106, - 92, 79, 81, 262, -106, 263, 78, -106, -106, 654, - 89, 125, 259, 229, -106, -106, -106, 322, 314, 1225, - -106, -106, -106, 412, -106, -106, 2300, 1713, 1225, 1225, - 1225, -106, 842, 1225, -106, -106, -106, 1225, 1225, -106, - -106, -106, -106, -106, -106, 1225, -106, 1225, 1225, -106, - 1225, 1225, 141, 216, -106, -106, 1225, 1225, 1225, -106, - -106, -106, 209, 1225, 281, 1225, 1225, 1225, 1225, 367, - 1225, 1225, 1225, 1225, 1225, 1225, 219, 1225, 1225, 1225, - 101, 102, 115, 314, 314, 314, 314, 314, 357, 347, - 337, 1225, 71, 1225, 70, 2198, 1225, 1225, -106, -106, + 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, -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, 98, 1225, -106, -106, 66, 65, -106, 1225, - -106, -106, 1225, -106, -106, -106, -106, -106, -106, -106, - -106, -106, -106, -106, -106, -106, 1225, 44, 1225, 1225, - 64, 57, 1225, -106, 2198, 1225, 1225, -106, 137, -106, - 49, -106, -106, 93, 344, 474, 95, 86, -106, 390, - -106, 85, 2708, -106, -106, -106, -106, -106, 189, -106, - 474, -106, 80, -106, -106, -106, 83, -106, -106, -106, - 2708, -106, -106, 490, -106, 551, 130, 2606, 46, 51, - 52, 2912, 1225, -106, 63, 1225, 56, -106, 58, 60, - -106, -106, 474, -106, -106, -106, -106, 61, 474, 62, - 67, 2708, 68, -106, -106, 2606, -106, -106, 87, -106, - -106, -106, -106, 110, -106, -106, -106, -106, -106, -106, - -24, 69, 1225, 122, 143, -106, -106, -106, 1419, -106, - 74, 76, 77, -106, 269, 73, 72, 611, 75, 114, - 397, 314, 474, 1225, 287, 1225, 1225, 1225, 1225, 397, - 1225, 1225, 1225, 1225, 1225, 218, 215, 198, 192, 182, - 397, 397, 312, 1225, 55, 1225, 59, 1225, -106, 654, - 1225, -106, 1225, 54, 53, 1225, 50, 2606, -106, 1225, - 124, 2606, -106, 1225, 90, 1225, 1225, 105, 88, 1225, - -106, 84, 157, -27, -106, -106, 1225, -106, 474, 1225, - -106, 82, 1225, 91, 2606, -106, 1225, 120, 2606, -106, - 1225, 103, 2606, -9, 2606, -106, -2, -106, 11, -30, - 17, -106, -106, 2606, -37, 469, 15, 551, 138, 1225, - 2606, 14, -16, 433, 2402, -20, 842, 6, 5, 1324, - 2402, 4, -36, 2, 1225, 7, -18, 1225, 10, 1225, - -26, -13, 2504, -106, -106, -106, -106, -106, -106, 1225, - -106, -106, -106, -33, -59, -25, 2708, 23, -106, 197, - -106, 1225, -12, -106, 140, -106, -106, 22, 474, -4, - 26, 2708, 12, -106, 1225, 113, 30, -106, 142, -106, - 142, 121, 1225, -106, -3, 45, -106, -5, -106, 2606, - -106, 108, 2606, -106, 207, -106, -106, 106, 2606, 37, - -106, 25, 36, -106, 474, 38, 40, -106, -106, -106, - -106, 1225, 136, 2606, -106, 1225, 166, 2606, -106, 13, - -106, 200, -106, -106, 1225, -106, -106, 474, -106, -106, - -17, 16, 2708, -11, -106, -106, 131, 1811, -106, -106, - 1615, -106, -106, 1517, -106, -106, -106, -106, -106, -106, - 109, -106, -106, -106, -106, -106, -106, -106, -106, -106, - 2708, -106, -106, -106, 233, -19, 748, 152, -60, 41, - -106, -106, 191, -106, 177, -106, -106, -106, 387, 203, - -106, 1906, -106, -106, -106, -106, -106, -106, -106, -106, - -106, 180, 43, 376, 174, 48, 474, 240, -106, 8, - -106, 748, 111, -106, -1, 748, -106, -106, 1130, -106, - -106, -106, 1034, -106, -106, 228, -106, 1906, -106, 295, - 21, -106, -106, 184, 379, 39, 2001, 288, 2810, 18, - -106, 34, 482, 33, 551, 138, 1225, 2606, 31, 9, - 399, 3, 643, 19, 29, 1324, 28, 1, 27, 1225, - 24, 0, 1225, 20, 1225, -7, -8, -106, 193, -106, - 205, -106, 47, 42, 329, 208, 319, -106, 128, -106, - -106, -106, 2096, 748, 1713, 35, -106, 132, -106, -106, - 32, -106, -106, 748, 748, 94, 748, -106, 250, -106, - 116, -106, -106, 233, 233, -106, -106, -106, -106, -106, - 393, -106, 214, -106, 100, -106, -106, 474, -106, -106, - 96, -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, - -111, 15, 71, 87, 80, 305, -6, -111, -111, -111, - -111, -111, -111, -111, -111, -111, -111, -111, -111, -42, - -111, -111, -111, -111, -111, -111, -111, -111, -111, 95, - -111, -111, -111, 3, -111, -111, -5, -11, 9, 109, - 91, -111, 62, 45, -111, -111, -111, 50, 63, -111, - -111, -111, -111, -111, -111, 32, -111, 203, 197, -111, - 189, 178, -111, -111, -111, -111, 182, 185, 188, -111, - -111, -111, -111, 193, -111, 198, 168, 113, 114, -111, - 133, 116, 123, 129, 130, 132, -111, 136, 139, 142, + -111, 6, 66, 84, 80, 306, 43, -111, -111, -111, + -111, -111, -111, -111, -111, -111, -111, -111, -111, -23, + -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, 148, -111, 151, -111, 186, 6, -37, -111, -111, + -111, 52, -111, 49, -111, 62, 44, 28, -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, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, 42, -111, -111, -111, -111, -111, 22, - -111, -111, 2, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, -111, -111, -111, 96, -111, 66, 21, - -111, -111, 0, -111, 274, 35, 88, -111, -111, -111, - -111, -111, -111, -111, 41, 75, -111, -111, -111, 49, - -111, -111, 48, -111, -111, -111, -111, -111, -111, -111, - 57, -111, -111, -111, -111, -111, -111, -111, -111, -111, - 77, -111, -111, 54, -111, 27, -111, 243, -111, 25, - -111, 160, 36, -111, -111, 169, 40, -111, -111, -111, - -111, -111, 56, -111, -111, -111, -111, -111, 180, -111, - -111, 163, -111, -111, -111, 246, -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, 8, -111, -111, -111, -111, -111, 69, -111, + -111, -111, 27, -111, -111, -111, -111, -111, 117, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, 61, 211, -111, 272, 257, 256, 236, -111, - 81, 83, 85, 68, 94, -111, -111, -111, -111, -111, - -111, -111, -111, 235, -111, 218, -111, 209, -111, -111, - 244, -111, 227, -111, -111, 228, -111, 238, -111, 33, - -111, 167, -111, 245, -111, 253, 254, -111, -111, 225, - -111, -111, -111, -111, -111, -111, 217, -111, 194, 213, - -111, -111, 208, -111, 207, -111, 52, -111, 205, -111, - 55, -111, 201, -111, 199, -111, -111, -111, -111, -111, - -111, -111, -111, 278, -111, 39, -111, 34, -111, 173, - 219, -111, -111, 53, 231, -111, 73, -111, -111, 44, - 59, -111, -111, -111, 47, -111, 24, 102, -111, 101, - -111, -111, 111, -111, -111, -111, -111, -111, -111, 26, - -111, -111, -111, -111, -111, -111, 65, -111, -111, -111, - -111, 76, -111, -111, -111, -111, -111, -111, 79, -111, - -111, 89, -111, -111, 51, -111, -111, -111, -111, -111, - -62, -111, 37, -111, -63, -111, -111, -111, -111, 387, - -111, -111, 264, -111, -111, -111, -111, -111, 158, -54, - -111, -111, 28, -111, 38, -111, 23, -111, -111, -111, - -111, 43, -111, 78, -111, 58, -111, 67, -111, -111, - -111, -111, -111, -111, 18, -111, -111, 195, -111, -111, - -111, -111, 161, -111, -111, -111, -111, 20, -111, -111, - 157, -111, -111, 31, -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, -111, -111, -111, -111, -111, -111, -111, -111, - 206, -111, -111, -111, -111, -111, -7, -111, -111, -111, - -111, -111, -111, -111, -24, -111, -111, -111, -12, -111, - -111, 342, -111, -111, -111, -111, -111, -111, -111, -111, - -111, -111, -111, -16, -32, -111, 5, -111, -111, -111, - -111, 152, -111, -111, -111, 248, -111, -111, 330, -111, - -111, -111, 324, -111, -111, -111, -111, 385, -111, -111, - -21, -111, -111, 1, 14, -111, 367, -111, 232, 12, - -111, -111, 11, -111, 10, -111, 164, 141, -111, -111, - 7, -111, 64, -111, -111, 19, -111, -111, -111, 17, - -111, -1, 60, -111, 46, -111, -111, -111, -111, -111, - -15, -111, -111, -111, -2, -17, -4, -111, -111, -111, - -111, -111, 484, 138, 313, -3, -111, -111, -111, -111, - 4, -111, -111, 13, 16, 97, 127, -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, -111, -111, -111, -111, -111, -111, -111, -111, - -14, -111, -111, -111, -111, -111, -111, -8, -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}; const short QQmlJSGrammar::action_info [] = { - 424, 405, 432, 404, 346, 245, 573, 354, 406, -134, - 461, -112, -113, -131, -136, 448, 350, -139, 402, 392, - 268, -123, -142, 465, 399, 398, -131, -139, 465, 461, - 474, -136, 558, 448, -134, -112, -113, 424, -123, 350, - -142, 245, 551, 481, 484, 268, 576, 524, 413, 482, - 438, 558, 439, 261, 558, 615, 420, 452, 418, 421, - 283, 454, 143, 428, 172, 558, 166, 423, 558, 448, - 608, 73, 546, 448, 149, 283, 0, 323, 408, 0, - 544, 307, 268, 0, 0, 0, 143, 184, 350, 448, - 245, 166, 101, 73, 461, 329, 465, 238, 456, 424, - 241, 336, 618, 189, 665, 262, 143, 323, 0, 181, - 317, 143, 451, 0, 315, 442, 143, 143, 192, 555, - 0, 143, 240, 243, 303, 151, 452, 101, 143, 185, - 143, 435, 143, 312, 305, 244, 0, 0, 303, 490, - 555, 60, 60, 342, 143, 143, 191, 432, 252, 251, - 103, 344, 61, 61, 144, 60, 305, 662, 661, 60, - 103, 656, 655, 352, 325, 338, 61, 556, 326, 501, - 61, 257, 256, 426, 143, 168, 436, 664, 663, 169, - 348, 542, 264, 64, 321, 633, 634, 491, 628, 620, - 619, 259, 258, 179, 65, 174, 463, 143, 622, 259, - 258, 416, 415, 525, 267, 265, 525, 87, 477, 88, - 531, 0, 174, 525, 175, 143, 411, 87, 339, 88, - 89, 66, 0, 87, 558, 88, 467, 527, 66, 610, - 89, 175, 266, 411, 525, 567, 89, 525, 526, 0, - 87, 66, 88, 87, 87, 88, 88, 549, 174, 527, - 236, 235, 527, 89, 611, 609, 89, 89, 0, 527, - 526, 478, 476, 526, 532, 530, 67, 175, 446, 445, - 526, 0, 68, 67, 174, 659, 658, 105, 0, 68, - 527, 75, 76, 527, 0, 623, 67, 285, 286, 568, - 566, 526, 68, 175, 526, 176, 106, 652, 107, 75, - 76, 550, 548, 174, 0, 285, 286, 657, 77, 78, - 174, 653, 651, 0, 287, 288, 0, 0, 0, 0, - 0, -99, 175, 0, 176, 0, 77, 78, -99, 175, - 0, 176, 287, 288, 0, 290, 291, 0, 0, 87, - 0, 88, 0, 650, 292, 80, 81, 293, 35, 294, - 0, 0, 89, 82, 83, 0, 0, 84, 35, 85, - 80, 81, 6, 5, 4, 1, 3, 2, 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, 49, 52, 50, 82, 83, - 0, 0, 84, 0, 85, 35, 0, 0, 35, 0, - 49, 52, 50, 46, 34, 51, 35, 0, 0, 35, - 290, 291, 35, 46, 34, 51, 0, 0, 35, 292, - 0, 0, 293, 0, 294, 184, 0, 0, 46, 34, - 51, 35, 49, 52, 50, 49, 52, 50, 184, 0, + 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, + 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, 0, 0, 49, 52, 50, 0, 184, - 46, 34, 51, 46, 34, 51, 0, 0, 49, 52, - 50, 46, 34, 51, 46, 34, 51, 46, 34, 51, - 0, 0, 0, 46, 34, 51, 0, 0, 35, 49, - 52, 50, 0, 35, 0, 0, 46, 34, 51, 0, - 0, 35, 0, 0, 0, 0, 0, 0, 0, 35, - 0, 0, 0, 0, 0, 0, 0, 46, 34, 51, - 250, 249, 0, 0, 0, 49, 52, 50, 0, 0, - 49, 52, 50, 250, 249, 0, 0, 0, 49, 52, - 50, 250, 249, 0, 0, 0, 49, 52, 50, 0, - 0, 0, 0, 46, 34, 51, 0, 0, 46, 34, - 51, 0, 0, 0, 0, 0, 46, 34, 51, 0, - 35, 0, 0, 0, 46, 34, 51, 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, 255, 254, 153, 0, 0, 49, 52, 50, - 0, 0, 0, 0, 154, 0, 0, 0, 155, 0, - 0, 0, 0, 0, 0, 0, 0, 156, 0, 157, - 0, 0, 319, 0, 0, 46, 34, 51, 0, 0, - 158, 0, 159, 64, 0, 30, 31, 153, 0, 0, - 160, 0, 0, 161, 65, 33, 0, 154, 0, 162, - 0, 155, 35, 0, 0, 163, 36, 37, 0, 38, - 156, 0, 157, 0, 0, 0, 42, 0, 0, 0, - 45, 164, 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, 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, + 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, 0, 0, 46, 34, 51, 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, + 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, 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, 563, - 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, 560, 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, 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, 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, 55, 0, 57, - 0, 58, 0, 0, 0, 0, 44, 56, 32, 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, -132, 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, 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, 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, 55, 0, 57, 282, 58, 0, 0, 0, 0, + 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, 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, 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, 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, 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, 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, 496, + 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, 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, 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, 220, 0, 0, 221, + 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, 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, 578, 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, 578, - 624, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 582, 112, 113, 0, 0, 584, - 117, 586, 30, 31, 587, 0, 120, 0, 0, 0, - 122, 589, 590, 0, 0, 0, 0, 0, 0, 35, - 591, 126, 127, 221, 37, 0, 38, 0, 0, 0, - 39, 0, 40, 592, 43, 0, 0, 594, 0, 0, - 0, 47, 0, 48, 0, 0, 0, 0, 0, 595, - 0, 223, 0, 0, 0, 596, 49, 52, 50, 597, - 598, 599, 55, 601, 602, 603, 604, 605, 606, 0, - 0, 593, 600, 588, 583, 585, 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, -278, 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, - - 545, 572, 565, 632, 654, 148, 529, 541, 528, 142, - 660, 263, 500, 393, 617, 616, 621, 614, 16, 629, - 444, 183, 313, 547, 447, 183, 631, 643, 253, 248, - 644, 485, 575, 574, 607, 152, 320, 437, 178, 313, - 441, 433, 173, 183, 165, 253, 462, 313, 457, 447, - 444, 453, 253, 458, 425, 347, 455, 248, 351, 188, - 475, 466, 498, 171, 150, 447, 206, 190, 400, 468, - 0, 183, 248, 495, 469, 237, 409, 393, 409, 331, - 464, 247, 512, 206, 145, 206, 62, 409, 507, 206, - 0, 511, 0, 188, 0, 206, 206, 188, 206, 62, - 62, 504, 460, 417, 62, 206, 505, 206, 647, 646, - 407, 0, 0, 410, 62, 410, 459, 62, 148, 506, - 62, 187, 62, 277, 410, 419, 412, 298, 281, 393, - 148, 0, 0, 0, 422, 62, 170, 62, 180, 62, - 295, 514, 296, 260, 297, 62, 648, 503, 62, 62, - 62, 182, 514, 299, 394, 62, 62, 460, 459, 206, - 362, 630, 362, 62, 167, 502, 514, 62, 62, 322, - 62, 553, 444, 99, 100, 93, 206, 62, 356, 206, - 510, 206, 94, 62, 62, 206, 62, 62, 95, 96, - 62, 97, 86, 62, 90, 493, 62, 91, 188, 492, - 92, 355, 62, 353, 108, 62, 483, 349, 242, 345, - 247, 313, 331, 469, 102, 104, 313, 206, 62, 206, - 182, 260, 62, 206, 206, 206, 239, 62, 98, 182, - 313, 313, 62, 110, 362, 72, 62, 206, 69, 62, - 318, 70, 62, 62, 71, 260, 63, 62, 246, 393, - 581, 62, 62, 460, 0, 74, 206, 62, 79, 459, - 0, 206, 514, 309, 206, 62, 362, 557, 281, 0, - 281, 309, 62, 0, 284, 403, 281, 281, 0, 309, - 401, 0, 206, 306, 281, 308, 343, 479, 340, 62, - 62, 341, 108, 337, 281, 281, 206, 302, 309, 62, - 0, 330, 304, 281, 281, 314, 316, 62, 309, 0, - 62, 62, 281, 281, 324, 281, 281, 301, 300, 514, - 311, 110, 177, 0, 327, 0, 62, 569, 522, 564, - 328, 281, 553, 289, 627, 561, 0, 0, 514, 0, - 513, 523, 0, 0, 514, 0, 0, 522, 0, 0, - 0, 0, 443, 522, 0, 485, 0, 0, 0, 513, - 523, 0, 0, 0, 0, 513, 523, 533, 534, 535, - 536, 540, 537, 538, 0, 0, 0, 0, 0, 0, - 0, 577, 0, 0, 0, 0, 0, 0, 0, 362, - 579, 580, 533, 534, 535, 536, 540, 537, 538, 569, - 0, 0, 0, 0, 0, 206, 0, 0, 570, 571, - 533, 534, 535, 536, 540, 537, 538, 0, 0, 0, - 0, 0, 0, 0, 0, 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, + 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, 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, + + 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, 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, 440, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 577, 0, - 0, 0, 0, 0, 0, 0, 0, 625, 626, 533, - 534, 535, 536, 540, 537, 538, 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}; const short QQmlJSGrammar::action_check [] = { - 36, 60, 5, 36, 31, 7, 66, 16, 33, 7, - 36, 7, 7, 7, 7, 33, 36, 7, 55, 8, - 36, 7, 7, 36, 7, 55, 7, 7, 36, 36, - 17, 7, 33, 33, 7, 7, 7, 36, 7, 36, - 7, 7, 34, 60, 55, 36, 7, 66, 60, 33, - 55, 33, 7, 77, 33, 8, 60, 20, 36, 33, - 1, 36, 8, 33, 7, 33, 2, 55, 33, 33, - 29, 1, 24, 33, 8, 1, -1, 2, 55, -1, - 37, 8, 36, -1, -1, -1, 8, 36, 36, 33, - 7, 2, 48, 1, 36, 7, 36, 36, 60, 36, - 33, 17, 60, 8, 0, 36, 8, 2, -1, 60, - 60, 8, 6, -1, 61, 7, 8, 8, 33, 8, - -1, 8, 60, 55, 48, 60, 20, 48, 8, 36, - 8, 10, 8, 61, 79, 55, -1, -1, 48, 8, - 8, 40, 40, 61, 8, 8, 60, 5, 61, 62, - 79, 60, 51, 51, 56, 40, 79, 61, 62, 40, - 79, 61, 62, 60, 50, 8, 51, 56, 54, 60, - 51, 61, 62, 60, 8, 50, 55, 61, 62, 54, - 60, 29, 60, 42, 60, 91, 92, 56, 56, 61, - 62, 61, 62, 56, 53, 15, 60, 8, 7, 61, - 62, 61, 62, 29, 61, 62, 29, 25, 8, 27, - 7, -1, 15, 29, 34, 8, 36, 25, 61, 27, - 38, 12, -1, 25, 33, 27, 60, 75, 12, 36, - 38, 34, 89, 36, 29, 7, 38, 29, 86, -1, - 25, 12, 27, 25, 25, 27, 27, 7, 15, 75, - 61, 62, 75, 38, 61, 62, 38, 38, -1, 75, - 86, 61, 62, 86, 61, 62, 57, 34, 61, 62, - 86, -1, 63, 57, 15, 61, 62, 15, -1, 63, - 75, 18, 19, 75, -1, 94, 57, 18, 19, 61, - 62, 86, 63, 34, 86, 36, 34, 47, 36, 18, - 19, 61, 62, 15, -1, 18, 19, 93, 45, 46, - 15, 61, 62, -1, 45, 46, -1, -1, -1, -1, - -1, 33, 34, -1, 36, -1, 45, 46, 33, 34, - -1, 36, 45, 46, -1, 23, 24, -1, -1, 25, - -1, 27, -1, 93, 32, 23, 24, 35, 29, 37, - -1, -1, 38, 31, 32, -1, -1, 35, 29, 37, - 23, 24, 98, 99, 100, 101, 102, 103, 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, 66, 67, 68, 31, 32, - -1, -1, 35, -1, 37, 29, -1, -1, 29, -1, - 66, 67, 68, 94, 95, 96, 29, -1, -1, 29, - 23, 24, 29, 94, 95, 96, -1, -1, 29, 32, - -1, -1, 35, -1, 37, 36, -1, -1, 94, 95, - 96, 29, 66, 67, 68, 66, 67, 68, 36, -1, + 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, + 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, -1, -1, 66, 67, 68, -1, 36, - 94, 95, 96, 94, 95, 96, -1, -1, 66, 67, - 68, 94, 95, 96, 94, 95, 96, 94, 95, 96, - -1, -1, -1, 94, 95, 96, -1, -1, 29, 66, - 67, 68, -1, 29, -1, -1, 94, 95, 96, -1, - -1, 29, -1, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, -1, -1, -1, -1, 94, 95, 96, - 61, 62, -1, -1, -1, 66, 67, 68, -1, -1, - 66, 67, 68, 61, 62, -1, -1, -1, 66, 67, - 68, 61, 62, -1, -1, -1, 66, 67, 68, -1, - -1, -1, -1, 94, 95, 96, -1, -1, 94, 95, - 96, -1, -1, -1, -1, -1, 94, 95, 96, -1, - 29, -1, -1, -1, 94, 95, 96, -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, 61, 62, 3, -1, -1, 66, 67, 68, - -1, -1, -1, -1, 13, -1, -1, -1, 17, -1, - -1, -1, -1, -1, -1, -1, -1, 26, -1, 28, - -1, -1, 31, -1, -1, 94, 95, 96, -1, -1, - 39, -1, 41, 42, -1, 12, 13, 3, -1, -1, - 49, -1, -1, 52, 53, 22, -1, 13, -1, 58, - -1, 17, 29, -1, -1, 64, 33, 34, -1, 36, - 26, -1, 28, -1, -1, -1, 43, -1, -1, -1, - 47, 80, -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, -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, + 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, -1, -1, 94, 95, 96, -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, + 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, -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, - 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, 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, 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, 72, -1, 74, - -1, 76, -1, -1, -1, -1, 81, 82, 83, -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, 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, 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, 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, 72, -1, 74, 75, 76, -1, -1, -1, -1, + -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, 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, 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, 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, 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, -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, 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, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, -1, 56, -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, 72, -1, 74, -1, 76, -1, -1, - -1, -1, 81, 82, 83, -1, -1, -1, 87, -1, + -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, 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, -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, 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, + 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, 61, -1, -1, -1, 65, 66, 67, 68, - 69, 70, -1, 72, 73, 74, -1, 76, -1, 78, + -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, 30, -1, -1, 33, + -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, 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, -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, 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, + -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, - 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, + 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, 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, 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, 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, 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, - - 32, 22, 18, 9, 18, 42, 18, 14, 32, 3, - 18, 3, 3, 18, 18, 32, 18, 32, 3, 22, - 3, 18, 3, 18, 25, 18, 22, 14, 18, 18, - 14, 42, 18, 32, 22, 77, 3, 100, 3, 3, - 3, 103, 42, 18, 42, 18, 3, 3, 25, 25, - 3, 105, 18, 25, 3, 3, 18, 18, 3, 18, - 42, 3, 42, 42, 42, 25, 18, 18, 42, 2, - -1, 18, 18, 42, 18, 18, 14, 18, 14, 18, - 2, 4, 2, 18, 42, 18, 54, 14, 56, 18, - -1, 4, -1, 18, -1, 18, 18, 18, 18, 54, - 54, 56, 56, 44, 54, 18, 56, 18, 11, 12, - 45, -1, -1, 51, 54, 51, 56, 54, 42, 56, - 54, 46, 54, 54, 51, 46, 50, 59, 59, 18, - 42, -1, -1, -1, 45, 54, 70, 54, 50, 54, - 59, 14, 59, 2, 59, 54, 19, 56, 54, 54, - 54, 56, 14, 59, 43, 54, 54, 56, 56, 18, - 2, 23, 2, 54, 68, 56, 14, 54, 54, 2, - 54, 19, 3, 60, 60, 59, 18, 54, 18, 18, - 109, 18, 59, 54, 54, 18, 54, 54, 59, 59, - 54, 59, 59, 54, 58, 38, 54, 58, 18, 42, - 58, 2, 54, 2, 18, 54, 45, 2, 45, 2, - 4, 3, 18, 18, 66, 64, 3, 18, 54, 18, - 56, 2, 54, 18, 18, 18, 46, 54, 60, 56, - 3, 3, 54, 47, 2, 57, 54, 18, 56, 54, - 2, 56, 54, 54, 56, 2, 57, 54, 2, 18, - 18, 54, 54, 56, -1, 62, 18, 54, 60, 56, - -1, 18, 14, 54, 18, 54, 2, 19, 59, -1, - 59, 54, 54, -1, 63, 44, 59, 59, -1, 54, - 2, -1, 18, 65, 59, 76, 78, 92, 94, 54, - 54, 78, 18, 76, 59, 59, 18, 61, 54, 54, - -1, 76, 67, 59, 59, 78, 78, 54, 54, -1, - 54, 54, 59, 59, 69, 59, 59, 61, 61, 14, - 76, 47, 48, -1, 71, -1, 54, 14, 23, 5, - 76, 59, 19, 61, 21, 5, -1, -1, 14, -1, - 35, 36, -1, -1, 14, -1, -1, 23, -1, -1, - -1, -1, 88, 23, -1, 42, -1, -1, -1, 35, - 36, -1, -1, -1, -1, 35, 36, 25, 26, 27, - 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, - -1, 14, -1, -1, -1, -1, -1, -1, -1, 2, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 14, - -1, -1, -1, -1, -1, 18, -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, 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, + + 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 88, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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, -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, -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 fadbe80c64..244a807f24 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 = 665, - RULE_COUNT = 358, - STATE_COUNT = 666, + ACCEPT_STATE = 672, + RULE_COUNT = 360, + STATE_COUNT = 673, TERMINAL_COUNT = 106, NON_TERMINAL_COUNT = 111, - GOTO_INDEX_OFFSET = 666, - GOTO_INFO_OFFSET = 3018, - GOTO_CHECK_OFFSET = 3018 + GOTO_INDEX_OFFSET = 673, + GOTO_INFO_OFFSET = 3185, + GOTO_CHECK_OFFSET = 3185 }; static const char *const spell []; diff --git a/src/qml/parser/qqmljsparser.cpp b/src/qml/parser/qqmljsparser.cpp index 92d12aee9c..ca5a09d22d 100644 --- a/src/qml/parser/qqmljsparser.cpp +++ b/src/qml/parser/qqmljsparser.cpp @@ -511,7 +511,20 @@ case 64: { sym(1).Node = node; } break; -case 65: { +case 66: { + AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(5), stringRef(7)); + node->isDefaultMember = true; + node->defaultToken = loc(1); + node->typeModifier = stringRef(3); + node->propertyToken = loc(2); + node->typeModifierToken = loc(2); + node->typeToken = loc(4); + node->identifierToken = loc(7); + node->semicolonToken = loc(8); + sym(1).Node = node; +} break; + +case 67: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3), sym(5).Statement); node->propertyToken = loc(1); @@ -521,7 +534,7 @@ case 65: { sym(1).Node = node; } break; -case 66: { +case 68: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), sym(6).Statement); node->isReadonlyMember = true; @@ -533,7 +546,7 @@ case 66: { sym(1).Node = node; } break; -case 67: { +case 69: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4), sym(6).Statement); node->isDefaultMember = true; @@ -545,7 +558,7 @@ case 67: { sym(1).Node = node; } break; -case 68: { +case 70: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(4), stringRef(6)); node->typeModifier = stringRef(2); node->propertyToken = loc(1); @@ -569,7 +582,7 @@ case 68: { sym(1).Node = node; } break; -case 69: { +case 71: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(2), stringRef(3)); node->propertyToken = loc(1); node->typeToken = loc(2); @@ -589,7 +602,7 @@ case 69: { sym(1).Node = node; } break; -case 70: { +case 72: { AST::UiPublicMember *node = new (pool) AST::UiPublicMember(stringRef(3), stringRef(4)); node->isReadonlyMember = true; node->readonlyToken = loc(1); @@ -611,57 +624,57 @@ case 70: { sym(1).Node = node; } break; -case 71: { +case 73: { sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); } break; -case 72: { +case 74: { sym(1).Node = new (pool) AST::UiSourceElement(sym(1).Node); } break; -case 80: { +case 82: { AST::ThisExpression *node = new (pool) AST::ThisExpression(); node->thisToken = loc(1); sym(1).Node = node; } break; -case 81: { +case 83: { AST::IdentifierExpression *node = new (pool) AST::IdentifierExpression(stringRef(1)); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 82: { +case 84: { AST::NullExpression *node = new (pool) AST::NullExpression(); node->nullToken = loc(1); sym(1).Node = node; } break; -case 83: { +case 85: { AST::TrueLiteral *node = new (pool) AST::TrueLiteral(); node->trueToken = loc(1); sym(1).Node = node; } break; -case 84: { +case 86: { AST::FalseLiteral *node = new (pool) AST::FalseLiteral(); node->falseToken = loc(1); sym(1).Node = node; } break; -case 85: { +case 87: { AST::NumericLiteral *node = new (pool) AST::NumericLiteral(sym(1).dval); node->literalToken = loc(1); sym(1).Node = node; } break; -case 86: -case 87: { +case 88: +case 89: { AST::StringLiteral *node = new (pool) AST::StringLiteral(stringRef(1)); node->literalToken = loc(1); sym(1).Node = node; } break; -case 88: { +case 90: { bool rx = lexer->scanRegExp(Lexer::NoPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -677,7 +690,7 @@ case 88: { sym(1).Node = node; } break; -case 89: { +case 91: { bool rx = lexer->scanRegExp(Lexer::EqualPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -693,28 +706,28 @@ case 89: { sym(1).Node = node; } break; -case 90: { +case 92: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral((AST::Elision *) 0); node->lbracketToken = loc(1); node->rbracketToken = loc(2); sym(1).Node = node; } break; -case 91: { +case 93: { 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 92: { +case 94: { 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 93: { +case 95: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), (AST::Elision *) 0); node->lbracketToken = loc(1); @@ -723,7 +736,7 @@ case 93: { sym(1).Node = node; } break; -case 94: { +case 96: { AST::ArrayLiteral *node = new (pool) AST::ArrayLiteral(sym(2).ElementList->finish (), sym(4).Elision->finish()); node->lbracketToken = loc(1); @@ -732,7 +745,7 @@ case 94: { sym(1).Node = node; } break; -case 95: { +case 97: { AST::ObjectLiteral *node = 0; if (sym(2).Node) node = new (pool) AST::ObjectLiteral( @@ -744,7 +757,7 @@ case 95: { sym(1).Node = node; } break; -case 96: { +case 98: { AST::ObjectLiteral *node = new (pool) AST::ObjectLiteral( sym(2).PropertyAssignmentList->finish ()); node->lbraceToken = loc(1); @@ -752,14 +765,14 @@ case 96: { sym(1).Node = node; } break; -case 97: { +case 99: { AST::NestedExpression *node = new (pool) AST::NestedExpression(sym(2).Expression); node->lparenToken = loc(1); node->rparenToken = loc(3); sym(1).Node = node; } break; -case 98: { +case 100: { if (AST::ArrayMemberExpression *mem = AST::cast(sym(1).Expression)) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Warning, mem->lbracketToken, QLatin1String("Ignored annotation"))); @@ -779,48 +792,48 @@ case 98: { } } break; -case 99: { +case 101: { sym(1).Node = new (pool) AST::ElementList((AST::Elision *) 0, sym(1).Expression); } break; -case 100: { +case 102: { sym(1).Node = new (pool) AST::ElementList(sym(1).Elision->finish(), sym(2).Expression); } break; -case 101: { +case 103: { 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 102: { +case 104: { 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 103: { +case 105: { AST::Elision *node = new (pool) AST::Elision(); node->commaToken = loc(1); sym(1).Node = node; } break; -case 104: { +case 106: { AST::Elision *node = new (pool) AST::Elision(sym(1).Elision); node->commaToken = loc(2); sym(1).Node = node; } break; -case 105: { +case 107: { AST::PropertyNameAndValue *node = new (pool) AST::PropertyNameAndValue( sym(1).PropertyName, sym(3).Expression); node->colonToken = loc(2); sym(1).Node = node; } break; -case 106: { +case 108: { AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( sym(2).PropertyName, sym(6).FunctionBody); node->getSetToken = loc(1); @@ -831,7 +844,7 @@ case 106: { sym(1).Node = node; } break; -case 107: { +case 109: { AST::PropertyGetterSetter *node = new (pool) AST::PropertyGetterSetter( sym(2).PropertyName, sym(4).FormalParameterList, sym(7).FunctionBody); node->getSetToken = loc(1); @@ -842,56 +855,56 @@ case 107: { sym(1).Node = node; } break; -case 108: { +case 110: { sym(1).Node = new (pool) AST::PropertyAssignmentList(sym(1).PropertyAssignment); } break; -case 109: { +case 111: { AST::PropertyAssignmentList *node = new (pool) AST::PropertyAssignmentList( sym(1).PropertyAssignmentList, sym(3).PropertyAssignment); node->commaToken = loc(2); sym(1).Node = node; } break; -case 110: { +case 112: { AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 111: { +case 113: { AST::StringLiteralPropertyName *node = new (pool) AST::StringLiteralPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 112: { +case 114: { AST::NumericLiteralPropertyName *node = new (pool) AST::NumericLiteralPropertyName(sym(1).dval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 113: { +case 115: { AST::IdentifierPropertyName *node = new (pool) AST::IdentifierPropertyName(stringRef(1)); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 149: { +case 151: { 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 150: { +case 152: { 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 151: { +case 153: { AST::NewMemberExpression *node = new (pool) AST::NewMemberExpression(sym(2).Expression, sym(4).ArgumentList); node->newToken = loc(1); node->lparenToken = loc(3); @@ -899,316 +912,309 @@ case 151: { sym(1).Node = node; } break; -case 153: { +case 155: { AST::NewExpression *node = new (pool) AST::NewExpression(sym(2).Expression); node->newToken = loc(1); sym(1).Node = node; } break; -case 154: { +case 156: { 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 155: { +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 156: { +case 158: { 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 157: { +case 159: { 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 158: { +case 160: { sym(1).Node = 0; } break; -case 159: { +case 161: { sym(1).Node = sym(1).ArgumentList->finish(); } break; -case 160: { +case 162: { sym(1).Node = new (pool) AST::ArgumentList(sym(1).Expression); } break; -case 161: { +case 163: { AST::ArgumentList *node = new (pool) AST::ArgumentList(sym(1).ArgumentList, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 165: { +case 167: { AST::PostIncrementExpression *node = new (pool) AST::PostIncrementExpression(sym(1).Expression); node->incrementToken = loc(2); sym(1).Node = node; } break; -case 166: { +case 168: { AST::PostDecrementExpression *node = new (pool) AST::PostDecrementExpression(sym(1).Expression); node->decrementToken = loc(2); sym(1).Node = node; } break; -case 168: { +case 170: { AST::DeleteExpression *node = new (pool) AST::DeleteExpression(sym(2).Expression); node->deleteToken = loc(1); sym(1).Node = node; } break; -case 169: { +case 171: { AST::VoidExpression *node = new (pool) AST::VoidExpression(sym(2).Expression); node->voidToken = loc(1); sym(1).Node = node; } break; -case 170: { +case 172: { AST::TypeOfExpression *node = new (pool) AST::TypeOfExpression(sym(2).Expression); node->typeofToken = loc(1); sym(1).Node = node; } break; -case 171: { +case 173: { AST::PreIncrementExpression *node = new (pool) AST::PreIncrementExpression(sym(2).Expression); node->incrementToken = loc(1); sym(1).Node = node; } break; -case 172: { +case 174: { AST::PreDecrementExpression *node = new (pool) AST::PreDecrementExpression(sym(2).Expression); node->decrementToken = loc(1); sym(1).Node = node; } break; -case 173: { +case 175: { AST::UnaryPlusExpression *node = new (pool) AST::UnaryPlusExpression(sym(2).Expression); node->plusToken = loc(1); sym(1).Node = node; } break; -case 174: { +case 176: { AST::UnaryMinusExpression *node = new (pool) AST::UnaryMinusExpression(sym(2).Expression); node->minusToken = loc(1); sym(1).Node = node; } break; -case 175: { +case 177: { AST::TildeExpression *node = new (pool) AST::TildeExpression(sym(2).Expression); node->tildeToken = loc(1); sym(1).Node = node; } break; -case 176: { +case 178: { AST::NotExpression *node = new (pool) AST::NotExpression(sym(2).Expression); node->notToken = loc(1); sym(1).Node = node; } break; -case 178: { +case 180: { 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 179: { +case 181: { 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 180: { +case 182: { 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 182: { +case 184: { 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 183: { +case 185: { 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 185: { +case 187: { 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 186: { +case 188: { 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 187: { +case 189: { 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 189: { +case 191: { 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 190: { +case 192: { 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 191: { +case 193: { 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 192: { +case 194: { 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 193: { +case 195: { 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 194: { +case 196: { 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 196: { +case 198: { 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 197: { +case 199: { 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 198: { +case 200: { 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 199: { +case 201: { 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 200: { +case 202: { 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 202: { +case 204: { 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 203: { +case 205: { 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 204: { +case 206: { 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 205: { +case 207: { 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 207: { +case 209: { 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 208: { +case 210: { 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 209: { +case 211: { 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 210: { - 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 212: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitAnd, sym(3).Expression); + QSOperator::StrictNotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; @@ -1222,7 +1228,7 @@ case 214: { case 216: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitXor, sym(3).Expression); + QSOperator::BitAnd, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; @@ -1236,7 +1242,7 @@ case 218: { case 220: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::BitOr, sym(3).Expression); + QSOperator::BitXor, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; @@ -1250,7 +1256,7 @@ case 222: { case 224: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::And, sym(3).Expression); + QSOperator::BitOr, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; @@ -1264,7 +1270,7 @@ case 226: { case 228: { AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, - QSOperator::Or, sym(3).Expression); + QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; @@ -1277,6 +1283,13 @@ case 230: { } break; case 232: { + 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: { AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1284,7 +1297,7 @@ case 232: { sym(1).Node = node; } break; -case 234: { +case 236: { AST::ConditionalExpression *node = new (pool) AST::ConditionalExpression(sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1292,112 +1305,112 @@ case 234: { sym(1).Node = node; } break; -case 236: { +case 238: { 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 238: { +case 240: { 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 239: { +case 241: { sym(1).ival = QSOperator::Assign; } break; -case 240: { +case 242: { sym(1).ival = QSOperator::InplaceMul; } break; -case 241: { +case 243: { sym(1).ival = QSOperator::InplaceDiv; } break; -case 242: { +case 244: { sym(1).ival = QSOperator::InplaceMod; } break; -case 243: { +case 245: { sym(1).ival = QSOperator::InplaceAdd; } break; -case 244: { +case 246: { sym(1).ival = QSOperator::InplaceSub; } break; -case 245: { +case 247: { sym(1).ival = QSOperator::InplaceLeftShift; } break; -case 246: { +case 248: { sym(1).ival = QSOperator::InplaceRightShift; } break; -case 247: { +case 249: { sym(1).ival = QSOperator::InplaceURightShift; } break; -case 248: { +case 250: { sym(1).ival = QSOperator::InplaceAnd; } break; -case 249: { +case 251: { sym(1).ival = QSOperator::InplaceXor; } break; -case 250: { +case 252: { sym(1).ival = QSOperator::InplaceOr; } break; -case 252: { +case 254: { AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 253: { +case 255: { sym(1).Node = 0; } break; -case 256: { +case 258: { AST::Expression *node = new (pool) AST::Expression(sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 257: { +case 259: { sym(1).Node = 0; } break; -case 274: { +case 276: { AST::Block *node = new (pool) AST::Block(sym(2).StatementList); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 275: { +case 277: { sym(1).Node = new (pool) AST::StatementList(sym(1).Statement); } break; -case 276: { +case 278: { sym(1).Node = new (pool) AST::StatementList(sym(1).StatementList, sym(2).Statement); } break; -case 277: { +case 279: { sym(1).Node = 0; } break; -case 278: { +case 280: { sym(1).Node = sym(1).StatementList->finish (); } break; -case 280: { +case 282: { AST::VariableStatement *node = new (pool) AST::VariableStatement( sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); node->declarationKindToken = loc(1); @@ -1405,76 +1418,76 @@ case 280: { sym(1).Node = node; } break; -case 281: { +case 283: { sym(1).ival = T_CONST; } break; -case 282: { +case 284: { sym(1).ival = T_VAR; } break; -case 283: { +case 285: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); } break; -case 284: { +case 286: { AST::VariableDeclarationList *node = new (pool) AST::VariableDeclarationList( sym(1).VariableDeclarationList, sym(3).VariableDeclaration); node->commaToken = loc(2); sym(1).Node = node; } break; -case 285: { +case 287: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclaration); } break; -case 286: { +case 288: { sym(1).Node = new (pool) AST::VariableDeclarationList(sym(1).VariableDeclarationList, sym(3).VariableDeclaration); } break; -case 287: { +case 289: { AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 288: { +case 290: { AST::VariableDeclaration *node = new (pool) AST::VariableDeclaration(stringRef(1), sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 289: { +case 291: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 290: { +case 292: { sym(1).Node = 0; } break; -case 292: { +case 294: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 293: { +case 295: { sym(1).Node = 0; } break; -case 295: { +case 297: { AST::EmptyStatement *node = new (pool) AST::EmptyStatement(); node->semicolonToken = loc(1); sym(1).Node = node; } break; -case 297: { +case 299: { AST::ExpressionStatement *node = new (pool) AST::ExpressionStatement(sym(1).Expression); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 298: { +case 300: { AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement, sym(7).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1483,7 +1496,7 @@ case 298: { sym(1).Node = node; } break; -case 299: { +case 301: { AST::IfStatement *node = new (pool) AST::IfStatement(sym(3).Expression, sym(5).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1491,7 +1504,7 @@ case 299: { sym(1).Node = node; } break; -case 302: { +case 304: { AST::DoWhileStatement *node = new (pool) AST::DoWhileStatement(sym(2).Statement, sym(5).Expression); node->doToken = loc(1); node->whileToken = loc(3); @@ -1501,7 +1514,7 @@ case 302: { sym(1).Node = node; } break; -case 303: { +case 305: { AST::WhileStatement *node = new (pool) AST::WhileStatement(sym(3).Expression, sym(5).Statement); node->whileToken = loc(1); node->lparenToken = loc(2); @@ -1509,7 +1522,7 @@ case 303: { sym(1).Node = node; } break; -case 304: { +case 306: { AST::ForStatement *node = new (pool) AST::ForStatement(sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); node->forToken = loc(1); @@ -1520,7 +1533,7 @@ case 304: { sym(1).Node = node; } break; -case 305: { +case 307: { AST::LocalForStatement *node = new (pool) AST::LocalForStatement( sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); @@ -1533,7 +1546,7 @@ case 305: { sym(1).Node = node; } break; -case 306: { +case 308: { AST:: ForEachStatement *node = new (pool) AST::ForEachStatement(sym(3).Expression, sym(5).Expression, sym(7).Statement); node->forToken = loc(1); @@ -1543,7 +1556,7 @@ case 306: { sym(1).Node = node; } break; -case 307: { +case 309: { AST::LocalForEachStatement *node = new (pool) AST::LocalForEachStatement( sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); node->forToken = loc(1); @@ -1554,14 +1567,14 @@ case 307: { sym(1).Node = node; } break; -case 309: { +case 311: { AST::ContinueStatement *node = new (pool) AST::ContinueStatement(); node->continueToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 311: { +case 313: { AST::ContinueStatement *node = new (pool) AST::ContinueStatement(stringRef(2)); node->continueToken = loc(1); node->identifierToken = loc(2); @@ -1569,14 +1582,14 @@ case 311: { sym(1).Node = node; } break; -case 313: { +case 315: { AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef()); node->breakToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 315: { +case 317: { AST::BreakStatement *node = new (pool) AST::BreakStatement(stringRef(2)); node->breakToken = loc(1); node->identifierToken = loc(2); @@ -1584,14 +1597,14 @@ case 315: { sym(1).Node = node; } break; -case 317: { +case 319: { AST::ReturnStatement *node = new (pool) AST::ReturnStatement(sym(2).Expression); node->returnToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 318: { +case 320: { AST::WithStatement *node = new (pool) AST::WithStatement(sym(3).Expression, sym(5).Statement); node->withToken = loc(1); node->lparenToken = loc(2); @@ -1599,7 +1612,7 @@ case 318: { sym(1).Node = node; } break; -case 319: { +case 321: { AST::SwitchStatement *node = new (pool) AST::SwitchStatement(sym(3).Expression, sym(5).CaseBlock); node->switchToken = loc(1); node->lparenToken = loc(2); @@ -1607,83 +1620,83 @@ case 319: { sym(1).Node = node; } break; -case 320: { +case 322: { AST::CaseBlock *node = new (pool) AST::CaseBlock(sym(2).CaseClauses); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 321: { +case 323: { 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 322: { +case 324: { sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClause); } break; -case 323: { +case 325: { sym(1).Node = new (pool) AST::CaseClauses(sym(1).CaseClauses, sym(2).CaseClause); } break; -case 324: { +case 326: { sym(1).Node = 0; } break; -case 325: { +case 327: { sym(1).Node = sym(1).CaseClauses->finish (); } break; -case 326: { +case 328: { 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 327: { +case 329: { AST::DefaultClause *node = new (pool) AST::DefaultClause(sym(3).StatementList); node->defaultToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 328: { +case 330: { 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 330: { +case 332: { AST::ThrowStatement *node = new (pool) AST::ThrowStatement(sym(2).Expression); node->throwToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 331: { +case 333: { AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Catch); node->tryToken = loc(1); sym(1).Node = node; } break; -case 332: { +case 334: { AST::TryStatement *node = new (pool) AST::TryStatement(sym(2).Statement, sym(3).Finally); node->tryToken = loc(1); sym(1).Node = node; } break; -case 333: { +case 335: { 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 334: { +case 336: { AST::Catch *node = new (pool) AST::Catch(stringRef(3), sym(5).Block); node->catchToken = loc(1); node->lparenToken = loc(2); @@ -1692,20 +1705,20 @@ case 334: { sym(1).Node = node; } break; -case 335: { +case 337: { AST::Finally *node = new (pool) AST::Finally(sym(2).Block); node->finallyToken = loc(1); sym(1).Node = node; } break; -case 337: { +case 339: { AST::DebuggerStatement *node = new (pool) AST::DebuggerStatement(); node->debuggerToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 339: { +case 341: { AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); node->identifierToken = loc(2); @@ -1716,7 +1729,7 @@ case 339: { sym(1).Node = node; } break; -case 340: { +case 342: { AST::FunctionExpression *node = new (pool) AST::FunctionExpression(stringRef(2), sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); if (! stringRef(2).isNull()) @@ -1728,7 +1741,7 @@ case 340: { sym(1).Node = node; } break; -case 341: { +case 343: { AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).FunctionBody); node->functionToken = loc(1); node->lparenToken = loc(2); @@ -1738,56 +1751,56 @@ case 341: { sym(1).Node = node; } break; -case 342: { +case 344: { AST::FormalParameterList *node = new (pool) AST::FormalParameterList(stringRef(1)); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 343: { +case 345: { 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 344: { +case 346: { sym(1).Node = 0; } break; -case 345: { +case 347: { sym(1).Node = sym(1).FormalParameterList->finish (); } break; -case 346: { +case 348: { sym(1).Node = 0; } break; -case 348: { +case 350: { sym(1).Node = new (pool) AST::FunctionBody(sym(1).SourceElements->finish ()); } break; -case 350: { +case 352: { sym(1).Node = new (pool) AST::Program(sym(1).SourceElements->finish ()); } break; -case 351: { +case 353: { sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElement); } break; -case 352: { +case 354: { sym(1).Node = new (pool) AST::SourceElements(sym(1).SourceElements, sym(2).SourceElement); } break; -case 353: { +case 355: { sym(1).Node = new (pool) AST::StatementSourceElement(sym(1).Statement); } break; -case 354: { +case 356: { sym(1).Node = new (pool) AST::FunctionSourceElement(sym(1).FunctionDeclaration); } break; -case 355: { +case 357: { sym(1).Node = 0; } break; diff --git a/src/qml/parser/qqmljsparser_p.h b/src/qml/parser/qqmljsparser_p.h index 00ffb6aca3..7533750a53 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 88 +#define J_SCRIPT_REGEXPLITERAL_RULE1 90 -#define J_SCRIPT_REGEXPLITERAL_RULE2 89 +#define J_SCRIPT_REGEXPLITERAL_RULE2 91 QT_QML_END_NAMESPACE diff --git a/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml new file mode 100644 index 0000000000..bb28e22110 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/QtObjectWithChildren.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + default property list myChildren; +} diff --git a/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml new file mode 100644 index 0000000000..d68ffd2979 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/defaultListProperty.qml @@ -0,0 +1,6 @@ +import QtQml 2.0 + +QtObjectWithChildren { + QtObject { + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index ad06946b0b..658b4f5852 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -254,6 +254,8 @@ private slots: void arrayBuffer_data(); void arrayBuffer(); + void defaultListProperty(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4233,6 +4235,13 @@ void tst_qqmllanguage::arrayBuffer() QCOMPARE(object->property("ok").toBool(), true); } +void tst_qqmllanguage::defaultListProperty() +{ + QQmlComponent component(&engine, testFileUrl("defaultListProperty.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From ae5c13acb12b66929032824b651177db341f6d57 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 24 Nov 2016 09:05:54 +0100 Subject: Fix OS platform label documentation Task-number: QTBUG-49033 Change-Id: I2e8157f8d2b40299799cbf31b424060ff89ab75a Reviewed-by: Oliver Wolff --- src/qml/qml/qqmlengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 7877ee7e21..2a439bde98 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -443,7 +443,7 @@ The following functions are also on the Qt object. \li \c "osx" - \macos \li \c "unix" - Other Unix-based OS \li \c "windows" - Windows - \li \c "winrt" - Windows Runtime + \li \c "winrt" - WinRT / UWP \li \c "winphone" - Windows Phone \endlist \endtable -- cgit v1.2.3 From 4b22e2093f08fb66107af4dbd8138cf9526c5786 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Nov 2016 13:15:49 +0100 Subject: qmlimportscanner: Output application name in generic error messages This makes it easier to spot issues in build logs. Amends change a23bcdf91971510b79c541fdff4a9467ead08751. Change-Id: I68e440c2ce79504fb5f5fa08392a91d39e631e25 Reviewed-by: Andy Shaw --- tools/qmlimportscanner/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index 0f8eca34e1..1e5f7a9921 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -519,7 +519,8 @@ int main(int argc, char *argv[]) std::cerr << "-importPath requires an argument\n"; argReceiver = &qmlImportPaths; } else { - std::cerr << "Invalid argument: \"" << qPrintable(arg) << "\"\n"; + std::cerr << qPrintable(appName) << ": Invalid argument: \"" + << qPrintable(arg) << "\"\n"; return 1; } @@ -529,7 +530,8 @@ int main(int argc, char *argv[]) break; ++i; if (!QFile::exists(arg)) { - std::cerr << "No such file or directory: \"" << qPrintable(arg) << "\"\n"; + std::cerr << qPrintable(appName) << ": No such file or directory: \"" + << qPrintable(arg) << "\"\n"; return 1; } else { *argReceiver += arg; -- cgit v1.2.3 From 5e6bf607ee1e466eebabb7b8114c9f5e8fc40a9e Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 23 Nov 2016 12:55:30 +0100 Subject: V4: check for exceptions after convertThisToObject The method_convertThisToObject method was invalidly tagged as not needing exception checks. As a side-effect method_pushCatchScope and method_popScope are now correctly tagged with a NoThrowEngine. Change-Id: I11d987e62136216a29eadcbd641546311030058f Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4runtime.cpp | 4 ++-- src/qml/jsruntime/qv4runtimeapi_p.h | 9 ++------- src/qml/jsruntime/qv4vme_moth.cpp | 4 ++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 0a71f0000a..2026ecdfde 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1259,7 +1259,7 @@ ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine) * * Instead the push/pop pair acts as a non local scope. */ -void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine) +void Runtime::method_pushWithScope(const Value &o, NoThrowEngine *engine) { engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine))); Q_ASSERT(engine->jsStackTop == engine->currentContext + 2); @@ -1272,7 +1272,7 @@ void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameI Q_ASSERT(engine->jsStackTop == engine->currentContext + 2); } -void Runtime::method_popScope(ExecutionEngine *engine) +void Runtime::method_popScope(NoThrowEngine *engine) { Q_ASSERT(engine->jsStackTop == engine->currentContext + 2); engine->popContext(); diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index 040a545b83..e06a3f5ec2 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -63,11 +63,6 @@ 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 }; @@ -244,9 +239,9 @@ struct Q_QML_PRIVATE_EXPORT Runtime { // exceptions & scopes RUNTIME_METHOD(void, throwException, (ExecutionEngine *engine, const Value &value)); RUNTIME_METHOD(ReturnedValue, unwindException, (ExecutionEngine *engine)); - RUNTIME_METHOD(void, pushWithScope, (const Value &o, ExecutionEngine *engine)); + RUNTIME_METHOD(void, pushWithScope, (const Value &o, NoThrowEngine *engine)); RUNTIME_METHOD(void, pushCatchScope, (NoThrowEngine *engine, int exceptionVarNameIndex)); - RUNTIME_METHOD(void, popScope, (ExecutionEngine *engine)); + RUNTIME_METHOD(void, popScope, (NoThrowEngine *engine)); // closures RUNTIME_METHOD(ReturnedValue, closure, (ExecutionEngine *engine, int functionId)); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 0f7f6b1f75..b19c36a5bd 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -662,13 +662,13 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(CallBuiltinPushCatchScope) MOTH_BEGIN_INSTR(CallBuiltinPushScope) - engine->runtime.pushWithScope(VALUE(instr.arg), engine); + engine->runtime.pushWithScope(VALUE(instr.arg), static_cast(engine)); context = engine->currentContext; CHECK_EXCEPTION; MOTH_END_INSTR(CallBuiltinPushScope) MOTH_BEGIN_INSTR(CallBuiltinPopScope) - engine->runtime.popScope(engine); + engine->runtime.popScope(static_cast(engine)); context = engine->currentContext; MOTH_END_INSTR(CallBuiltinPopScope) -- 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 9fdab4a3619f457f66716c74ea73355453557e52 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 25 Nov 2016 13:11:32 +0100 Subject: D3D12: Fix RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH Change-Id: I531d53c81d5ab19bba22f883bc802ecc8d02590d Task-number: QTBUG-57234 Reviewed-by: Andy Nichols --- src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp index 44f79ebea7..caf64ebb8b 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp @@ -1052,8 +1052,11 @@ ID3D12Resource *QSGD3D12EnginePrivate::createColorBuffer(D3D12_CPU_DESCRIPTOR_HA rtDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; ID3D12Resource *resource = nullptr; + const D3D12_RESOURCE_STATES initialState = samples <= 1 + ? D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE + : D3D12_RESOURCE_STATE_RENDER_TARGET; if (FAILED(device->CreateCommittedResource(&heapProp, D3D12_HEAP_FLAG_NONE, &rtDesc, - D3D12_RESOURCE_STATE_RENDER_TARGET, &clearValue, IID_PPV_ARGS(&resource)))) { + initialState, &clearValue, IID_PPV_ARGS(&resource)))) { qWarning("Failed to create offscreen render target of size %dx%d", size.width(), size.height()); return nullptr; } -- cgit v1.2.3 From 8bf579d8d4feb13ca8651e98dd762b28483abe9e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 22 Oct 2016 05:24:20 +0200 Subject: Cleanup of builtin JS helpers for qmljs Replace the hand-written gc and print functions with the print and gc functions also used in Qml and QJSEngine. And while we're at it, this also adds the console object. Change-Id: Ia3a0ff24936b7ed5149cb689838b987f9178131e Reviewed-by: Erik Verbruggen Reviewed-by: Mitch Curtis --- src/qml/jsruntime/qv4engine_p.h | 2 +- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 +- tools/qmljs/qmljs.cpp | 57 ++------------------------------- 3 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index a46066bde4..25d6fc1970 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -147,7 +147,7 @@ public: QQmlEngine *qmlEngine() const; #else // !V4_BOOTSTRAP QJSEngine *jsEngine() const { return v8Engine->publicEngine(); } - QQmlEngine *qmlEngine() const { return v8Engine->engine(); } + QQmlEngine *qmlEngine() const { return v8Engine ? v8Engine->engine() : nullptr; } #endif // V4_BOOTSTRAP QV8Engine *v8Engine; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 7602a92582..f428e377d7 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -166,7 +166,7 @@ struct ConsoleObject : Object }; -struct GlobalExtensions { +struct Q_QML_PRIVATE_EXPORT GlobalExtensions { static void init(Object *globalObject, QJSEngine::Extensions extensions); #ifndef QT_NO_TRANSLATION diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp index b0079dcf49..dd1898a88a 100644 --- a/tools/qmljs/qmljs.cpp +++ b/tools/qmljs/qmljs.cpp @@ -42,6 +42,7 @@ #include "private/qv4context_p.h" #include "private/qv4script_p.h" #include "private/qv4string_p.h" +#include "private/qqmlbuiltinfunctions_p.h" #ifdef V4_ENABLE_JIT # include "private/qv4isel_masm_p.h" @@ -60,57 +61,6 @@ QT_REQUIRE_CONFIG(qml_interpreter); #include -namespace builtins { - -using namespace QV4; - -struct Print: FunctionObject -{ - struct Data : Heap::FunctionObject { - void init(ExecutionContext *scope) - { - Heap::FunctionObject::init(scope, QStringLiteral("print")); - } - }; - V4_OBJECT(FunctionObject) - - static void call(const Managed *, Scope &scope, CallData *callData) - { - for (int i = 0; i < callData->argc; ++i) { - QString s = callData->args[i].toQStringNoThrow(); - if (i) - std::cout << ' '; - std::cout << qPrintable(s); - } - std::cout << std::endl; - scope.result = Encode::undefined(); - } -}; - -DEFINE_OBJECT_VTABLE(Print); - -struct GC: public FunctionObject -{ - struct Data : Heap::FunctionObject { - void init(ExecutionContext *scope) - { - Heap::FunctionObject::init(scope, QStringLiteral("gc")); - } - - }; - V4_OBJECT(FunctionObject) - - static void call(const Managed *m, Scope &scope, CallData *) - { - static_cast(m)->engine()->memoryManager->runGC(); - scope.result = Encode::undefined(); - } -}; - -DEFINE_OBJECT_VTABLE(GC); - -} // builtins - static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exception, const QV4::StackTrace &trace) { QV4::Scope scope(ctx); @@ -200,10 +150,7 @@ int main(int argc, char *argv[]) QV4::Scope scope(&vm); QV4::ScopedContext ctx(scope, vm.rootContext()); - QV4::ScopedObject print(scope, vm.memoryManager->allocObject(vm.rootContext())); - vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print); - QV4::ScopedObject gc(scope, vm.memoryManager->allocObject(ctx)); - vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc); + QV4::GlobalExtensions::init(vm.globalObject, QJSEngine::ConsoleExtension | QJSEngine::GarbageCollectionExtension); for (const QString &fn : qAsConst(args)) { QFile file(fn); -- 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 485e9fdf486446fb13012debe10137739b96d8ca Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Wed, 10 Aug 2016 21:41:19 -0700 Subject: Add touch event support to qmltest [ChangeLog][QuickTest] Add support for simulating touch events from TestCase. Task-number: QTBUG-23083 Change-Id: Ic045e00a91b8270b6f08d398323e06b576615e79 Reviewed-by: Shawn Rutledge --- src/imports/testlib/TestCase.qml | 103 ++++++++++++++++ src/imports/testlib/main.cpp | 1 + src/imports/testlib/toucheventsequence.qdoc | 110 +++++++++++++++++ src/qmltest/qmltest.pro | 2 +- src/qmltest/quicktestevent.cpp | 93 ++++++++++++++ src/qmltest/quicktestevent_p.h | 24 ++++ tests/auto/qmltest/events/tst_touch.qml | 182 ++++++++++++++++++++++++++++ 7 files changed, 514 insertions(+), 1 deletion(-) create mode 100644 src/imports/testlib/toucheventsequence.qdoc create mode 100644 tests/auto/qmltest/events/tst_touch.qml diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index d22ec7c44f..a874fd4fe2 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -1317,6 +1317,109 @@ Item { qtest_fail("window not shown", 2) } + /*! + \qmlmethod TouchEventSequence TestCase::touchEvent(object item) + + \since 5.9 + + Begins a sequence of touch events through a simulated QTouchDevice::TouchScreen. + Events are delivered to the window containing \a item. + + The returned object is used to enumerate events to be delivered through a single + QTouchEvent. Touches are delivered to the window containing the TestCase unless + otherwise specified. + + \code + Rectangle { + width: 640; height: 480 + + MultiPointTouchArea { + id: area + anchors.fill: parent + + property bool touched: false + + onPressed: touched = true + } + + TestCase { + name: "ItemTests" + when: area.pressed + id: test1 + + function test_touch() { + var touch = touchEvent(area); + touch.press(0, area, 10, 10); + touch.commit(); + verify(area.touched); + } + } + } + \endcode + + \sa TouchEventSequence::press(), TouchEventSequence::move(), TouchEventSequence::release(), TouchEventSequence::stationary(), TouchEventSequence::commit(), QTouchDevice::TouchScreen + */ + + function touchEvent(item) { + if (!item) + qtest_fail("No item given to touchEvent", 1) + + return { + _defaultItem: item, + _sequence: qtest_events.touchEvent(item), + + press: function (id, target, x, y) { + if (!target) + target = this._defaultItem; + if (id === undefined) + qtest_fail("No id given to TouchEventSequence::press", 1); + if (x === undefined) + x = target.width / 2; + if (y === undefined) + y = target.height / 2; + this._sequence.press(id, target, x, y); + return this; + }, + + move: function (id, target, x, y) { + if (!target) + target = this._defaultItem; + if (id === undefined) + qtest_fail("No id given to TouchEventSequence::move", 1); + if (x === undefined) + x = target.width / 2; + if (y === undefined) + y = target.height / 2; + this._sequence.move(id, target, x, y); + return this; + }, + + stationary: function (id) { + if (id === undefined) + qtest_fail("No id given to TouchEventSequence::stationary", 1); + this._sequence.stationary(id); + return this; + }, + + release: function (id, target, x, y) { + if (!target) + target = this._defaultItem; + if (id === undefined) + qtest_fail("No id given to TouchEventSequence::release", 1); + if (x === undefined) + x = target.width / 2; + if (y === undefined) + y = target.height / 2; + this._sequence.release(id, target, x, y); + return this; + }, + + commit: function () { + this._sequence.commit(); + return this; + } + }; + } // Functions that can be overridden in subclasses for init/cleanup duties. /*! diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 4e2bd919e9..3c28000e35 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -158,6 +158,7 @@ public: qmlRegisterType(uri,1,1,"TestResult"); qmlRegisterType(uri,1,0,"TestEvent"); qmlRegisterType(uri,1,0,"TestUtil"); + qmlRegisterType(); } }; diff --git a/src/imports/testlib/toucheventsequence.qdoc b/src/imports/testlib/toucheventsequence.qdoc new file mode 100644 index 0000000000..f85a1cd4f9 --- /dev/null +++ b/src/imports/testlib/toucheventsequence.qdoc @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** 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$ +** +****************************************************************************/ + +/*! + \qmltype TouchEventSequence + \inqmlmodule QtTest + \ingroup qtquicktest + \brief TouchEventSequence is used to build and dispatch touch events + for testing. + + \since 5.9 + + A TouchEventSequence is created by calling \l [QML] {TestCase::touchEvent()}{TestCase.touchEvent()}. + The type can not be directly instantiated. Each method provided by the type returns + the same object, allowing chained calls. + + For example: + \code + touchEvent(item).press(0).commit(); + \endcode + is equivalent to: + \code + var sequence = touchEvent(item); + sequence.press(0); + sequence.commit(); + \endcode + + Events are delivered to the window which contains the item specified in touchEvent. + + \sa TestCase::touchEvent(), QTest::QTouchEventSequence +*/ + +/*! + \qmlmethod TouchEventSequence TouchEventSequence::press(int touchId, object item, real x = item.width / 2, real y = item.height / 2) + + Creates a new point identified as \a touchId, at the point indicated by \a x and \a y relative to \a item. + Further use of the same touch point should maintain the same touchId. + + Item defaults to the value provided via touchEvent(). + X and y default to the midpoint of the item. +*/ + +/*! + \qmlmethod TouchEventSequence TouchEventSequence::move(int touchId, object item, real x = item.width / 2, real y = item.height / 2) + + Moves \a touchId to the point indicated by \a x and \a y relative to \a item. + + Item defaults to the value provided via touchEvent(). + X and y default to the midpoint of the item. +*/ + +/*! + \qmlmethod TouchEventSequence TouchEventSequence::release(int touchId, object item, real x = item.width / 2, real y = item.height / 2) + + Removes \a touchId at the point indicated by \a x and \a y relative to \a item. + + Item defaults to the value provided via touchEvent(). + X and y default to the midpoint of the item. +*/ + +/*! + \qmlmethod TouchEventSequence TouchEventSequence::stationary(int touchId) + + Indicates that \a touchId is present but otherwise unchanged from prior events. +*/ + +/*! + \qmlmethod TouchEventSequence TouchEventSequence::commit() + + Sends the touch event composed by prior use of press(), move(), release(), and stationary(). + Following commit's return, the TouchEventSequence can be used to compose a new event. + + \code + var sequence = touchEvent(target); + // Touch the middle of target with 1 point + sequence.press(1); + sequence.commit(); + + // Begin a new event + // Move the point to target's upper left corner + sequence.move(1, target, 0, 0); + sequence.commit(); + \endcode + + Commit is automatically invoked when the TouchEventSequence object is destroyed. +*/ diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index 9852861334..d13e162ff4 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -2,7 +2,7 @@ TARGET = QtQuickTest DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_FOREACH QT = core testlib-private -QT_PRIVATE = quick qml-private gui core-private +QT_PRIVATE = quick qml-private gui core-private gui-private # Testlib is only a private dependency, which results in our users not # inheriting testlibs's MODULE_CONFIG transitively. Make it explicit. diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 26f0521cdf..4b8ade761f 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -42,6 +42,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -347,4 +348,96 @@ QWindow *QuickTestEvent::activeWindow() return eventWindow(); } +QQuickTouchEventSequence::QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item) + : QObject(testEvent) + , m_sequence(QTest::touchEvent(testEvent->eventWindow(item), testEvent->touchDevice())) + , m_testEvent(testEvent) +{ +} + +QObject *QQuickTouchEventSequence::press(int touchId, QObject *item, qreal x, qreal y) +{ + QWindow *view = m_testEvent->eventWindow(item); + if (view) { + QPointF pos(x, y); + QQuickItem *quickItem = qobject_cast(item); + if (quickItem) { + pos = quickItem->mapToScene(pos); + } + m_sequence.press(touchId, pos.toPoint(), view); + } + return this; +} + +QObject *QQuickTouchEventSequence::move(int touchId, QObject *item, qreal x, qreal y) +{ + QWindow *view = m_testEvent->eventWindow(item); + if (view) { + QPointF pos(x, y); + QQuickItem *quickItem = qobject_cast(item); + if (quickItem) { + pos = quickItem->mapToScene(pos); + } + m_sequence.move(touchId, pos.toPoint(), view); + } + return this; +} + +QObject *QQuickTouchEventSequence::release(int touchId, QObject *item, qreal x, qreal y) +{ + QWindow *view = m_testEvent->eventWindow(item); + if (view) { + QPointF pos(x, y); + QQuickItem *quickItem = qobject_cast(item); + if (quickItem) { + pos = quickItem->mapToScene(pos); + } + m_sequence.release(touchId, pos.toPoint(), view); + } + return this; +} + +QObject *QQuickTouchEventSequence::stationary(int touchId) +{ + m_sequence.stationary(touchId); + return this; +} + +QObject *QQuickTouchEventSequence::commit() +{ + m_sequence.commit(); + return this; +} + +/*! + Return a simulated touchscreen, creating one if necessary + + \internal +*/ + +QTouchDevice *QuickTestEvent::touchDevice() +{ + static QTouchDevice *device(nullptr); + + if (!device) { + device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + } + return device; +} + +/*! + Creates a new QQuickTouchEventSequence. + + If valid, \a item determines the QWindow that touch events are sent to. + Test code should use touchEvent() from the QML TestCase type. + + \internal +*/ +QQuickTouchEventSequence *QuickTestEvent::touchEvent(QObject *item) +{ + return new QQuickTouchEventSequence(this, item); +} + QT_END_NAMESPACE diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h index 1adf8f3317..c37d03ad0f 100644 --- a/src/qmltest/quicktestevent_p.h +++ b/src/qmltest/quicktestevent_p.h @@ -54,8 +54,28 @@ #include #include #include +#include + QT_BEGIN_NAMESPACE +class QuickTestEvent; +class Q_QUICK_TEST_EXPORT QQuickTouchEventSequence : public QObject +{ + Q_OBJECT +public: + explicit QQuickTouchEventSequence(QuickTestEvent *testEvent, QObject *item = nullptr); +public slots: + QObject* press(int touchId, QObject *item, qreal x, qreal y); + QObject* move(int touchId, QObject *item, qreal x, qreal y); + QObject* release(int touchId, QObject *item, qreal x, qreal y); + QObject* stationary(int touchId); + QObject* commit(); + +private: + QTest::QTouchEventSequence m_sequence; + QuickTestEvent * const m_testEvent; +}; + class Q_QUICK_TEST_EXPORT QuickTestEvent : public QObject { Q_OBJECT @@ -91,9 +111,13 @@ public Q_SLOTS: int modifiers, int xDelta, int yDelta, int delay); #endif + QQuickTouchEventSequence *touchEvent(QObject *item = nullptr); private: QWindow *eventWindow(QObject *item = 0); QWindow *activeWindow(); + QTouchDevice *touchDevice(); + + friend class QQuickTouchEventSequence; }; QT_END_NAMESPACE diff --git a/tests/auto/qmltest/events/tst_touch.qml b/tests/auto/qmltest/events/tst_touch.qml new file mode 100644 index 0000000000..5b209a6d0b --- /dev/null +++ b/tests/auto/qmltest/events/tst_touch.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Jeremy Katz +** 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 QtQuick.Window 2.0 +import QtTest 1.0 + +MultiPointTouchArea { + id: touchArea + width: 100 + height: 100 + + SignalSpy { + id: touchUpdatedSpy + target: touchArea + signalName: "touchUpdated" + } + + SignalSpy { + id: interiorSpy + target: interior + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: interior + width: parent.width / 2 + height: parent.height + anchors.right: parent.right + } + + Window { + width: 100; height: 100 + + SignalSpy { + id: subWindowSpy + target: subWindowTouchArea + signalName: "touchUpdated" + } + + MultiPointTouchArea { + id: subWindowTouchArea + anchors.fill: parent + } + } + + TestCase { + when: windowShown + name: "touch" + + function comparePoint(point, id, x, y) { + var retval = true; + var pointId = point.pointId & 0xFFFFFF; //strip device identifier + if (pointId !== id) { + warn("Unexpected pointId: " + pointId + ". Expected " + id); + retval = false; + } + if (point.x !== x) { + warn("Unexpected x: " + point.x + ". Expected " + x); + retval = false; + } + if (point.y !== y) { + warn("Unexpected y: " + point.y + ". Expected " + y); + retval = false; + } + return retval; + } + + function cleanup() { + touchUpdatedSpy.clear(); + interiorSpy.clear(); + subWindowSpy.clear(); + } + + function test_secondWindow() { + var first = 1; + var sequence = touchEvent(subWindowTouchArea); + sequence.press(first, 0, 0, 0); + sequence.commit(); + sequence.release(first, subWindowTouchArea, 0, 0) + sequence.commit(); + compare(subWindowSpy.count, 2); + var touchPoint = subWindowSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, 0, 0)); + } + + function initTestCase() { + waitForRendering(touchArea) // when: windowShown may be insufficient + } + + function test_childMapping() { + var sequence = touchEvent(touchArea); + + var first = 1; + // Test mapping touches to a child item + sequence.press(first, interior, 0, 0); + sequence.commit(); + + // Map touches to the parent at the same point + sequence.move(first, touchArea, interior.x, interior.y); + sequence.commit(); + + sequence.release(first, touchArea, interior.x, interior.y); + sequence.commit(); + + compare(interiorSpy.count, 3); + verify(comparePoint(interiorSpy.signalArguments[0][0][0], first, 0, 0)); + verify(comparePoint(interiorSpy.signalArguments[1][0][0], first, 0, 0)); + } + + function test_fullSequence() { + var sequence = touchEvent(touchArea); + verify(sequence); + + var first = 1; + var second = 2; + + sequence.press(first, null, 0, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 1); + var touchPoints = touchUpdatedSpy.signalArguments[0][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], first, 0, 0)); + + sequence.stationary(first); + sequence.press(second, null, 1, 0); + sequence.commit(); + compare(touchUpdatedSpy.count, 2); + touchPoints = touchUpdatedSpy.signalArguments[1][0]; + compare(touchPoints.length, 2); + verify(comparePoint(touchPoints[0], first, 0, 0)); + verify(comparePoint(touchPoints[1], second, 1, 0)); + + sequence.release(first); + sequence.move(second, null, 1, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 3); + touchPoints = touchUpdatedSpy.signalArguments[2][0]; + compare(touchPoints.length, 1); + verify(comparePoint(touchPoints[0], second, 1, 1)); + + sequence.release(second, null, 0, 1); + sequence.commit(); + compare(touchUpdatedSpy.count, 4); + touchPoints = touchUpdatedSpy.signalArguments[3][0]; + compare(touchPoints.length, 0); + } + + function test_simpleChain() { + var first = 1; + touchEvent(touchArea).press(first).commit().release(first).commit(); + compare(touchUpdatedSpy.count, 2); + var touchPoint = touchUpdatedSpy.signalArguments[0][0][0]; + verify(comparePoint(touchPoint, first, touchArea.width / 2, touchArea.height / 2)); + } + } +} -- 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 3dd96630a2823ff9723a399c84303f565abce455 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 5 Dec 2016 00:03:04 +0300 Subject: headers: Add missing override and remove redundant virtual Change-Id: Ifa816ebcd79372afca42dbd0dc0ecde006bb688a Reviewed-by: Anton Kudryavtsev Reviewed-by: Simon Hausmann --- .../qmldbg_debugger/qqmldebuggerservicefactory.h | 2 +- .../qmltooling/qmldbg_debugger/qv4debugjob.h | 2 +- .../qmltooling/qmldbg_inspector/highlight.h | 4 +- .../qmldbg_inspector/qqmlinspectorservicefactory.h | 2 +- .../qmldbg_inspector/qquickwindowinspector.h | 2 +- .../qmldbg_local/qlocalclientconnectionfactory.h | 2 +- .../qmldbg_messages/qdebugmessageservice.h | 4 +- .../qmldbg_messages/qdebugmessageservicefactory.h | 2 +- .../qmldbg_native/qqmlnativedebugconnector.h | 2 +- .../qqmlnativedebugservicefactory.h | 2 +- .../qmldbg_profiler/qqmlprofilerservicefactory.h | 2 +- .../qquickprofileradapterfactory.h | 2 +- .../qmldbg_server/qqmldebugserverfactory.h | 2 +- .../qmldbg_tcp/qtcpserverconnectionfactory.h | 2 +- src/qml/animations/qabstractanimationjob_p.h | 6 +- .../animations/qcontinuinganimationgroupjob_p.h | 12 +-- src/qml/animations/qpauseanimationjob_p.h | 6 +- .../animations/qsequentialanimationgroupjob_p.h | 16 +-- src/qml/jit/qv4isel_masm_p.h | 118 ++++++++++----------- src/qml/parser/qqmljsast_p.h | 4 +- src/qml/qml/qqmlcontext_p.h | 2 +- src/qml/qml/qqmlopenmetaobject_p.h | 2 +- src/qml/qml/qqmltypeloader_p.h | 4 +- src/qml/qml/qqmlvmemetaobject_p.h | 2 +- src/qml/types/qqmldelegatemodel_p_p.h | 2 +- src/qml/util/qqmladaptormodel_p.h | 2 +- src/qmldebug/qqmlenginecontrolclient_p.h | 2 +- src/qmldebug/qqmlprofilerclient_p.h | 2 +- src/quick/items/qquickdrag_p.h | 2 +- src/quick/scenegraph/qsgadaptationlayer_p.h | 10 +- src/quick/scenegraph/qsgbasicglyphnode_p.h | 14 +-- src/quick/scenegraph/qsgcontextplugin_p.h | 6 +- .../qsgdefaultdistancefieldglyphcache_p.h | 8 +- src/quick/scenegraph/qsgdefaultglyphnode_p_p.h | 16 +-- src/quick/scenegraph/qsgdistancefieldglyphnode_p.h | 18 ++-- .../scenegraph/qsgdistancefieldglyphnode_p_p.h | 34 +++--- src/quick/scenegraph/qsgthreadedrenderloop_p.h | 30 +++--- src/quick/scenegraph/qsgwindowsrenderloop_p.h | 26 ++--- src/quick/scenegraph/util/qsgsimplematerial.h | 6 +- src/quick/util/qquickstate_p_p.h | 2 +- tools/qmleasing/mainwindow.h | 6 +- tools/qmleasing/splineeditor.h | 10 +- tools/qmlprofiler/qmlprofilerclient.h | 26 ++--- 43 files changed, 213 insertions(+), 213 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h index 99d6679833..50eed2369c 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmldebuggerservicefactory.h @@ -49,7 +49,7 @@ class QQmlDebuggerServiceFactory : public QQmlDebugServiceFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmldebuggerservice.json") public: - QQmlDebugService *create(const QString &key); + QQmlDebugService *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h index aff2ea1b6c..b28adffae5 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h @@ -112,7 +112,7 @@ class ScopeJob: public CollectJob public: ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr); - void run(); + void run() override; bool wasSuccessful() const; }; diff --git a/src/plugins/qmltooling/qmldbg_inspector/highlight.h b/src/plugins/qmltooling/qmldbg_inspector/highlight.h index 2bf4fc1ad5..3f910e833b 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/highlight.h +++ b/src/plugins/qmltooling/qmldbg_inspector/highlight.h @@ -81,7 +81,7 @@ class SelectionHighlight : public Highlight public: SelectionHighlight(const QString &name, QQuickItem *item, QQuickItem *parent); - void paint(QPainter *painter); + void paint(QPainter *painter) override; void showName(const QPointF &displayPoint); private: @@ -104,7 +104,7 @@ public: setZ(1); // hover highlight on top of selection highlight } - void paint(QPainter *painter); + void paint(QPainter *painter) override; }; } // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h index 09e6a01f96..3214532c8d 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservicefactory.h @@ -64,7 +64,7 @@ class QQmlInspectorServiceFactory : public QQmlDebugServiceFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlinspectorservice.json") public: - QQmlDebugService *create(const QString &key); + QQmlDebugService *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h index b37a9face1..fc18f33ad3 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qquickwindowinspector.h @@ -78,7 +78,7 @@ public: void setEnabled(bool enabled); protected: - bool eventFilter(QObject *, QEvent *); + bool eventFilter(QObject *, QEvent *) override; private: QQuickItem *m_overlay; diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h index b884a1ec23..b64a1fff95 100644 --- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h +++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnectionfactory.h @@ -50,7 +50,7 @@ class QLocalClientConnectionFactory : public QQmlDebugServerConnectionFactory Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qlocalclientconnection.json") Q_INTERFACES(QQmlDebugServerConnectionFactory) public: - QQmlDebugServerConnection *create(const QString &key); + QQmlDebugServerConnection *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h index c25e756c2d..24fd27514b 100644 --- a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h +++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.h @@ -68,10 +68,10 @@ public: QDebugMessageServiceImpl(QObject *parent = 0); void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf); - void synchronizeTime(const QElapsedTimer &otherTimer); + void synchronizeTime(const QElapsedTimer &otherTimer) override; protected: - void stateChanged(State); + void stateChanged(State) override; private: friend class QQmlDebuggerServiceFactory; diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h index e09efd1304..0c5f0f5d0a 100644 --- a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h +++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservicefactory.h @@ -49,7 +49,7 @@ class QDebugMessageServiceFactory : public QQmlDebugServiceFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qdebugmessageservice.json") public: - QQmlDebugService *create(const QString &key); + QQmlDebugService *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h index 1184925e53..f8b7e1d527 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h @@ -78,7 +78,7 @@ class QQmlNativeDebugConnectorFactory : public QQmlDebugConnectorFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmlnativedebugconnector.json") public: - QQmlDebugConnector *create(const QString &key); + QQmlDebugConnector *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h index c4a8850bec..f2b2e4792e 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservicefactory.h @@ -49,7 +49,7 @@ class QQmlNativeDebugServiceFactory : public QQmlDebugServiceFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlnativedebugservice.json") public: - QQmlDebugService *create(const QString &key); + QQmlDebugService *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h index 772e53bde7..cdce4cd240 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservicefactory.h @@ -60,7 +60,7 @@ class QQmlProfilerServiceFactory : public QQmlDebugServiceFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlDebugServiceFactory_iid FILE "qqmlprofilerservice.json") public: - QQmlDebugService *create(const QString &key); + QQmlDebugService *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h index 489545b504..41b9875c03 100644 --- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h +++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapterfactory.h @@ -61,7 +61,7 @@ class QQuickProfilerAdapterFactory : public QQmlAbstractProfilerAdapterFactory Q_OBJECT Q_PLUGIN_METADATA(IID QQmlAbstractProfilerAdapterFactory_iid FILE "qquickprofileradapter.json") public: - QQmlAbstractProfilerAdapter *create(const QString &key); + QQmlAbstractProfilerAdapter *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h index fd71b03019..2debabaeb2 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserverfactory.h @@ -63,7 +63,7 @@ class QQmlDebugServerFactory : public QQmlDebugConnectorFactory // QQmlDebugServer is for connection plugins. Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmldebugserver.json") public: - QQmlDebugConnector *create(const QString &key); + QQmlDebugConnector *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h index 52d9f4b709..d3b0e00584 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnectionfactory.h @@ -50,7 +50,7 @@ class QTcpServerConnectionFactory : public QQmlDebugServerConnectionFactory Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qtcpserverconnection.json") Q_INTERFACES(QQmlDebugServerConnectionFactory) public: - QQmlDebugServerConnection *create(const QString &key); + QQmlDebugServerConnection *create(const QString &key) override; }; QT_END_NAMESPACE diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h index efc86a5823..95a39b1301 100644 --- a/src/qml/animations/qabstractanimationjob_p.h +++ b/src/qml/animations/qabstractanimationjob_p.h @@ -218,11 +218,11 @@ public: */ static void updateAnimationTimer(); - void restartAnimationTimer(); - void updateAnimationsTime(qint64 timeStep); + void restartAnimationTimer() override; + void updateAnimationsTime(qint64 timeStep) override; //useful for profiling/debugging - int runningAnimationCount() { return animations.count(); } + int runningAnimationCount() override { return animations.count(); } bool hasStartAnimationPending() const { return startAnimationPending; } diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h index f34a118cad..baf4ff1ae5 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob_p.h +++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h @@ -62,14 +62,14 @@ public: QContinuingAnimationGroupJob(); ~QContinuingAnimationGroupJob(); - int duration() const { return -1; } + int duration() const override { return -1; } protected: - void updateCurrentTime(int currentTime); - void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - void updateDirection(QAbstractAnimationJob::Direction direction); - void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); - void debugAnimation(QDebug d) const; + void updateCurrentTime(int currentTime) override; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; + void updateDirection(QAbstractAnimationJob::Direction direction) override; + void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override; + void debugAnimation(QDebug d) const override; }; QT_END_NAMESPACE diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h index 2967e1cf60..e228f46daa 100644 --- a/src/qml/animations/qpauseanimationjob_p.h +++ b/src/qml/animations/qpauseanimationjob_p.h @@ -62,12 +62,12 @@ public: explicit QPauseAnimationJob(int duration = 250); ~QPauseAnimationJob(); - int duration() const; + int duration() const override; void setDuration(int msecs); protected: - void updateCurrentTime(int); - void debugAnimation(QDebug d) const; + void updateCurrentTime(int) override; + void debugAnimation(QDebug d) const override; private: //definition diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h index bb481d1322..5fbafcb9ac 100644 --- a/src/qml/animations/qsequentialanimationgroupjob_p.h +++ b/src/qml/animations/qsequentialanimationgroupjob_p.h @@ -63,16 +63,16 @@ public: QSequentialAnimationGroupJob(); ~QSequentialAnimationGroupJob(); - int duration() const; + int duration() const override; QAbstractAnimationJob *currentAnimation() const { return m_currentAnimation; } protected: - void updateCurrentTime(int); - void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState); - void updateDirection(QAbstractAnimationJob::Direction direction); - void uncontrolledAnimationFinished(QAbstractAnimationJob *animation); - void debugAnimation(QDebug d) const; + void updateCurrentTime(int) override; + void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override; + void updateDirection(QAbstractAnimationJob::Direction direction) override; + void uncontrolledAnimationFinished(QAbstractAnimationJob *animation) override; + void debugAnimation(QDebug d) const override; private: struct AnimationIndex @@ -91,8 +91,8 @@ private: void setCurrentAnimation(QAbstractAnimationJob *anim, bool intermediate = false); void activateCurrentAnimation(bool intermediate = false); - void animationInserted(QAbstractAnimationJob *anim); - void animationRemoved(QAbstractAnimationJob *anim,QAbstractAnimationJob*,QAbstractAnimationJob*); + void animationInserted(QAbstractAnimationJob *anim) override; + void animationRemoved(QAbstractAnimationJob *anim, QAbstractAnimationJob *, QAbstractAnimationJob *) override; bool atEnd() const; diff --git a/src/qml/jit/qv4isel_masm_p.h b/src/qml/jit/qv4isel_masm_p.h index 5c693e0736..012745c5f2 100644 --- a/src/qml/jit/qv4isel_masm_p.h +++ b/src/qml/jit/qv4isel_masm_p.h @@ -80,61 +80,61 @@ public: InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator, EvalISelFactory *iselFactory); ~InstructionSelection(); - virtual void run(int functionIndex); + void run(int functionIndex) override; protected: - virtual QQmlRefPointer backendCompileStep(); - - virtual void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Expr *result); - virtual void callBuiltinTypeofQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::Expr *result); - virtual void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result); - virtual void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result); - virtual void callBuiltinTypeofName(const QString &name, IR::Expr *result); - virtual void callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result); - virtual void callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result); - virtual void callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result); - virtual void callBuiltinDeleteName(const QString &name, IR::Expr *result); - virtual void callBuiltinDeleteValue(IR::Expr *result); - virtual void callBuiltinThrow(IR::Expr *arg); - virtual void callBuiltinReThrow(); - virtual void callBuiltinUnwindException(IR::Expr *); - virtual void callBuiltinPushCatchScope(const QString &exceptionName); - virtual void callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result); - virtual void callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result); - virtual void callBuiltinPushWithScope(IR::Expr *arg); - virtual void callBuiltinPopScope(); - virtual void callBuiltinDeclareVar(bool deletable, const QString &name); - virtual void callBuiltinDefineArray(IR::Expr *result, IR::ExprList *args); - virtual void callBuiltinDefineObjectLiteral(IR::Expr *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray); - virtual void callBuiltinSetupArgumentObject(IR::Expr *result); - virtual void callBuiltinConvertThisToObject(); - virtual void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result); - virtual void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::ExprList *args, IR::Expr *result); - virtual void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result); - virtual void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Expr *result); - virtual void convertType(IR::Expr *source, IR::Expr *target); - virtual void loadThisObject(IR::Expr *temp); - virtual void loadQmlContext(IR::Expr *target); - virtual void loadQmlImportedScripts(IR::Expr *target); - virtual void loadQmlSingleton(const QString &name, IR::Expr *target); - virtual void loadConst(IR::Const *sourceConst, IR::Expr *target); - virtual void loadString(const QString &str, IR::Expr *target); - virtual void loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target); - virtual void getActivationProperty(const IR::Name *name, IR::Expr *target); - virtual void setActivationProperty(IR::Expr *source, const QString &targetName); - virtual void initClosure(IR::Closure *closure, IR::Expr *target); - virtual void getProperty(IR::Expr *base, const QString &name, IR::Expr *target); - virtual void getQmlContextProperty(IR::Expr *source, IR::Member::MemberKind kind, int index, bool captureRequired, IR::Expr *target); - virtual void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target); - virtual void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName); - virtual void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind kind, int propertyIndex); - virtual void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex); - virtual void getElement(IR::Expr *base, IR::Expr *index, IR::Expr *target); - virtual void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex); - virtual void copyValue(IR::Expr *source, IR::Expr *target); - virtual void swapValues(IR::Expr *source, IR::Expr *target); - virtual void unop(IR::AluOp oper, IR::Expr *sourceTemp, IR::Expr *target); - virtual void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target); + QQmlRefPointer backendCompileStep() override; + + void callBuiltinInvalid(IR::Name *func, IR::ExprList *args, IR::Expr *result) override; + void callBuiltinTypeofQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::Expr *result) override; + void callBuiltinTypeofMember(IR::Expr *base, const QString &name, IR::Expr *result) override; + void callBuiltinTypeofSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) override; + void callBuiltinTypeofName(const QString &name, IR::Expr *result) override; + void callBuiltinTypeofValue(IR::Expr *value, IR::Expr *result) override; + void callBuiltinDeleteMember(IR::Expr *base, const QString &name, IR::Expr *result) override; + void callBuiltinDeleteSubscript(IR::Expr *base, IR::Expr *index, IR::Expr *result) override; + void callBuiltinDeleteName(const QString &name, IR::Expr *result) override; + void callBuiltinDeleteValue(IR::Expr *result) override; + void callBuiltinThrow(IR::Expr *arg) override; + void callBuiltinReThrow() override; + void callBuiltinUnwindException(IR::Expr *) override; + void callBuiltinPushCatchScope(const QString &exceptionName) override; + void callBuiltinForeachIteratorObject(IR::Expr *arg, IR::Expr *result) override; + void callBuiltinForeachNextPropertyname(IR::Expr *arg, IR::Expr *result) override; + void callBuiltinPushWithScope(IR::Expr *arg) override; + void callBuiltinPopScope() override; + void callBuiltinDeclareVar(bool deletable, const QString &name) override; + void callBuiltinDefineArray(IR::Expr *result, IR::ExprList *args) override; + void callBuiltinDefineObjectLiteral(IR::Expr *result, int keyValuePairCount, IR::ExprList *keyValuePairs, IR::ExprList *arrayEntries, bool needSparseArray) override; + void callBuiltinSetupArgumentObject(IR::Expr *result) override; + void callBuiltinConvertThisToObject() override; + void callValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override; + void callQmlContextProperty(IR::Expr *base, IR::Member::MemberKind kind, int propertyIndex, IR::ExprList *args, IR::Expr *result) override; + void callProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr *result) override; + void callSubscript(IR::Expr *base, IR::Expr *index, IR::ExprList *args, IR::Expr *result) override; + void convertType(IR::Expr *source, IR::Expr *target) override; + void loadThisObject(IR::Expr *temp) override; + void loadQmlContext(IR::Expr *target) override; + void loadQmlImportedScripts(IR::Expr *target) override; + void loadQmlSingleton(const QString &name, IR::Expr *target) override; + void loadConst(IR::Const *sourceConst, IR::Expr *target) override; + void loadString(const QString &str, IR::Expr *target) override; + void loadRegexp(IR::RegExp *sourceRegexp, IR::Expr *target) override; + void getActivationProperty(const IR::Name *name, IR::Expr *target) override; + void setActivationProperty(IR::Expr *source, const QString &targetName) override; + void initClosure(IR::Closure *closure, IR::Expr *target) override; + void getProperty(IR::Expr *base, const QString &name, IR::Expr *target) override; + void getQmlContextProperty(IR::Expr *source, IR::Member::MemberKind kind, int index, bool captureRequired, IR::Expr *target) override; + void getQObjectProperty(IR::Expr *base, int propertyIndex, bool captureRequired, bool isSingleton, int attachedPropertiesId, IR::Expr *target) override; + void setProperty(IR::Expr *source, IR::Expr *targetBase, const QString &targetName) override; + void setQmlContextProperty(IR::Expr *source, IR::Expr *targetBase, IR::Member::MemberKind kind, int propertyIndex) override; + void setQObjectProperty(IR::Expr *source, IR::Expr *targetBase, int propertyIndex) override; + void getElement(IR::Expr *base, IR::Expr *index, IR::Expr *target) override; + void setElement(IR::Expr *source, IR::Expr *targetBase, IR::Expr *targetIndex) override; + void copyValue(IR::Expr *source, IR::Expr *target) override; + void swapValues(IR::Expr *source, IR::Expr *target) override; + void unop(IR::AluOp oper, IR::Expr *sourceTemp, IR::Expr *target) override; + void binop(IR::AluOp oper, IR::Expr *leftSource, IR::Expr *rightSource, IR::Expr *target) override; typedef Assembler::Address Address; typedef Assembler::Pointer Pointer; @@ -159,13 +159,13 @@ protected: return _as->stackLayout().callDataAddress(); } - virtual void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Expr *result); - virtual void constructProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr*result); - virtual void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result); + void constructActivationProperty(IR::Name *func, IR::ExprList *args, IR::Expr *result) override; + void constructProperty(IR::Expr *base, const QString &name, IR::ExprList *args, IR::Expr*result) override; + void constructValue(IR::Expr *value, IR::ExprList *args, IR::Expr *result) override; - virtual void visitJump(IR::Jump *); - virtual void visitCJump(IR::CJump *); - virtual void visitRet(IR::Ret *); + void visitJump(IR::Jump *) override; + void visitCJump(IR::CJump *) override; + void visitRet(IR::Ret *) override; bool visitCJumpDouble(IR::AluOp op, IR::Expr *left, IR::Expr *right, IR::BasicBlock *iftrue, IR::BasicBlock *iffalse); diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h index 846ea42571..d31e464e99 100644 --- a/src/qml/parser/qqmljsast_p.h +++ b/src/qml/parser/qqmljsast_p.h @@ -253,7 +253,7 @@ class QML_PARSER_EXPORT ExpressionNode: public Node public: ExpressionNode() {} - virtual ExpressionNode *expressionCast(); + ExpressionNode *expressionCast() override; }; class QML_PARSER_EXPORT Statement: public Node @@ -261,7 +261,7 @@ class QML_PARSER_EXPORT Statement: public Node public: Statement() {} - virtual Statement *statementCast(); + Statement *statementCast() override; }; class QML_PARSER_EXPORT NestedExpression: public ExpressionNode diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 162fbcc8f6..4d2bb72352 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -197,7 +197,7 @@ public: { inline ContextGuard(); inline ContextGuard &operator=(QObject *obj); - inline void objectDestroyed(QObject *); + inline void objectDestroyed(QObject *) override; inline bool wasSet() const; diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h index 183baec941..4bb92489a5 100644 --- a/src/qml/qml/qqmlopenmetaobject_p.h +++ b/src/qml/qml/qqmlopenmetaobject_p.h @@ -83,7 +83,7 @@ public: protected: virtual void propertyCreated(int, QMetaPropertyBuilder &); - virtual void clear(); + void clear() override; private: QQmlOpenMetaObjectTypePrivate *d; diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index abbbf89ea2..b1d6451974 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -577,8 +577,8 @@ public: void setPriority(int); protected: - virtual void dataReceived(const Data &); - virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*); + void dataReceived(const Data &) override; + void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit*) override; private: QString m_content; diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index 9a13e0047d..bb6fede7c8 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -83,7 +83,7 @@ public: inline QQmlVMEVariantQObjectPtr(); inline ~QQmlVMEVariantQObjectPtr(); - inline void objectDestroyed(QObject *); + inline void objectDestroyed(QObject *) override; inline void setGuardedValue(QObject *obj, QQmlVMEMetaObject *target, int index); QQmlVMEMetaObject *m_target; diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index f4ffdf38aa..07e35d3fd7 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -294,7 +294,7 @@ public: const QVector &removes, const QVector &inserts); void itemsChanged(const QVector &changes); void emitChanges(); - void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset); + void emitModelUpdated(const QQmlChangeSet &changeSet, bool reset) override; bool insert(Compositor::insert_iterator &before, const QV4::Value &object, int groups); diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h index 8e400f9146..78d964236e 100644 --- a/src/qml/util/qqmladaptormodel_p.h +++ b/src/qml/util/qqmladaptormodel_p.h @@ -143,7 +143,7 @@ public: inline void fetchMore() { return accessors->fetchMore(*this); } protected: - void objectDestroyed(QObject *); + void objectDestroyed(QObject *) override; }; class QQmlAdaptorModelProxyInterface diff --git a/src/qmldebug/qqmlenginecontrolclient_p.h b/src/qmldebug/qqmlenginecontrolclient_p.h index 6affc46ffc..9b4ea3acb1 100644 --- a/src/qmldebug/qqmlenginecontrolclient_p.h +++ b/src/qmldebug/qqmlenginecontrolclient_p.h @@ -78,7 +78,7 @@ protected: QQmlEngineControlClient(QQmlEngineControlClientPrivate &dd); private: - void messageReceived(const QByteArray &); + void messageReceived(const QByteArray &) override; }; QT_END_NAMESPACE diff --git a/src/qmldebug/qqmlprofilerclient_p.h b/src/qmldebug/qqmlprofilerclient_p.h index b4054ed0d9..a328cad26c 100644 --- a/src/qmldebug/qqmlprofilerclient_p.h +++ b/src/qmldebug/qqmlprofilerclient_p.h @@ -73,7 +73,7 @@ protected: QQmlProfilerClient(QQmlProfilerClientPrivate &dd); private: - virtual void messageReceived(const QByteArray &message); + void messageReceived(const QByteArray &message) override; virtual void traceStarted(qint64 time, int engineId); virtual void traceFinished(qint64 time, int engineId); diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h index f9faca55e0..06239c7193 100644 --- a/src/quick/items/qquickdrag_p.h +++ b/src/quick/items/qquickdrag_p.h @@ -77,7 +77,7 @@ class QQuickDragGrabber QIntrusiveListNode node; protected: - void objectDestroyed(QQuickItem *) { delete this; } + void objectDestroyed(QQuickItem *) override { delete this; } }; typedef QIntrusiveList ItemList; diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index 5880c67af0..bf267ccf92 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -141,7 +141,7 @@ public: virtual void update() = 0; - virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } }; @@ -165,7 +165,7 @@ public: virtual void update() = 0; - virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } }; class Q_QUICK_PRIVATE_EXPORT QSGPainterNode : public QSGVisitableNode @@ -188,7 +188,7 @@ public: virtual void update() = 0; virtual QSGTexture *texture() const = 0; - virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } }; class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture @@ -231,7 +231,7 @@ public: virtual void update() = 0; - virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } }; #endif @@ -389,7 +389,7 @@ public: void setOwnerElement(QQuickItem *ownerElement) { m_ownerElement = ownerElement; } QQuickItem *ownerElement() const { return m_ownerElement; } - virtual void accept(QSGNodeVisitorEx *visitor) { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } + void accept(QSGNodeVisitorEx *visitor) override { if (visitor->visit(this)) visitor->visitChildren(this); visitor->endVisit(this); } protected: QRectF m_bounding_rect; QQuickItem *m_ownerElement; diff --git a/src/quick/scenegraph/qsgbasicglyphnode_p.h b/src/quick/scenegraph/qsgbasicglyphnode_p.h index 1d09367ea5..0a43d17d2b 100644 --- a/src/quick/scenegraph/qsgbasicglyphnode_p.h +++ b/src/quick/scenegraph/qsgbasicglyphnode_p.h @@ -63,16 +63,16 @@ public: QSGBasicGlyphNode(); virtual ~QSGBasicGlyphNode(); - virtual QPointF baseLine() const { return m_baseLine; } - virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs); - virtual void setColor(const QColor &color); + QPointF baseLine() const override { return m_baseLine; } + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; - virtual void setPreferredAntialiasingMode(AntialiasingMode) { } - virtual void setStyle(QQuickText::TextStyle); - virtual void setStyleColor(const QColor &); + void setPreferredAntialiasingMode(AntialiasingMode) override { } + void setStyle(QQuickText::TextStyle) override; + void setStyleColor(const QColor &) override; virtual void setMaterialColor(const QColor &color) = 0; - virtual void update() = 0; + void update() override = 0; protected: QGlyphRun m_glyphs; diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h index 08c3d21408..5914b42809 100644 --- a/src/quick/scenegraph/qsgcontextplugin_p.h +++ b/src/quick/scenegraph/qsgcontextplugin_p.h @@ -90,10 +90,10 @@ public: explicit QSGContextPlugin(QObject *parent = 0); virtual ~QSGContextPlugin(); - virtual QStringList keys() const = 0; + virtual QStringList keys() const override = 0; - virtual QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) { return 0; } - virtual QSGRenderLoop *createWindowManager() { return 0; } + QQuickTextureFactory *createTextureFactoryFromImage(const QImage &) override { return 0; } + QSGRenderLoop *createWindowManager() override { return 0; } }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h index 0fefb95328..57dc4a5d07 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache_p.h @@ -72,10 +72,10 @@ public: QSGDefaultDistanceFieldGlyphCache(QSGDistanceFieldGlyphCacheManager *man, QOpenGLContext *c, const QRawFont &font); virtual ~QSGDefaultDistanceFieldGlyphCache(); - void requestGlyphs(const QSet &glyphs); - void storeGlyphs(const QList &glyphs); - void referenceGlyphs(const QSet &glyphs); - void releaseGlyphs(const QSet &glyphs); + void requestGlyphs(const QSet &glyphs) override; + void storeGlyphs(const QList &glyphs) override; + void referenceGlyphs(const QSet &glyphs) override; + void releaseGlyphs(const QSet &glyphs) override; bool useTextureResizeWorkaround() const; bool useTextureUploadWorkaround() const; diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h index caa7dfad07..b0a2788dd8 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p_p.h @@ -71,9 +71,9 @@ public: QSGTextMaskMaterial(const QRawFont &font, QFontEngine::GlyphFormat glyphFormat = QFontEngine::Format_None); virtual ~QSGTextMaskMaterial(); - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + int compare(const QSGMaterial *other) const override; void setColor(const QColor &c) { m_color = QVector4D(c.redF(), c.greenF(), c.blueF(), c.alphaF()); } void setColor(const QVector4D &color) { m_color = color; } @@ -115,10 +115,10 @@ public: void setStyleColor(const QVector4D &color) { m_styleColor = color; } const QVector4D &styleColor() const { return m_styleColor; } - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; - int compare(const QSGMaterial *other) const; + int compare(const QSGMaterial *other) const override; private: QVector2D m_styleShift; @@ -131,8 +131,8 @@ public: QSGOutlinedTextMaterial(const QRawFont &font); ~QSGOutlinedTextMaterial() { } - QSGMaterialType *type() const; - QSGMaterialShader *createShader() const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h index 22c68558ef..c0c6bda718 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.h @@ -67,19 +67,19 @@ public: QSGDistanceFieldGlyphNode(QSGRenderContext *context); ~QSGDistanceFieldGlyphNode(); - virtual QPointF baseLine() const { return m_baseLine; } - virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs); - virtual void setColor(const QColor &color); + QPointF baseLine() const override { return m_baseLine; } + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; - virtual void setPreferredAntialiasingMode(AntialiasingMode mode); + void setPreferredAntialiasingMode(AntialiasingMode mode) override; - virtual void setStyle(QQuickText::TextStyle style); - virtual void setStyleColor(const QColor &color); + void setStyle(QQuickText::TextStyle style) override; + void setStyleColor(const QColor &color) override; - virtual void update(); - void preprocess(); + void update() override; + void preprocess() override; - void invalidateGlyphs(const QVector &glyphs); + void invalidateGlyphs(const QVector &glyphs) override; void updateGeometry(); diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h index 38dcf3d307..c13a0898eb 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p_p.h @@ -63,9 +63,9 @@ public: QSGDistanceFieldTextMaterial(); ~QSGDistanceFieldTextMaterial(); - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + int compare(const QSGMaterial *other) const override; virtual void setColor(const QColor &color); const QVector4D &color() const { return m_color; } @@ -97,9 +97,9 @@ public: QSGDistanceFieldStyledTextMaterial(); ~QSGDistanceFieldStyledTextMaterial(); - virtual QSGMaterialType *type() const = 0; - virtual QSGMaterialShader *createShader() const = 0; - virtual int compare(const QSGMaterial *other) const; + QSGMaterialType *type() const override = 0; + QSGMaterialShader *createShader() const override = 0; + int compare(const QSGMaterial *other) const override; void setStyleColor(const QColor &color); const QVector4D &styleColor() const { return m_styleColor; } @@ -114,8 +114,8 @@ public: QSGDistanceFieldOutlineTextMaterial(); ~QSGDistanceFieldOutlineTextMaterial(); - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; }; class Q_QUICK_PRIVATE_EXPORT QSGDistanceFieldShiftedStyleTextMaterial : public QSGDistanceFieldStyledTextMaterial @@ -124,9 +124,9 @@ public: QSGDistanceFieldShiftedStyleTextMaterial(); ~QSGDistanceFieldShiftedStyleTextMaterial(); - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const; + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + int compare(const QSGMaterial *other) const override; void setShift(const QPointF &shift) { m_shift = shift; } const QPointF &shift() const { return m_shift; } @@ -138,17 +138,17 @@ protected: class Q_QUICK_PRIVATE_EXPORT QSGHiQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial { public: - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); } + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); } }; class Q_QUICK_PRIVATE_EXPORT QSGLoQSubPixelDistanceFieldTextMaterial : public QSGDistanceFieldTextMaterial { public: - virtual QSGMaterialType *type() const; - virtual QSGMaterialShader *createShader() const; - void setColor(const QColor &color) { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); } + QSGMaterialType *type() const override; + QSGMaterialShader *createShader() const override; + void setColor(const QColor &color) override { m_color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); } }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h index 0ab83b444a..32bfcb7148 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h +++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h @@ -68,29 +68,29 @@ public: QSGThreadedRenderLoop(); ~QSGThreadedRenderLoop(); - void show(QQuickWindow *) {} - void hide(QQuickWindow *); + void show(QQuickWindow *) override {} + void hide(QQuickWindow *) override; - void windowDestroyed(QQuickWindow *window); - void exposureChanged(QQuickWindow *window); + void windowDestroyed(QQuickWindow *window) override; + void exposureChanged(QQuickWindow *window) override; - QImage grab(QQuickWindow *); + QImage grab(QQuickWindow *) override; - void update(QQuickWindow *window); - void maybeUpdate(QQuickWindow *window); - void handleUpdateRequest(QQuickWindow *window); + void update(QQuickWindow *window) override; + void maybeUpdate(QQuickWindow *window) override; + void handleUpdateRequest(QQuickWindow *window) override; - QSGContext *sceneGraphContext() const; - QSGRenderContext *createRenderContext(QSGContext *) const; + QSGContext *sceneGraphContext() const override; + QSGRenderContext *createRenderContext(QSGContext *) const override; - QAnimationDriver *animationDriver() const; + QAnimationDriver *animationDriver() const override; - void releaseResources(QQuickWindow *window); + void releaseResources(QQuickWindow *window) override; - bool event(QEvent *); - void postJob(QQuickWindow *window, QRunnable *job); + bool event(QEvent *) override; + void postJob(QQuickWindow *window, QRunnable *job) override; - bool interleaveIncubation() const; + bool interleaveIncubation() const override; public Q_SLOTS: void animationStarted(); diff --git a/src/quick/scenegraph/qsgwindowsrenderloop_p.h b/src/quick/scenegraph/qsgwindowsrenderloop_p.h index 9e5d7f04d3..1940a66af2 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop_p.h +++ b/src/quick/scenegraph/qsgwindowsrenderloop_p.h @@ -70,31 +70,31 @@ public: explicit QSGWindowsRenderLoop(); ~QSGWindowsRenderLoop(); - void show(QQuickWindow *window); - void hide(QQuickWindow *window); + void show(QQuickWindow *window) override; + void hide(QQuickWindow *window) override; - void windowDestroyed(QQuickWindow *window); + void windowDestroyed(QQuickWindow *window) override; - void exposureChanged(QQuickWindow *window); - QImage grab(QQuickWindow *window); + void exposureChanged(QQuickWindow *window) override; + QImage grab(QQuickWindow *window) override; - void update(QQuickWindow *window); - void maybeUpdate(QQuickWindow *window); + void update(QQuickWindow *window) override; + void maybeUpdate(QQuickWindow *window) override; - QAnimationDriver *animationDriver() const { return m_animationDriver; } + QAnimationDriver *animationDriver() const override { return m_animationDriver; } - QSGContext *sceneGraphContext() const { return m_sg; } - QSGRenderContext *createRenderContext(QSGContext *) const; + QSGContext *sceneGraphContext() const override { return m_sg; } + QSGRenderContext *createRenderContext(QSGContext *) const override; - void releaseResources(QQuickWindow *) { } + void releaseResources(QQuickWindow *) override { } void render(); void renderWindow(QQuickWindow *window); - bool event(QEvent *event); + bool event(QEvent *event) override; bool anyoneShowing() const; - bool interleaveIncubation() const; + bool interleaveIncubation() const override; public Q_SLOTS: void started(); diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h index 01f98767fd..c14ba506ec 100644 --- a/src/quick/scenegraph/util/qsgsimplematerial.h +++ b/src/quick/scenegraph/util/qsgsimplematerial.h @@ -48,7 +48,7 @@ template class QSGSimpleMaterialShader : public QSGMaterialShader { public: - void initialize() { + void initialize() override { QSGMaterialShader::initialize(); #ifndef QT_NO_OPENGL m_id_matrix = program()->uniformLocation(uniformMatrixName()); @@ -74,7 +74,7 @@ public: const char *uniformMatrixName() const { return "qt_Matrix"; } const char *uniformOpacityName() const { return "qt_Opacity"; } - void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); + void updateState(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; virtual void updateState(const State *newState, const State *oldState) = 0; @@ -82,7 +82,7 @@ public: virtual QList attributes() const = 0; - char const *const *attributeNames() const + char const *const *attributeNames() const override { if (m_attribute_pointers.size()) return m_attribute_pointers.constData(); diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h index af97390efb..eba1dabecf 100644 --- a/src/quick/util/qquickstate_p_p.h +++ b/src/quick/util/qquickstate_p_p.h @@ -217,7 +217,7 @@ public: setObject(static_cast(obj)); } QList *list; - void objectDestroyed(QQuickStateOperation *) { + void objectDestroyed(QQuickStateOperation *) override { // we assume priv will always be destroyed after objectDestroyed calls list->removeOne(*this); } diff --git a/tools/qmleasing/mainwindow.h b/tools/qmleasing/mainwindow.h index 9af5c8050c..7ca4dbfd5c 100644 --- a/tools/qmleasing/mainwindow.h +++ b/tools/qmleasing/mainwindow.h @@ -51,9 +51,9 @@ public slots: void importData(int result); protected: - virtual void moveEvent(QMoveEvent *event); - virtual void resizeEvent(QResizeEvent *event); - virtual void closeEvent(QCloseEvent *event); + void moveEvent(QMoveEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void closeEvent(QCloseEvent *event) override; void initQml(); private: diff --git a/tools/qmleasing/splineeditor.h b/tools/qmleasing/splineeditor.h index 243e199cd0..f21713d6a7 100644 --- a/tools/qmleasing/splineeditor.h +++ b/tools/qmleasing/splineeditor.h @@ -75,12 +75,12 @@ public slots: void setEasingCurve(const QString &code); protected: - void paintEvent(QPaintEvent *); - void mousePressEvent(QMouseEvent *); - void mouseMoveEvent(QMouseEvent *); - void mouseReleaseEvent(QMouseEvent *); + void paintEvent(QPaintEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; #ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QContextMenuEvent *); + void contextMenuEvent(QContextMenuEvent *) override; #endif // QT_NO_CONTEXTMENU void invalidate(); diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h index 1da04db42a..a04a412bb0 100644 --- a/tools/qmlprofiler/qmlprofilerclient.h +++ b/tools/qmlprofiler/qmlprofilerclient.h @@ -50,24 +50,24 @@ signals: void error(const QString &error); private: - virtual void stateChanged(State state); + void stateChanged(State state) override; - void traceStarted(qint64 time, int engineId); - void traceFinished(qint64 time, int engineId); - void rangeStart(QQmlProfilerDefinitions::RangeType type, qint64 startTime); - void rangeData(QQmlProfilerDefinitions::RangeType type, qint64 time, const QString &data); + void traceStarted(qint64 time, int engineId) override; + void traceFinished(qint64 time, int engineId) override; + void rangeStart(QQmlProfilerDefinitions::RangeType type, qint64 startTime) override; + void rangeData(QQmlProfilerDefinitions::RangeType type, qint64 time, const QString &data) override; void rangeLocation(QQmlProfilerDefinitions::RangeType type, qint64 time, - const QQmlEventLocation &location); - void rangeEnd(QQmlProfilerDefinitions::RangeType type, qint64 endTime); - void animationFrame(qint64 time, int frameRate, int animationCount, int threadId); + const QQmlEventLocation &location) override; + void rangeEnd(QQmlProfilerDefinitions::RangeType type, qint64 endTime) override; + void animationFrame(qint64 time, int frameRate, int animationCount, int threadId) override; void sceneGraphEvent(QQmlProfilerDefinitions::SceneGraphFrameType type, qint64 time, qint64 numericData1, qint64 numericData2, qint64 numericData3, - qint64 numericData4, qint64 numericData5); + qint64 numericData4, qint64 numericData5) override; void pixmapCacheEvent(QQmlProfilerDefinitions::PixmapEventType type, qint64 time, - const QString &url, int numericData1, int numericData2); - void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount); - void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b); - void complete(); + const QString &url, int numericData1, int numericData2) override; + void memoryAllocation(QQmlProfilerDefinitions::MemoryType type, qint64 time, qint64 amount) override; + void inputEvent(QQmlProfilerDefinitions::InputEventType type, qint64 time, int a, int b) override; + void complete() override; }; #endif // QMLPROFILERCLIENT_H -- 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 bff7302fc277d18b5bd4ad95d35b9e1bbc2be001 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 7 Dec 2016 14:24:04 +0100 Subject: V4 Debugger: Add an option to pass additional context for evaluate Interpret the "context" option as an ID for a QObject whose QML context is then injected when evaluating the expression. The QObject needs to be tracked by some other debug service for this to work, e.g. the QML debugger or the inspector. Task-number: QTCREATORBUG-17177 Change-Id: I6a9e8b9ae23e8bb67ed1905a2ef73f7c4faeb990 Reviewed-by: Simon Hausmann --- .../qmltooling/qmldbg_debugger/qv4debugjob.cpp | 40 ++++++++----- .../qmltooling/qmldbg_debugger/qv4debugjob.h | 7 ++- .../qmltooling/qmldbg_debugger/qv4debugservice.cpp | 5 +- .../qqmldebugjs/qqmldebugjs/qqmldebugjs.pro | 1 + .../qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp | 68 +++++++++++++++++++++- .../qml/debugger/qv4debugger/tst_qv4debugger.cpp | 26 ++++++--- 6 files changed, 119 insertions(+), 28 deletions(-) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index 4e4048f6ad..6c1e353b4d 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -51,9 +52,10 @@ QV4DebugJob::~QV4DebugJob() { } -JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, - const QString &script) : - engine(engine), frameNr(frameNr), script(script), resultIsException(false) +JavaScriptJob::JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context, + const QString &script) : + engine(engine), frameNr(frameNr), context(context), script(script), + resultIsException(false) {} void JavaScriptJob::run() @@ -64,7 +66,23 @@ void JavaScriptJob::run() QV4::ExecutionContext *ctx = engine->currentContext; QObject scopeObject; - if (frameNr < 0) { // Use QML context if available + + if (frameNr > 0) { + for (int i = 0; i < frameNr; ++i) { + ctx = engine->parentContext(ctx); + } + engine->pushContext(ctx); + ctx = engine->currentContext; + } + + if (context >= 0) { + QQmlContext *extraContext = qmlContext(QQmlDebugService::objectForId(context)); + if (extraContext) { + engine->pushContext(ctx->newQmlContext(QQmlContextData::get(extraContext), + &scopeObject)); + ctx = engine->currentContext; + } + } else if (frameNr < 0) { // Use QML context if available QQmlEngine *qmlEngine = engine->qmlEngine(); if (qmlEngine) { QQmlContext *qmlRootContext = qmlEngine->rootContext(); @@ -88,13 +106,6 @@ void JavaScriptJob::run() engine->pushContext(ctx->newWithContext(withContext->toObject(engine))); ctx = engine->currentContext; } - } else { - if (frameNr > 0) { - for (int i = 0; i < frameNr; ++i) { - ctx = engine->parentContext(ctx); - } - engine->pushContext(ctx); - } } QV4::Script script(ctx, this->script); @@ -224,8 +235,9 @@ const QString &ValueLookupJob::exceptionMessage() const } ExpressionEvalJob::ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, - const QString &expression, QV4DataCollector *collector) : - JavaScriptJob(engine, frameNr, expression), collector(collector) + int context, const QString &expression, + QV4DataCollector *collector) : + JavaScriptJob(engine, frameNr, context, expression), collector(collector) { } @@ -271,7 +283,7 @@ const QStringList &GatherSourcesJob::result() const } EvalJob::EvalJob(QV4::ExecutionEngine *engine, const QString &script) : - JavaScriptJob(engine, /*frameNr*/-1, script), result(false) + JavaScriptJob(engine, /*frameNr*/-1, /*context*/ -1, script), result(false) {} void EvalJob::handleResult(QV4::ScopedValue &result) diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h index b28adffae5..00d3e6206a 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h @@ -60,11 +60,12 @@ class JavaScriptJob : public QV4DebugJob { QV4::ExecutionEngine *engine; int frameNr; + int context; const QString &script; bool resultIsException; public: - JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, const QString &script); + JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context, const QString &script); void run() override; bool hasExeption() const; @@ -135,8 +136,8 @@ class ExpressionEvalJob: public JavaScriptJob QJsonArray collectedRefs; public: - ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, const QString &expression, - QV4DataCollector *collector); + ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context, + const QString &expression, QV4DataCollector *collector); void handleResult(QV4::ScopedValue &value) override; const QString &exceptionMessage() const; const QJsonObject &returnValue() const; diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index de97b5437b..1d2cc092dc 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -177,6 +177,7 @@ public: body.insert(QStringLiteral("V8Version"), QLatin1String("this is not V8, this is V4 in Qt " QT_VERSION_STR)); body.insert(QStringLiteral("UnpausedEvaluate"), true); + body.insert(QStringLiteral("ContextEvaluate"), true); addBody(body); } }; @@ -610,6 +611,7 @@ public: { QJsonObject arguments = req.value(QLatin1String("arguments")).toObject(); QString expression = arguments.value(QLatin1String("expression")).toString(); + int context = arguments.value(QLatin1String("context")).toInt(-1); int frame = -1; QV4Debugger *debugger = debugService->debuggerAgent.pausedDebugger(); @@ -627,7 +629,8 @@ public: frame = arguments.value(QLatin1String("frame")).toInt(0); } - ExpressionEvalJob job(debugger->engine(), frame, expression, debugger->collector()); + ExpressionEvalJob job(debugger->engine(), frame, context, expression, + debugger->collector()); debugger->runInEngine(&job); if (job.hasExeption()) { createErrorResponse(job.exceptionMessage()); diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro index 79e772c1ee..cbaf3b5309 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/qqmldebugjs.pro @@ -9,6 +9,7 @@ SOURCES += tst_qqmldebugjs.cpp INCLUDEPATH += ../../shared include(../../../../shared/util.pri) include(../../shared/debugutil.pri) +include(../../shared/qqmlenginedebugclient.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp index d1150be831..31b8d63ec2 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs/tst_qqmldebugjs.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "debugutil_p.h" +#include "../../shared/qqmlenginedebugclient.h" #include "../../../../shared/util.h" #include @@ -52,6 +53,7 @@ const char *STEPACTION = "stepaction"; const char *STEPCOUNT = "stepcount"; const char *EXPRESSION = "expression"; const char *FRAME = "frame"; +const char *CONTEXT = "context"; const char *GLOBAL = "global"; const char *DISABLEBREAK = "disable_break"; const char *HANDLES = "handles"; @@ -215,6 +217,8 @@ private slots: void evaluateInLocalScope_data() { targetData(); } void evaluateInLocalScope(); + void evaluateInContext(); + void getScripts_data() { targetData(); } void getScripts(); @@ -257,7 +261,7 @@ public: void interrupt(); void continueDebugging(StepAction stepAction); - void evaluate(QString expr, int frame = -1); + void evaluate(QString expr, int frame = -1, int context = -1); void lookup(QList handles, bool includeSource = false); void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); void frame(int number = -1); @@ -280,6 +284,7 @@ signals: void connected(); void interruptRequested(); void result(); + void failure(); void stopped(); private: @@ -340,13 +345,14 @@ void QJSDebugClient::continueDebugging(StepAction action) sendMessage(packMessage(V8REQUEST, json.toString().toUtf8())); } -void QJSDebugClient::evaluate(QString expr, int frame) +void QJSDebugClient::evaluate(QString expr, int frame, int context) { // { "seq" : , // "type" : "request", // "command" : "evaluate", // "arguments" : { "expression" : , - // "frame" : + // "frame" : , + // "context" : // } // } VARIANTMAPINIT; @@ -358,6 +364,9 @@ void QJSDebugClient::evaluate(QString expr, int frame) if (frame != -1) args.setProperty(QLatin1String(FRAME),QJSValue(frame)); + if (context != -1) + args.setProperty(QLatin1String(CONTEXT), QJSValue(context)); + if (!args.isUndefined()) { jsonVal.setProperty(QLatin1String(ARGUMENTS),args); } @@ -684,6 +693,7 @@ void QJSDebugClient::messageReceived(const QByteArray &data) if (type == "response") { if (!value.value("success").toBool()) { + emit failure(); qDebug() << "Received success == false response from application"; return; } @@ -1394,6 +1404,58 @@ void tst_QQmlDebugJS::evaluateInLocalScope() QCOMPARE(body.value("value").toInt(),10); } +void tst_QQmlDebugJS::evaluateInContext() +{ + connection = new QQmlDebugConnection(); + process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + + "/qmlscene", this); + client = new QJSDebugClient(connection); + QScopedPointer engineClient(new QQmlEngineDebugClient(connection)); + process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(ONCOMPLETED_QMLFILE)); + + QVERIFY(process->waitForSessionStart()); + + connection->connectToHost("127.0.0.1", process->debugPort()); + QVERIFY(connection->waitForConnected()); + + QTRY_COMPARE(client->state(), QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(engineClient->state(), QQmlEngineDebugClient::Enabled); + client->connect(); + + // "a" not accessible without extra context + client->evaluate(QLatin1String("a + 10"), -1, -1); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(failure()))); + + bool success = false; + engineClient->queryAvailableEngines(&success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + QVERIFY(engineClient->engines().count()); + engineClient->queryRootContexts(engineClient->engines()[0].debugId, &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + + auto contexts = engineClient->rootContext().contexts; + QCOMPARE(contexts.count(), 1); + auto objects = contexts[0].objects; + QCOMPARE(objects.count(), 1); + engineClient->queryObjectRecursive(objects[0], &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(engineClient.data(), SIGNAL(result()))); + auto object = engineClient->object(); + + // "a" accessible in context of surrounding object + client->evaluate(QLatin1String("a + 10"), -1, object.debugId); + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result()))); + + QString jsonString = client->response; + QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap(); + + QVariantMap body = value.value("body").toMap(); + QTRY_COMPARE(body.value("value").toInt(), 20); +} + void tst_QQmlDebugJS::getScripts() { //void scripts(int types = -1, QList ids = QList(), bool includeSource = false, QVariant filter = QVariant()); diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index a23b7e37eb..6793596174 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -41,6 +41,7 @@ #include #include #include +#include using namespace QV4; using namespace QV4::Debugging; @@ -203,8 +204,8 @@ public slots: while (!m_expressionRequests.isEmpty()) { Q_ASSERT(debugger->state() == QV4Debugger::Paused); ExpressionRequest request = m_expressionRequests.takeFirst(); - ExpressionEvalJob job(debugger->engine(), request.frameNr, request.expression, - &collector); + ExpressionEvalJob job(debugger->engine(), request.frameNr, request.context, + request.expression, &collector); debugger->runInEngine(&job); m_expressionResults << job.returnValue(); m_expressionRefs << job.refs(); @@ -276,6 +277,7 @@ public: struct ExpressionRequest { QString expression; int frameNr; + int context; }; QVector m_expressionRequests; QList m_expressionResults; @@ -726,24 +728,34 @@ void tst_qv4debugger::evaluateExpression() TestAgent::ExpressionRequest request; request.expression = "x"; request.frameNr = 0; + request.context = -1; // no extra context m_debuggerAgent->m_expressionRequests << request; request.expression = "x"; request.frameNr = 1; m_debuggerAgent->m_expressionRequests << request; + request.context = 5355; // invalid context object + m_debuggerAgent->m_expressionRequests << request; + + QObject object; // some object without QML context + request.context = QQmlDebugService::idForObject(&object); + m_debuggerAgent->m_expressionRequests << request; + debugger()->addBreakPoint("evaluateExpression", 3); evaluateJavaScript(script, "evaluateExpression"); - QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 2); + QCOMPARE(m_debuggerAgent->m_expressionRefs.count(), 4); QCOMPARE(m_debuggerAgent->m_expressionRefs[0].size(), 1); QJsonObject result0 = m_debuggerAgent->m_expressionRefs[0].first().toObject(); QCOMPARE(result0.value("type").toString(), QStringLiteral("number")); QCOMPARE(result0.value("value").toInt(), 10); - QCOMPARE(m_debuggerAgent->m_expressionRefs[1].size(), 1); - QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); - QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); - QCOMPARE(result1.value("value").toInt(), 20); + for (int i = 1; i < 4; ++i) { + QCOMPARE(m_debuggerAgent->m_expressionRefs[i].size(), 1); + QJsonObject result1 = m_debuggerAgent->m_expressionRefs[1].first().toObject(); + QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); + QCOMPARE(result1.value("value").toInt(), 20); + } } QTEST_MAIN(tst_qv4debugger) -- 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 From 3f57f2b7cc3899af154257a3c858bd23d9f03a62 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Sun, 3 Apr 2016 18:06:46 +0200 Subject: OpenVG Scenegraph Adaptation This is an OpenVG backend for the Qt Quick 2 scenegraph. Should be feature complete now, but there are still some issues that could be improved in future commits: If Rectangle nodes are rendered with a non-affine transform, they will be rendered incorrectly. This is because paths expect affine transformations. The Glyph cache is a bit cheeky in that it's caching paths, but doing so per font size. It shoudln't need to, but right now I've not though up a good way of getting the transform/scale needed when rendering yet. Change-Id: Ie3c4f2df35d14279b0f9f55e0e10a873328c025b Reviewed-by: Laszlo Agocs --- src/plugins/scenegraph/openvg/openvg.json | 3 + src/plugins/scenegraph/openvg/openvg.pro | 54 ++ src/plugins/scenegraph/openvg/qopenvgcontext.cpp | 218 ++++++++ src/plugins/scenegraph/openvg/qopenvgcontext_p.h | 88 +++ src/plugins/scenegraph/openvg/qopenvgmatrix.cpp | 325 +++++++++++ src/plugins/scenegraph/openvg/qopenvgmatrix.h | 99 ++++ .../scenegraph/openvg/qsgopenvgadaptation.cpp | 78 +++ .../scenegraph/openvg/qsgopenvgadaptation_p.h | 68 +++ src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp | 219 ++++++++ src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h | 104 ++++ .../scenegraph/openvg/qsgopenvgfontglyphcache.cpp | 185 +++++++ .../scenegraph/openvg/qsgopenvgfontglyphcache.h | 99 ++++ .../scenegraph/openvg/qsgopenvgglyphnode.cpp | 191 +++++++ .../scenegraph/openvg/qsgopenvgglyphnode_p.h | 95 ++++ src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp | 433 +++++++++++++++ src/plugins/scenegraph/openvg/qsgopenvghelpers.h | 64 +++ .../openvg/qsgopenvginternalimagenode.cpp | 233 ++++++++ .../scenegraph/openvg/qsgopenvginternalimagenode.h | 92 ++++ .../openvg/qsgopenvginternalrectanglenode.cpp | 613 +++++++++++++++++++++ .../openvg/qsgopenvginternalrectanglenode.h | 96 ++++ src/plugins/scenegraph/openvg/qsgopenvglayer.cpp | 360 ++++++++++++ src/plugins/scenegraph/openvg/qsgopenvglayer.h | 115 ++++ .../scenegraph/openvg/qsgopenvgnodevisitor.cpp | 283 ++++++++++ .../scenegraph/openvg/qsgopenvgnodevisitor.h | 104 ++++ .../scenegraph/openvg/qsgopenvgpainternode.cpp | 249 +++++++++ .../scenegraph/openvg/qsgopenvgpainternode.h | 97 ++++ .../scenegraph/openvg/qsgopenvgpublicnodes.cpp | 266 +++++++++ .../scenegraph/openvg/qsgopenvgpublicnodes.h | 143 +++++ .../scenegraph/openvg/qsgopenvgrenderable.cpp | 77 +++ .../scenegraph/openvg/qsgopenvgrenderable.h | 69 +++ .../scenegraph/openvg/qsgopenvgrenderer.cpp | 90 +++ .../scenegraph/openvg/qsgopenvgrenderer_p.h | 61 ++ .../scenegraph/openvg/qsgopenvgrenderloop.cpp | 257 +++++++++ .../scenegraph/openvg/qsgopenvgrenderloop_p.h | 94 ++++ .../scenegraph/openvg/qsgopenvgspritenode.cpp | 153 +++++ .../scenegraph/openvg/qsgopenvgspritenode.h | 78 +++ src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp | 123 +++++ src/plugins/scenegraph/openvg/qsgopenvgtexture.h | 67 +++ src/plugins/scenegraph/scenegraph.pro | 2 + .../doc/src/concepts/visualcanvas/adaptations.qdoc | 80 +++ .../scenegraph/coreapi/qsgrendererinterface.cpp | 1 + .../scenegraph/coreapi/qsgrendererinterface.h | 3 +- 42 files changed, 6128 insertions(+), 1 deletion(-) create mode 100644 src/plugins/scenegraph/openvg/openvg.json create mode 100644 src/plugins/scenegraph/openvg/openvg.pro create mode 100644 src/plugins/scenegraph/openvg/qopenvgcontext.cpp create mode 100644 src/plugins/scenegraph/openvg/qopenvgcontext_p.h create mode 100644 src/plugins/scenegraph/openvg/qopenvgmatrix.cpp create mode 100644 src/plugins/scenegraph/openvg/qopenvgmatrix.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvghelpers.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvglayer.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvglayer.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgpainternode.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderable.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgspritenode.h create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp create mode 100644 src/plugins/scenegraph/openvg/qsgopenvgtexture.h diff --git a/src/plugins/scenegraph/openvg/openvg.json b/src/plugins/scenegraph/openvg/openvg.json new file mode 100644 index 0000000000..224afbf784 --- /dev/null +++ b/src/plugins/scenegraph/openvg/openvg.json @@ -0,0 +1,3 @@ +{ + "Keys": ["openvg"] +} diff --git a/src/plugins/scenegraph/openvg/openvg.pro b/src/plugins/scenegraph/openvg/openvg.pro new file mode 100644 index 0000000000..fb9b3b93f5 --- /dev/null +++ b/src/plugins/scenegraph/openvg/openvg.pro @@ -0,0 +1,54 @@ +TARGET = qsgopenvgbackend + +QT += gui-private core-private qml-private quick-private + +PLUGIN_TYPE = scenegraph +PLUGIN_CLASS_NAME = QSGOpenVGAdaptation +load(qt_plugin) + +QMAKE_TARGET_PRODUCT = "Qt Quick OpenVG Renderer (Qt $$QT_VERSION)" +QMAKE_TARGET_DESCRIPTION = "Quick OpenVG Renderer for Qt." + +QMAKE_USE += openvg + +OTHER_FILES += $$PWD/openvg.json + +HEADERS += \ + qsgopenvgadaptation_p.h \ + qsgopenvgcontext_p.h \ + qsgopenvgrenderloop_p.h \ + qsgopenvgglyphnode_p.h \ + qopenvgcontext_p.h \ + qsgopenvgrenderer_p.h \ + qsgopenvginternalrectanglenode.h \ + qsgopenvgnodevisitor.h \ + qopenvgmatrix.h \ + qsgopenvgpublicnodes.h \ + qsgopenvginternalimagenode.h \ + qsgopenvgtexture.h \ + qsgopenvglayer.h \ + qsgopenvghelpers.h \ + qsgopenvgfontglyphcache.h \ + qsgopenvgpainternode.h \ + qsgopenvgspritenode.h \ + qsgopenvgrenderable.h + +SOURCES += \ + qsgopenvgadaptation.cpp \ + qsgopenvgcontext.cpp \ + qsgopenvgrenderloop.cpp \ + qsgopenvgglyphnode.cpp \ + qopenvgcontext.cpp \ + qsgopenvgrenderer.cpp \ + qsgopenvginternalrectanglenode.cpp \ + qsgopenvgnodevisitor.cpp \ + qopenvgmatrix.cpp \ + qsgopenvgpublicnodes.cpp \ + qsgopenvginternalimagenode.cpp \ + qsgopenvgtexture.cpp \ + qsgopenvglayer.cpp \ + qsgopenvghelpers.cpp \ + qsgopenvgfontglyphcache.cpp \ + qsgopenvgpainternode.cpp \ + qsgopenvgspritenode.cpp \ + qsgopenvgrenderable.cpp diff --git a/src/plugins/scenegraph/openvg/qopenvgcontext.cpp b/src/plugins/scenegraph/openvg/qopenvgcontext.cpp new file mode 100644 index 0000000000..ea2c24afdb --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgcontext.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 +#include +#include +#include + +#include "qopenvgcontext_p.h" + +QT_BEGIN_NAMESPACE + +QOpenVGContext::QOpenVGContext(QWindow *window) + : m_window(window) +{ + QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + m_display = reinterpret_cast(nativeInterface->nativeResourceForWindow("EglDisplay", window)); + m_surface = reinterpret_cast(nativeInterface->nativeResourceForWindow("EglSurface", window)); + + if (m_display == 0) + qFatal("QOpenVGContext: failed to get EGLDisplay"); + if (m_surface == 0) + qFatal("QOpenVGContext: failed to get EGLSurface"); + + EGLint configID = 0; + if (eglQuerySurface(m_display, m_surface, EGL_CONFIG_ID, &configID)) { + EGLint numConfigs; + const EGLint configAttribs[] = { + EGL_CONFIG_ID, configID, + EGL_NONE + }; + eglChooseConfig(m_display, configAttribs, &m_config, 1, &numConfigs); + } else { + qFatal("QOpenVGContext: failed to get surface config"); + } + + // Create an EGL Context + eglBindAPI(EGL_OPENVG_API); + m_context = eglCreateContext(m_display, m_config, EGL_NO_CONTEXT, 0); + if (!m_context) + qFatal("QOpenVGContext: eglCreateContext failed"); +} + +QOpenVGContext::~QOpenVGContext() +{ + doneCurrent(); + eglDestroyContext(m_display, m_context); +} + +void QOpenVGContext::makeCurrent() +{ + makeCurrent(m_surface); +} + +void QOpenVGContext::makeCurrent(EGLSurface surface) +{ + eglMakeCurrent(m_display, surface, surface, m_context); +} + +void QOpenVGContext::doneCurrent() +{ + eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); +} + +void QOpenVGContext::swapBuffers() +{ + swapBuffers(m_surface); +} + +void QOpenVGContext::swapBuffers(EGLSurface surface) +{ + eglSwapBuffers(m_display, surface); +} + +QWindow *QOpenVGContext::window() const +{ + return m_window; +} + +QImage QOpenVGContext::readFramebuffer(const QSize &size) +{ + QImage framebufferImage(size, QImage::Format_RGB32); + vgReadPixels(framebufferImage.bits(), framebufferImage.bytesPerLine(), VG_sXRGB_8888, 0, 0, size.width(), size.height()); + return framebufferImage.mirrored(false, true); +} + +void QOpenVGContext::getConfigs() +{ + EGLint configsAvailable = 0; + eglGetConfigs(m_display, 0, 0, &configsAvailable); + + QVector configs(configsAvailable); + eglGetConfigs(m_display, configs.data(), configs.size(), &configsAvailable); + + for (EGLConfig config : configs) { + EGLint value; + eglGetConfigAttrib(m_display, config, EGL_CONFIG_ID, &value); + qDebug() << "#################\n" << "EGL_CONFIG_ID:" << value; + eglGetConfigAttrib(m_display, config, EGL_BUFFER_SIZE, &value); + qDebug() << "EGL_BUFFER_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_ALPHA_SIZE, &value); + qDebug() << "EGL_ALPHA_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_RED_SIZE, &value); + qDebug() << "EGL_RED_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_GREEN_SIZE, &value); + qDebug() << "EGL_GREEN_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_BLUE_SIZE, &value); + qDebug() << "EGL_BLUE_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_DEPTH_SIZE, &value); + qDebug() << "EGL_DEPTH_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_STENCIL_SIZE, &value); + qDebug() << "EGL_STENCIL_SIZE:" << value; + + eglGetConfigAttrib(m_display, config, EGL_ALPHA_MASK_SIZE, &value); + qDebug() << "EGL_ALPHA_MASK_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_BIND_TO_TEXTURE_RGB, &value); + qDebug() << "EGL_BIND_TO_TEXTURE_RGB:" << value; + eglGetConfigAttrib(m_display, config, EGL_BIND_TO_TEXTURE_RGBA, &value); + qDebug() << "EGL_BIND_TO_TEXTURE_RGBA:" << value; + + + eglGetConfigAttrib(m_display, config, EGL_COLOR_BUFFER_TYPE, &value); + qDebug() << "EGL_COLOR_BUFFER_TYPE:" << value; + eglGetConfigAttrib(m_display, config, EGL_CONFIG_CAVEAT, &value); + qDebug() << "EGL_CONFIG_CAVEAT:" << value; + eglGetConfigAttrib(m_display, config, EGL_CONFORMANT, &value); + qDebug() << "EGL_CONFORMANT:" << value; + + + eglGetConfigAttrib(m_display, config, EGL_LEVEL, &value); + qDebug() << "EGL_LEVEL:" << value; + eglGetConfigAttrib(m_display, config, EGL_LUMINANCE_SIZE, &value); + qDebug() << "EGL_LUMINANCE_SIZE:" << value; + eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_WIDTH, &value); + qDebug() << "EGL_MAX_PBUFFER_WIDTH:" << value; + eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_HEIGHT, &value); + qDebug() << "EGL_MAX_PBUFFER_HEIGHT:" << value; + eglGetConfigAttrib(m_display, config, EGL_MAX_PBUFFER_PIXELS, &value); + qDebug() << "EGL_MAX_PBUFFER_PIXELS:" << value; + eglGetConfigAttrib(m_display, config, EGL_MAX_SWAP_INTERVAL, &value); + qDebug() << "EGL_MAX_SWAP_INTERVAL:" << value; + eglGetConfigAttrib(m_display, config, EGL_MIN_SWAP_INTERVAL, &value); + qDebug() << "EGL_MIN_SWAP_INTERVAL:" << value; + eglGetConfigAttrib(m_display, config, EGL_NATIVE_RENDERABLE, &value); + qDebug() << "EGL_NATIVE_RENDERABLE:" << value; + eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_ID, &value); + qDebug() << "EGL_NATIVE_VISUAL_ID:" << value; + eglGetConfigAttrib(m_display, config, EGL_NATIVE_VISUAL_TYPE, &value); + qDebug() << "EGL_NATIVE_VISUAL_TYPE:" << value; + eglGetConfigAttrib(m_display, config, EGL_RENDERABLE_TYPE, &value); + qDebug() << "EGL_RENDERABLE_TYPE:" << value; + eglGetConfigAttrib(m_display, config, EGL_SAMPLE_BUFFERS, &value); + qDebug() << "EGL_SAMPLE_BUFFERS:" << value; + eglGetConfigAttrib(m_display, config, EGL_SAMPLES, &value); + qDebug() << "EGL_SAMPLES:" << value; + + eglGetConfigAttrib(m_display, config, EGL_SURFACE_TYPE, &value); + qDebug() << "EGL_SURFACE_TYPE:" << value; + eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_TYPE, &value); + qDebug() << "EGL_TRANSPARENT_TYPE:" << value; + eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_RED_VALUE, &value); + qDebug() << "EGL_TRANSPARENT_RED_VALUE:" << value; + eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_GREEN_VALUE, &value); + qDebug() << "EGL_TRANSPARENT_GREEN_VALUE:" << value; + eglGetConfigAttrib(m_display, config, EGL_TRANSPARENT_BLUE_VALUE, &value); + qDebug() << "EGL_TRANSPARENT_BLUE_VALUE:" << value; + } +} + +void QOpenVGContext::checkErrors() +{ + VGErrorCode error; + EGLint eglError; + do { + error = vgGetError(); + eglError = eglGetError(); + qDebug() << "error: " << QString::number(error, 16); + qDebug() << "eglError: " << QString::number(eglError, 16); + } while (error != VG_NO_ERROR && eglError != EGL_SUCCESS); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qopenvgcontext_p.h b/src/plugins/scenegraph/openvg/qopenvgcontext_p.h new file mode 100644 index 0000000000..a1ba73957f --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgcontext_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QOPENVGCONTEXT_H +#define QOPENVGCONTEXT_H + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QOpenVGContext +{ +public: + QOpenVGContext(QWindow *window); + ~QOpenVGContext(); + + void makeCurrent(); + void makeCurrent(EGLSurface surface); + void doneCurrent(); + void swapBuffers(); + void swapBuffers(EGLSurface surface); + + + QWindow *window() const; + + EGLDisplay eglDisplay() { return m_display; } + EGLConfig eglConfig() { return m_config; } + EGLContext eglContext() { return m_context; } + + QImage readFramebuffer(const QSize &size); + + void getConfigs(); + + static void checkErrors(); + +private: + EGLSurface m_surface; + EGLDisplay m_display; + EGLConfig m_config; + EGLContext m_context; + + QWindow *m_window; + +}; + +QT_END_NAMESPACE + +#endif // QOPENVGCONTEXT_H diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp new file mode 100644 index 0000000000..e55de2ce0d --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp @@ -0,0 +1,325 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qopenvgmatrix.h" + +QT_BEGIN_NAMESPACE + +// QOpenVGMatrix: Because Qt will never have enough matrix classes +// Internally the data is stored as column-major format +// So this is a 3x3 version of QMatrix4x4 for optimal +// OpenVG usage. + +QOpenVGMatrix::QOpenVGMatrix() +{ + setToIdentity(); +} + +QOpenVGMatrix::QOpenVGMatrix(const float *values) +{ + for (int col = 0; col < 3; ++col) + for (int row = 0; row < 3; ++row) + m[col][row] = values[col * 3 + row]; +} + +const float &QOpenVGMatrix::operator()(int row, int column) const +{ + Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4); + return m[column][row]; +} + +float &QOpenVGMatrix::operator()(int row, int column) +{ + Q_ASSERT(row >= 0 && row < 4 && column >= 0 && column < 4); + return m[column][row]; +} + +bool QOpenVGMatrix::isIdentity() const +{ + if (m[0][0] != 1.0f || m[0][1] != 0.0f || m[0][2] != 0.0f) + return false; + if ( m[1][0] != 0.0f || m[1][1] != 1.0f) + return false; + if (m[1][2] != 0.0f || m[2][0] != 0.0f) + return false; + if (m[2][1] != 0.0f || m[2][2] != 1.0f) + return false; + + return true; +} + +void QOpenVGMatrix::setToIdentity() +{ + m[0][0] = 1.0f; + m[0][1] = 0.0f; + m[0][2] = 0.0f; + m[1][0] = 0.0f; + m[1][1] = 1.0f; + m[1][2] = 0.0f; + m[2][0] = 0.0f; + m[2][1] = 0.0f; + m[2][2] = 1.0f; +} + +void QOpenVGMatrix::fill(float value) +{ + m[0][0] = value; + m[0][1] = value; + m[0][2] = value; + m[1][0] = value; + m[1][1] = value; + m[1][2] = value; + m[2][0] = value; + m[2][1] = value; + m[2][2] = value; +} + +QOpenVGMatrix QOpenVGMatrix::transposed() const +{ + QOpenVGMatrix result; + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) + result.m[col][row] = m[row][col]; + } + return result; +} + +QOpenVGMatrix &QOpenVGMatrix::operator+=(const QOpenVGMatrix &other) +{ + m[0][0] += other.m[0][0]; + m[0][1] += other.m[0][1]; + m[0][2] += other.m[0][2]; + m[1][0] += other.m[1][0]; + m[1][1] += other.m[1][1]; + m[1][2] += other.m[1][2]; + m[2][0] += other.m[2][0]; + m[2][1] += other.m[2][1]; + m[2][2] += other.m[2][2]; + return *this; +} + +QOpenVGMatrix &QOpenVGMatrix::operator-=(const QOpenVGMatrix &other) +{ + m[0][0] -= other.m[0][0]; + m[0][1] -= other.m[0][1]; + m[0][2] -= other.m[0][2]; + m[1][0] -= other.m[1][0]; + m[1][1] -= other.m[1][1]; + m[1][2] -= other.m[1][2]; + m[2][0] -= other.m[2][0]; + m[2][1] -= other.m[2][1]; + m[2][2] -= other.m[2][2]; + return *this; +} + +QOpenVGMatrix &QOpenVGMatrix::operator*=(const QOpenVGMatrix &other) +{ + float m0, m1; + m0 = m[0][0] * other.m[0][0] + + m[1][0] * other.m[0][1] + + m[2][0] * other.m[0][2]; + m1 = m[0][0] * other.m[1][0] + + m[1][0] * other.m[1][1] + + m[2][0] * other.m[1][2]; + m[2][0] = m[0][0] * other.m[2][0] + + m[1][0] * other.m[2][1] + + m[2][0] * other.m[2][2]; + m[0][0] = m0; + m[1][0] = m1; + + m0 = m[0][1] * other.m[0][0] + + m[1][1] * other.m[0][1] + + m[2][1] * other.m[0][2]; + m1 = m[0][1] * other.m[1][0] + + m[1][1] * other.m[1][1] + + m[2][1] * other.m[1][2]; + m[2][1] = m[0][1] * other.m[2][0] + + m[1][1] * other.m[2][1] + + m[2][1] * other.m[2][2]; + m[0][1] = m0; + m[1][1] = m1; + + m0 = m[0][2] * other.m[0][0] + + m[1][2] * other.m[0][1] + + m[2][2] * other.m[0][2]; + m1 = m[0][2] * other.m[1][0] + + m[1][2] * other.m[1][1] + + m[2][2] * other.m[1][2]; + m[2][2] = m[0][2] * other.m[2][0] + + m[1][2] * other.m[2][1] + + m[2][2] * other.m[2][2]; + m[0][2] = m0; + m[1][2] = m1; + return *this; +} + +QOpenVGMatrix &QOpenVGMatrix::operator*=(float factor) +{ + m[0][0] *= factor; + m[0][1] *= factor; + m[0][2] *= factor; + m[1][0] *= factor; + m[1][1] *= factor; + m[1][2] *= factor; + m[2][0] *= factor; + m[2][1] *= factor; + m[2][2] *= factor; + return *this; +} + +QOpenVGMatrix &QOpenVGMatrix::operator/=(float divisor) +{ + m[0][0] /= divisor; + m[0][1] /= divisor; + m[0][2] /= divisor; + m[1][0] /= divisor; + m[1][1] /= divisor; + m[1][2] /= divisor; + m[2][0] /= divisor; + m[2][1] /= divisor; + m[2][2] /= divisor; + return *this; +} + +bool QOpenVGMatrix::operator==(const QOpenVGMatrix &other) const +{ + return m[0][0] == other.m[0][0] && + m[0][1] == other.m[0][1] && + m[0][2] == other.m[0][2] && + m[1][0] == other.m[1][0] && + m[1][1] == other.m[1][1] && + m[1][2] == other.m[1][2] && + m[2][0] == other.m[2][0] && + m[2][1] == other.m[2][1] && + m[2][2] == other.m[2][2]; +} + +bool QOpenVGMatrix::operator!=(const QOpenVGMatrix &other) const +{ + return m[0][0] != other.m[0][0] || + m[0][1] != other.m[0][1] || + m[0][2] != other.m[0][2] || + m[1][0] != other.m[1][0] || + m[1][1] != other.m[1][1] || + m[1][2] != other.m[1][2] || + m[2][0] != other.m[2][0] || + m[2][1] != other.m[2][1] || + m[2][2] != other.m[2][2]; +} + +void QOpenVGMatrix::copyDataTo(float *values) const +{ + // Row-Major? + for (int row = 0; row < 3; ++row) { + for (int col = 0; col < 3; ++col) + values[row * 3 + col] = float(m[col][row]); + } +} + +QOpenVGMatrix operator*(const QOpenVGMatrix &m1, const QOpenVGMatrix &m2) +{ + QOpenVGMatrix matrix; + matrix.m[0][0] = m1.m[0][0] * m2.m[0][0] + + m1.m[1][0] * m2.m[0][1] + + m1.m[2][0] * m2.m[0][2]; + matrix.m[0][1] = m1.m[0][1] * m2.m[0][0] + + m1.m[1][1] * m2.m[0][1] + + m1.m[2][1] * m2.m[0][2]; + matrix.m[0][2] = m1.m[0][2] * m2.m[0][0] + + m1.m[1][2] * m2.m[0][1] + + m1.m[2][2] * m2.m[0][2]; + + matrix.m[1][0] = m1.m[0][0] * m2.m[1][0] + + m1.m[1][0] * m2.m[1][1] + + m1.m[2][0] * m2.m[1][2]; + matrix.m[1][1] = m1.m[0][1] * m2.m[1][0] + + m1.m[1][1] * m2.m[1][1] + + m1.m[2][1] * m2.m[1][2]; + matrix.m[1][2] = m1.m[0][2] * m2.m[1][0] + + m1.m[1][2] * m2.m[1][1] + + m1.m[2][2] * m2.m[1][2]; + + matrix.m[2][0] = m1.m[0][0] * m2.m[2][0] + + m1.m[1][0] * m2.m[2][1] + + m1.m[2][0] * m2.m[2][2]; + matrix.m[2][1] = m1.m[0][1] * m2.m[2][0] + + m1.m[1][1] * m2.m[2][1] + + m1.m[2][1] * m2.m[2][2]; + matrix.m[2][2] = m1.m[0][2] * m2.m[2][0] + + m1.m[1][2] * m2.m[2][1] + + m1.m[2][2] * m2.m[2][2]; + return matrix; +} + +QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m) +{ + QDebugStateSaver saver(dbg); + // Output in row-major order because it is more human-readable. + dbg.nospace() << "QOpenVGMatrix:(" << endl + << qSetFieldWidth(10) + << m(0, 0) << m(0, 1) << m(0, 2) << endl + << m(1, 0) << m(1, 1) << m(1, 2) << endl + << m(2, 0) << m(2, 1) << m(2, 2) << endl + << qSetFieldWidth(0) << ')'; + return dbg; +} + +QDataStream &operator<<(QDataStream &stream, const QOpenVGMatrix &matrix) +{ + for (int row = 0; row < 3; ++row) + for (int col = 0; col < 3; ++col) + stream << matrix(row, col); + return stream; +} + + +QDataStream &operator>>(QDataStream &stream, QOpenVGMatrix &matrix) +{ + float x; + for (int row = 0; row < 4; ++row) { + for (int col = 0; col < 4; ++col) { + stream >> x; + matrix(row, col) = x; + } + } + return stream; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.h b/src/plugins/scenegraph/openvg/qopenvgmatrix.h new file mode 100644 index 0000000000..644c9da5bc --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QOPENVGMATRIX_H +#define QOPENVGMATRIX_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QOpenVGMatrix +{ +public: + QOpenVGMatrix(); + explicit QOpenVGMatrix(const float *values); + + const float& operator()(int row, int column) const; + float& operator()(int row, int column); + + bool isIdentity() const; + void setToIdentity(); + + void fill(float value); + + QOpenVGMatrix transposed() const; + + QOpenVGMatrix& operator+=(const QOpenVGMatrix& other); + QOpenVGMatrix& operator-=(const QOpenVGMatrix& other); + QOpenVGMatrix& operator*=(const QOpenVGMatrix& other); + QOpenVGMatrix& operator*=(float factor); + QOpenVGMatrix& operator/=(float divisor); + friend QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2); +#ifndef QT_NO_DEBUG_STREAM + friend QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m); +#endif + bool operator==(const QOpenVGMatrix& other) const; + bool operator!=(const QOpenVGMatrix& other) const; + + void copyDataTo(float *values) const; + + float *data() { return *m; } + const float *data() const { return *m; } + const float *constData() const { return *m; } + +private: + float m[3][3]; +}; + +QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2); + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m); +#endif + +#ifndef QT_NO_DATASTREAM +QDataStream &operator<<(QDataStream &, const QOpenVGMatrix &); +QDataStream &operator>>(QDataStream &, QOpenVGMatrix &); +#endif + +QT_END_NAMESPACE + +#endif // QOPENVGMATRIX_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp b/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp new file mode 100644 index 0000000000..1a26522459 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgadaptation.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgadaptation_p.h" + +#include "qsgopenvgcontext_p.h" +#include "qsgopenvgrenderloop_p.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGAdaptation::QSGOpenVGAdaptation(QObject *parent) + : QSGContextPlugin(parent) +{ +} + +QStringList QSGOpenVGAdaptation::keys() const +{ + return QStringList() << QLatin1String("openvg"); +} + +QSGContext *QSGOpenVGAdaptation::create(const QString &key) const +{ + Q_UNUSED(key) + if (!instance) + instance = new QSGOpenVGContext(); + return instance; +} + +QSGRenderLoop *QSGOpenVGAdaptation::createWindowManager() +{ + return new QSGOpenVGRenderLoop(); +} + +QSGContextFactoryInterface::Flags QSGOpenVGAdaptation::flags(const QString &key) const +{ + Q_UNUSED(key) + return 0; +} + +QSGOpenVGContext *QSGOpenVGAdaptation::instance = nullptr; + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h b/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h new file mode 100644 index 0000000000..77f79af9ac --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgadaptation_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGADAPTATION_H +#define QSGOPENVGADAPTATION_H + +#include + +QT_BEGIN_NAMESPACE + +class QSGContext; +class QSGRenderLoop; +class QSGOpenVGContext; + +class QSGOpenVGAdaptation : public QSGContextPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSGContextFactoryInterface" FILE "openvg.json") +public: + QSGOpenVGAdaptation(QObject *parent = nullptr); + + QStringList keys() const override; + QSGContext *create(const QString &key) const override; + QSGRenderLoop *createWindowManager() override; + Flags flags(const QString &key) const override; +private: + static QSGOpenVGContext *instance; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGADAPTATION_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp b/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp new file mode 100644 index 0000000000..22a80c62e8 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgcontext_p.h" +#include "qsgopenvgrenderer_p.h" +#include "qsgopenvginternalrectanglenode.h" +#include "qsgopenvginternalimagenode.h" +#include "qsgopenvgpublicnodes.h" +#include "qsgopenvgtexture.h" +#include "qsgopenvglayer.h" +#include "qsgopenvgglyphnode_p.h" +#include "qsgopenvgfontglyphcache.h" +#include "qsgopenvgpainternode.h" +#include "qsgopenvgspritenode.h" + +#include "qopenvgcontext_p.h" + +#include + +// polish, animations, sync, render and swap in the render loop +Q_LOGGING_CATEGORY(QSG_OPENVG_LOG_TIME_RENDERLOOP, "qt.scenegraph.time.renderloop") + +QT_BEGIN_NAMESPACE + +QSGOpenVGRenderContext::QSGOpenVGRenderContext(QSGContext *context) + : QSGRenderContext(context) + , m_vgContext(nullptr) + , m_glyphCacheManager(nullptr) +{ + +} + +void QSGOpenVGRenderContext::initialize(void *context) +{ + m_vgContext = static_cast(context); + QSGRenderContext::initialize(context); +} + +void QSGOpenVGRenderContext::invalidate() +{ + m_vgContext = nullptr; + delete m_glyphCacheManager; + m_glyphCacheManager = nullptr; + QSGRenderContext::invalidate(); +} + +void QSGOpenVGRenderContext::renderNextFrame(QSGRenderer *renderer, uint fboId) +{ + renderer->renderScene(fboId); +} + +QSGTexture *QSGOpenVGRenderContext::createTexture(const QImage &image, uint flags) const +{ + QImage tmp = image; + + // Make sure image is not larger than maxTextureSize + int maxSize = maxTextureSize(); + if (tmp.width() > maxSize || tmp.height() > maxSize) { + tmp = tmp.scaled(qMin(maxSize, tmp.width()), qMin(maxSize, tmp.height()), Qt::IgnoreAspectRatio, Qt::FastTransformation); + } + + return new QSGOpenVGTexture(tmp, flags); +} + +QSGRenderer *QSGOpenVGRenderContext::createRenderer() +{ + return new QSGOpenVGRenderer(this); +} + +QSGOpenVGContext::QSGOpenVGContext(QObject *parent) +{ + Q_UNUSED(parent) +} + +QSGRenderContext *QSGOpenVGContext::createRenderContext() +{ + return new QSGOpenVGRenderContext(this); +} + +QSGRectangleNode *QSGOpenVGContext::createRectangleNode() +{ + return new QSGOpenVGRectangleNode; +} + +QSGImageNode *QSGOpenVGContext::createImageNode() +{ + return new QSGOpenVGImageNode; +} + +QSGPainterNode *QSGOpenVGContext::createPainterNode(QQuickPaintedItem *item) +{ + Q_UNUSED(item) + return new QSGOpenVGPainterNode(item); +} + +QSGGlyphNode *QSGOpenVGContext::createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) +{ + Q_UNUSED(preferNativeGlyphNode) + return new QSGOpenVGGlyphNode(rc); +} + +QSGNinePatchNode *QSGOpenVGContext::createNinePatchNode() +{ + return new QSGOpenVGNinePatchNode; +} + +QSGLayer *QSGOpenVGContext::createLayer(QSGRenderContext *renderContext) +{ + return new QSGOpenVGLayer(renderContext); +} + +QSurfaceFormat QSGOpenVGContext::defaultSurfaceFormat() const +{ + QSurfaceFormat format = QSurfaceFormat::defaultFormat(); + format.setRenderableType(QSurfaceFormat::OpenVG); + format.setMajorVersion(1); + return format; +} + +QSGInternalRectangleNode *QSGOpenVGContext::createInternalRectangleNode() +{ + return new QSGOpenVGInternalRectangleNode(); +} + +QSGInternalImageNode *QSGOpenVGContext::createInternalImageNode() +{ + return new QSGOpenVGInternalImageNode(); +} + +int QSGOpenVGRenderContext::maxTextureSize() const +{ + VGint width = vgGeti(VG_MAX_IMAGE_WIDTH); + VGint height = vgGeti(VG_MAX_IMAGE_HEIGHT); + + return qMin(width, height); +} + + +QSGSpriteNode *QSGOpenVGContext::createSpriteNode() +{ + return new QSGOpenVGSpriteNode(); +} + +QSGRendererInterface *QSGOpenVGContext::rendererInterface(QSGRenderContext *renderContext) +{ + return static_cast(renderContext); +} + +QSGRendererInterface::GraphicsApi QSGOpenVGRenderContext::graphicsApi() const +{ + return OpenVG; +} + +QSGRendererInterface::ShaderType QSGOpenVGRenderContext::shaderType() const +{ + return UnknownShadingLanguage; +} + +QSGRendererInterface::ShaderCompilationTypes QSGOpenVGRenderContext::shaderCompilationType() const +{ + return 0; +} + +QSGRendererInterface::ShaderSourceTypes QSGOpenVGRenderContext::shaderSourceType() const +{ + return 0; +} + +QSGOpenVGFontGlyphCache *QSGOpenVGRenderContext::glyphCache(const QRawFont &rawFont) +{ + if (!m_glyphCacheManager) + m_glyphCacheManager = new QSGOpenVGFontGlyphCacheManager; + + QSGOpenVGFontGlyphCache *cache = m_glyphCacheManager->cache(rawFont); + if (!cache) { + cache = new QSGOpenVGFontGlyphCache(m_glyphCacheManager, rawFont); + m_glyphCacheManager->insertCache(rawFont, cache); + } + + return cache; +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h b/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h new file mode 100644 index 0000000000..fa9939a253 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgcontext_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGCONTEXT_H +#define QSGOPENVGCONTEXT_H + +#include +#include + +Q_DECLARE_LOGGING_CATEGORY(QSG_OPENVG_LOG_TIME_RENDERLOOP) + +QT_BEGIN_NAMESPACE + +class QOpenVGContext; +class QSGOpenVGFontGlyphCache; +class QSGOpenVGFontGlyphCacheManager; + +class QSGOpenVGRenderContext : public QSGRenderContext, public QSGRendererInterface +{ + Q_OBJECT +public: + QSGOpenVGRenderContext(QSGContext *context); + + void initialize(void *context) override; + void invalidate() override; + void renderNextFrame(QSGRenderer *renderer, uint fboId) override; + QSGTexture *createTexture(const QImage &image, uint flags) const override; + QSGRenderer *createRenderer() override; + int maxTextureSize() const override; + + // QSGRendererInterface interface + GraphicsApi graphicsApi() const override; + ShaderType shaderType() const override; + ShaderCompilationTypes shaderCompilationType() const override; + ShaderSourceTypes shaderSourceType() const override; + + QOpenVGContext* vgContext() { return m_vgContext; } + QSGOpenVGFontGlyphCache* glyphCache(const QRawFont &rawFont); + +private: + QOpenVGContext *m_vgContext; + QSGOpenVGFontGlyphCacheManager *m_glyphCacheManager; + +}; + +class QSGOpenVGContext : public QSGContext +{ + Q_OBJECT +public: + QSGOpenVGContext(QObject *parent = nullptr); + + QSGRenderContext *createRenderContext() override; + QSGRectangleNode *createRectangleNode() override; + QSGImageNode *createImageNode() override; + QSGPainterNode *createPainterNode(QQuickPaintedItem *item) override; + QSGGlyphNode *createGlyphNode(QSGRenderContext *rc, bool preferNativeGlyphNode) override; + QSGNinePatchNode *createNinePatchNode() override; + QSGLayer *createLayer(QSGRenderContext *renderContext) override; + QSurfaceFormat defaultSurfaceFormat() const override; + QSGInternalRectangleNode *createInternalRectangleNode() override; + QSGInternalImageNode *createInternalImageNode() override; + QSGSpriteNode *createSpriteNode() override; + QSGRendererInterface *rendererInterface(QSGRenderContext *renderContext) override; +}; + +#endif // QSGOPENVGCONTEXT_H + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp new file mode 100644 index 0000000000..1ed54f7b6a --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp @@ -0,0 +1,185 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgfontglyphcache.h" +#include "qsgopenvghelpers.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QSGOpenVGFontGlyphCacheManager::QSGOpenVGFontGlyphCacheManager() +{ + +} + +QSGOpenVGFontGlyphCacheManager::~QSGOpenVGFontGlyphCacheManager() +{ + qDeleteAll(m_caches); +} + +QSGOpenVGFontGlyphCache *QSGOpenVGFontGlyphCacheManager::cache(const QRawFont &font) +{ + return m_caches.value(fontKey(font), nullptr); +} + +void QSGOpenVGFontGlyphCacheManager::insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache) +{ + m_caches.insert(fontKey(font), cache); +} + +QString QSGOpenVGFontGlyphCacheManager::fontKey(const QRawFont &font) +{ + QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; + if (!fe->faceId().filename.isEmpty()) { + QByteArray keyName = fe->faceId().filename; + if (font.style() != QFont::StyleNormal) + keyName += QByteArray(" I"); + if (font.weight() != QFont::Normal) + keyName += ' ' + QByteArray::number(font.weight()); + keyName += " " + QString::number(font.pixelSize()); + keyName += QByteArray(" DF"); + return QString::fromUtf8(keyName); + } else { + return QString::fromLatin1("%1_%2_%3_%4_%5") + .arg(font.familyName()) + .arg(font.styleName()) + .arg(font.weight()) + .arg(font.style()) + .arg(font.pixelSize()); + } +} + + +QSGOpenVGFontGlyphCache::QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font) + : m_manager(manager) +{ + m_referenceFont = font; + QRawFontPrivate *fontD = QRawFontPrivate::get(font); + m_glyphCount = fontD->fontEngine->glyphCount(); + m_font = vgCreateFont(0); +} + +QSGOpenVGFontGlyphCache::~QSGOpenVGFontGlyphCache() +{ + if (m_font != VG_INVALID_HANDLE) + vgDestroyFont(m_font); +} + +void QSGOpenVGFontGlyphCache::populate(const QVector &glyphs) +{ + QSet referencedGlyphs; + QSet newGlyphs; + int count = glyphs.count(); + for (int i = 0; i < count; ++i) { + quint32 glyphIndex = glyphs.at(i); + if ((int) glyphIndex >= glyphCount()) { + qWarning("Warning: glyph is not available with index %d", glyphIndex); + continue; + } + + referencedGlyphs.insert(glyphIndex); + + + if (!m_cachedGlyphs.contains(glyphIndex)) { + newGlyphs.insert(glyphIndex); + } + } + + referenceGlyphs(referencedGlyphs); + if (!newGlyphs.isEmpty()) + requestGlyphs(newGlyphs); +} + +void QSGOpenVGFontGlyphCache::release(const QVector &glyphs) +{ + QSet unusedGlyphs; + int count = glyphs.count(); + for (int i = 0; i < count; ++i) { + quint32 glyphIndex = glyphs.at(i); + unusedGlyphs.insert(glyphIndex); + } + releaseGlyphs(unusedGlyphs); +} + +void QSGOpenVGFontGlyphCache::requestGlyphs(const QSet &glyphs) +{ + VGfloat origin[2]; + VGfloat escapement[2]; + QRectF metrics; + QRawFont rawFont = m_referenceFont; + + // Before adding any new glyphs, remove any unused glyphs + for (auto glyph : qAsConst(m_unusedGlyphs)) { + vgClearGlyph(m_font, glyph); + } + + for (auto glyph : glyphs) { + m_cachedGlyphs.insert(glyph); + + // Calculate the path for the glyph and cache it. + QPainterPath path = rawFont.pathForGlyph(glyph); + VGPath vgPath; + if (!path.isEmpty()) { + vgPath = QSGOpenVGHelpers::qPainterPathToVGPath(path); + } else { + // Probably a "space" character with no visible outline. + vgPath = VG_INVALID_HANDLE; + } + origin[0] = 0; + origin[1] = 0; + escapement[0] = 0; + escapement[1] = 0; + vgSetGlyphToPath(m_font, glyph, vgPath, VG_FALSE, origin, escapement); + vgDestroyPath(vgPath); // Reduce reference count. + } + +} + +void QSGOpenVGFontGlyphCache::referenceGlyphs(const QSet &glyphs) +{ + m_unusedGlyphs -= glyphs; +} + +void QSGOpenVGFontGlyphCache::releaseGlyphs(const QSet &glyphs) +{ + m_unusedGlyphs += glyphs; +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h new file mode 100644 index 0000000000..a4a51cd2b6 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGFONTGLYPHCACHE_H +#define QSGOPENVGFONTGLYPHCACHE_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGFontGlyphCache; + +class QSGOpenVGFontGlyphCacheManager +{ +public: + QSGOpenVGFontGlyphCacheManager(); + ~QSGOpenVGFontGlyphCacheManager(); + + QSGOpenVGFontGlyphCache *cache(const QRawFont &font); + void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache); + +private: + static QString fontKey(const QRawFont &font); + + QHash m_caches; +}; + +class QSGOpenVGFontGlyphCache +{ +public: + QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font); + ~QSGOpenVGFontGlyphCache(); + + const QSGOpenVGFontGlyphCacheManager *manager() const { return m_manager; } + const QRawFont &referenceFont() const { return m_referenceFont; } + int glyphCount() const { return m_glyphCount; } + + void populate(const QVector &glyphs); + void release(const QVector &glyphs); + + VGFont font() { return m_font; } + +private: + void requestGlyphs(const QSet &glyphs); + void referenceGlyphs(const QSet &glyphs); + void releaseGlyphs(const QSet &glyphs); + + QSGOpenVGFontGlyphCacheManager *m_manager; + QRawFont m_referenceFont; + int m_glyphCount; + + VGFont m_font; + QSet m_cachedGlyphs; + QSet m_unusedGlyphs; +}; + + +QT_END_NAMESPACE + +#endif // QSGOPENVGFONTGLYPHCACHE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp new file mode 100644 index 0000000000..c90f0f0bbe --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgglyphnode_p.h" +#include "qopenvgcontext_p.h" +#include "qsgopenvgcontext_p.h" +#include "qsgopenvghelpers.h" +#include "qsgopenvgfontglyphcache.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGGlyphNode::QSGOpenVGGlyphNode(QSGRenderContext *rc) + : m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0) + , m_style(QQuickText::Normal) + , m_glyphCache(nullptr) +{ + // Set Dummy material to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry(&m_geometry); + m_fontColorPaint = vgCreatePaint(); + m_styleColorPaint = vgCreatePaint(); + + // Get handle to Glyph Cache + m_renderContext = static_cast(rc); +} + +QSGOpenVGGlyphNode::~QSGOpenVGGlyphNode() +{ + if (m_glyphCache) + m_glyphCache->release(m_glyphRun.glyphIndexes()); + + vgDestroyPaint(m_fontColorPaint); + vgDestroyPaint(m_styleColorPaint); +} + +void QSGOpenVGGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &glyphs) +{ + // Obtain glyph cache for font + auto oldGlyphCache = m_glyphCache; + m_glyphCache = m_renderContext->glyphCache(glyphs.rawFont()); + if (m_glyphCache != oldGlyphCache) { + if (oldGlyphCache) + oldGlyphCache->release(m_glyphRun.glyphIndexes()); + } + m_glyphCache->populate(glyphs.glyphIndexes()); + + m_position = position; + m_glyphRun = glyphs; + + // Recreate ajustments + m_xAdjustments.clear(); + m_yAdjustments.clear(); + + for (int i = 1; i < glyphs.positions().count(); ++i) { + m_xAdjustments.append(glyphs.positions().at(i).x() - glyphs.positions().at(i-1).x()); + m_yAdjustments.append(glyphs.positions().at(i).y() - glyphs.positions().at(i-1).y()); + } +} + +void QSGOpenVGGlyphNode::setColor(const QColor &color) +{ + m_color = color; + vgSetParameteri(m_fontColorPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); + vgSetParameterfv(m_fontColorPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_color, opacity()).constData()); +} + +void QSGOpenVGGlyphNode::setStyle(QQuickText::TextStyle style) +{ + m_style = style; +} + +void QSGOpenVGGlyphNode::setStyleColor(const QColor &color) +{ + m_styleColor = color; + vgSetParameteri(m_styleColorPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); + vgSetParameterfv(m_styleColorPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_styleColor, opacity()).constData()); +} + +QPointF QSGOpenVGGlyphNode::baseLine() const +{ + return QPointF(); +} + +void QSGOpenVGGlyphNode::setPreferredAntialiasingMode(QSGGlyphNode::AntialiasingMode) +{ +} + +void QSGOpenVGGlyphNode::update() +{ +} + +void QSGOpenVGGlyphNode::render() +{ + if (m_glyphRun.positions().count() == 0) + return; + + // Rendering Style + qreal offset = 1.0; + + vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); + + switch (m_style) { + case QQuickText::Normal: break; + case QQuickText::Outline: + // Set the correct fill state + vgSetPaint(m_styleColorPaint, VG_FILL_PATH); + drawGlyphsAtOffset(QPointF(0, offset)); + drawGlyphsAtOffset(QPointF(0, -offset)); + drawGlyphsAtOffset(QPointF(offset, 0)); + drawGlyphsAtOffset(QPointF(-offset, 0)); + break; + case QQuickText::Raised: + vgSetPaint(m_styleColorPaint, VG_FILL_PATH); + drawGlyphsAtOffset(QPointF(0, offset)); + break; + case QQuickText::Sunken: + vgSetPaint(m_styleColorPaint, VG_FILL_PATH); + drawGlyphsAtOffset(QPointF(0, -offset)); + break; + } + + // Set the correct fill state + vgSetPaint(m_fontColorPaint, VG_FILL_PATH); + drawGlyphsAtOffset(QPointF(0.0, 0.0)); + +} + +void QSGOpenVGGlyphNode::setOpacity(float opacity) +{ + if (QSGOpenVGRenderable::opacity() != opacity) { + QSGOpenVGRenderable::setOpacity(opacity); + // Update Colors + setColor(m_color); + setStyleColor(m_styleColor); + } +} + +void QSGOpenVGGlyphNode::drawGlyphsAtOffset(const QPointF &offset) +{ + QPointF firstPosition = m_glyphRun.positions()[0] + (m_position - QPointF(0, m_glyphRun.rawFont().ascent())); + VGfloat origin[2]; + origin[0] = firstPosition.x() + offset.x(); + origin[1] = firstPosition.y() + offset.y(); + vgSetfv(VG_GLYPH_ORIGIN, 2, origin); + + vgDrawGlyphs(m_glyphCache->font(), + m_glyphRun.glyphIndexes().count(), + (VGuint*)m_glyphRun.glyphIndexes().constData(), + m_xAdjustments.constData(), + m_yAdjustments.constData(), + VG_FILL_PATH, + VG_TRUE); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h new file mode 100644 index 0000000000..205e3dcbc8 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGGLYPHNODE_H +#define QSGOPENVGGLYPHNODE_H + +#include +#include + +#include + +#include "qsgopenvgrenderable.h" +#include "qsgopenvgfontglyphcache.h" + +QT_BEGIN_NAMESPACE + +class QSGOpenVGFontGlyphCache; +class QSGOpenVGRenderContext; +class QSGRenderContext; + +class QSGOpenVGGlyphNode : public QSGGlyphNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGGlyphNode(QSGRenderContext *rc); + ~QSGOpenVGGlyphNode(); + + void setGlyphs(const QPointF &position, const QGlyphRun &glyphs) override; + void setColor(const QColor &color) override; + void setStyle(QQuickText::TextStyle style) override; + void setStyleColor(const QColor &color) override; + QPointF baseLine() const override; + void setPreferredAntialiasingMode(AntialiasingMode) override; + void update() override; + + void render() override; + void setOpacity(float opacity) override; + +private: + void drawGlyphsAtOffset(const QPointF &offset); + + QPointF m_position; + QGlyphRun m_glyphRun; + QColor m_color; + QSGGeometry m_geometry; + QQuickText::TextStyle m_style; + QColor m_styleColor; + + QSGOpenVGFontGlyphCache *m_glyphCache; + QVector m_xAdjustments; + QVector m_yAdjustments; + VGPaint m_fontColorPaint; + VGPaint m_styleColorPaint; + + QSGOpenVGRenderContext *m_renderContext; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGGLYPHNODE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp new file mode 100644 index 0000000000..6bc99d32a1 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvghelpers.cpp @@ -0,0 +1,433 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvghelpers.h" +#include + +QT_BEGIN_NAMESPACE + +namespace QSGOpenVGHelpers { + +VGPath qPainterPathToVGPath(const QPainterPath &path) +{ + int count = path.elementCount(); + + VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD, + VG_PATH_DATATYPE_F, + 1.0f, // scale + 0.0f, // bias + count + 1, // segmentCapacityHint + count * 2, // coordCapacityHint + VG_PATH_CAPABILITY_ALL); + + if (count == 0) + return vgpath; + + QVector coords; + QVector segments; + + int curvePos = 0; + QPointF temp; + + // Keep track of the start and end of each sub-path. QPainterPath + // does not have an "implicit close" flag like QVectorPath does. + // We therefore have to detect closed paths by looking for a LineTo + // element that connects back to the initial MoveTo element. + qreal startx = 0.0; + qreal starty = 0.0; + qreal endx = 0.0; + qreal endy = 0.0; + bool haveStart = false; + bool haveEnd = false; + + for (int i = 0; i < count; ++i) { + const QPainterPath::Element element = path.elementAt(i); + switch (element.type) { + + case QPainterPath::MoveToElement: + { + if (haveStart && haveEnd && startx == endx && starty == endy) { + // Implicitly close the previous sub-path. + segments.append(VG_CLOSE_PATH); + } + temp = QPointF(element.x, element.y); + startx = temp.x(); + starty = temp.y(); + coords.append(startx); + coords.append(starty); + haveStart = true; + haveEnd = false; + segments.append(VG_MOVE_TO_ABS); + } + break; + + case QPainterPath::LineToElement: + { + temp = QPointF(element.x, element.y); + endx = temp.x(); + endy = temp.y(); + coords.append(endx); + coords.append(endy); + haveEnd = true; + segments.append(VG_LINE_TO_ABS); + } + break; + + case QPainterPath::CurveToElement: + { + temp = QPointF(element.x, element.y); + coords.append(temp.x()); + coords.append(temp.y()); + haveEnd = false; + curvePos = 2; + } + break; + + case QPainterPath::CurveToDataElement: + { + temp = QPointF(element.x, element.y); + coords.append(temp.x()); + coords.append(temp.y()); + haveEnd = false; + curvePos += 2; + if (curvePos == 6) { + curvePos = 0; + segments.append(VG_CUBIC_TO_ABS); + } + } + break; + + } + } + + if (haveStart && haveEnd && startx == endx && starty == endy) { + // Implicitly close the last sub-path. + segments.append(VG_CLOSE_PATH); + } + + vgAppendPathData(vgpath, segments.count(), + segments.constData(), coords.constData()); + + return vgpath; +} + + +void qDrawTiled(VGImage image, const QSize imageSize, const QRectF &targetRect, const QPointF offset, float scaleX, float scaleY) { + + //Check for valid image size and targetRect + if (imageSize.width() <= 0 || imageSize.height() <= 0) + return; + if (targetRect.width() <= 0 || targetRect.height() <= 0) + return; + + // This logic is mostly from the Qt Raster PaintEngine's qt_draw_tile + qreal drawH; + qreal drawW; + qreal xPos; + qreal xOff; + qreal yPos = targetRect.y(); + qreal yOff; + + if (offset.y() < 0) + yOff = imageSize.height() - qRound(-offset.y()) % imageSize.height(); + else + yOff = qRound(offset.y()) % imageSize.height(); + + + // Save the current image transform matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + QVector originalMatrix(9); + vgGetMatrix(originalMatrix.data()); + + while (!qFuzzyCompare(yPos, targetRect.y() + targetRect.height()) && + yPos < targetRect.y() + targetRect.height()) { + drawH = imageSize.height() - yOff; // Cropping first row + if (yPos + drawH * scaleY > targetRect.y() + targetRect.height()) { // Cropping last row + // Check that values aren't equal + if (!qFuzzyCompare((float)(yPos + drawH * scaleY), (float)(targetRect.y() + targetRect.height()))) + drawH = targetRect.y() + targetRect.height() - yPos; + } + xPos = targetRect.x(); + if (offset.x() < 0) + xOff = imageSize.width() - qRound(-offset.x()) % imageSize.width(); + else + xOff = qRound(offset.x()) % imageSize.width(); + + while (!qFuzzyCompare(xPos, targetRect.x() + targetRect.width()) && + xPos < targetRect.x() + targetRect.width()) { + drawW = imageSize.width() - xOff; // Cropping first column + if (xPos + drawW * scaleX > targetRect.x() + targetRect.width()) { + // Check that values aren't equal + if (!qFuzzyCompare((float)(xPos + drawW * scaleX), (float)(targetRect.x() + targetRect.width()))) + drawW = targetRect.x() + targetRect.width() - xPos; + } + if (round(drawW) > 0 && round(drawH) > 0) { // Can't source image less than 1 width or height + //Draw here + VGImage childRectImage = vgChildImage(image, xOff, yOff, round(drawW), round(drawH)); + vgTranslate(xPos, yPos); + vgScale(scaleX, scaleY); + vgDrawImage(childRectImage); + vgDestroyImage(childRectImage); + vgLoadMatrix(originalMatrix.constData()); + } + if ( drawW > 0) + xPos += drawW * scaleX; + xOff = 0; + } + if ( drawH > 0) + yPos += drawH * scaleY; + yOff = 0; + + } +} + +void qDrawBorderImage(VGImage image, const QSizeF &textureSize, const QRectF &targetRect, const QRectF &innerTargetRect, const QRectF &subSourceRect) +{ + // Create normalized margins + QMarginsF margins(qMax(innerTargetRect.left() - targetRect.left(), 0.0), + qMax(innerTargetRect.top() - targetRect.top(), 0.0), + qMax(targetRect.right() - innerTargetRect.right(), 0.0), + qMax(targetRect.bottom() - innerTargetRect.bottom(), 0.0)); + + QRectF sourceRect(0, 0, textureSize.width(), textureSize.height()); + + // Create all the subRects + QRectF topLeftSourceRect(sourceRect.topLeft(), QSizeF(margins.left(), margins.top())); + QRectF topRightSourceRect(sourceRect.width() - margins.right(), sourceRect.top(), margins.right(), margins.top()); + QRectF bottomLeftSourceRect(sourceRect.left(), sourceRect.height() - margins.bottom(), margins.left(), margins.bottom()); + QRectF bottomRightSourceRect(sourceRect.width() - margins.right(), sourceRect.height() - margins.bottom(), margins.right(), margins.bottom()); + + QRectF topSourceRect(margins.left(), 0.0, sourceRect.width() - (margins.right() + margins.left()), margins.top()); + QRectF topTargetRect(margins.left(), 0.0, innerTargetRect.width(), margins.top()); + QRectF bottomSourceRect(margins.left(), sourceRect.height() - margins.bottom(), sourceRect.width() - (margins.right() + margins.left()), margins.bottom()); + QRectF bottomTargetRect(margins.left(), targetRect.height() - margins.bottom(), innerTargetRect.width(), margins.bottom()); + QRectF leftSourceRect(0.0, margins.top(), margins.left(), sourceRect.height() - (margins.bottom() + margins.top())); + QRectF leftTargetRect(0.0, margins.top(), margins.left(), innerTargetRect.height()); + QRectF rightSourceRect(sourceRect.width() - margins.right(), margins.top(), margins.right(), sourceRect.height() - (margins.bottom() + margins.top())); + QRectF rightTargetRect(targetRect.width() - margins.right(), margins.top(), margins.right(), innerTargetRect.height()); + + QRectF centerSourceRect(margins.left(), margins.top(), sourceRect.width() - (margins.right() + margins.left()), sourceRect.height() - (margins.top() + margins.bottom())); + + // Draw the 9 different sections + // (1) Top Left (unscaled) + qDrawSubImage(image, + topLeftSourceRect, + targetRect.topLeft()); + + // (3) Top Right (unscaled) + qDrawSubImage(image, + topRightSourceRect, + QPointF(targetRect.width() - margins.right(), 0.0)); + + // (7) Bottom Left (unscaled) + qDrawSubImage(image, + bottomLeftSourceRect, + QPointF(targetRect.left(), targetRect.height() - margins.bottom())); + + // (9) Bottom Right (unscaled) + qDrawSubImage(image, + bottomRightSourceRect, + QPointF(targetRect.width() - margins.right(), targetRect.height() - margins.bottom())); + + double scaledWidth = 1.0; + double scaledHeight = 1.0; + + // (2) Top (scaled via horizontalTileRule) + VGImage topImage = vgChildImage(image, topSourceRect.x(), topSourceRect.y(), topSourceRect.width(), topSourceRect.height()); + scaledWidth = (topTargetRect.width() / subSourceRect.width()) / topSourceRect.width(); + + QSGOpenVGHelpers::qDrawTiled(topImage, topSourceRect.size().toSize(), topTargetRect, QPoint(0.0, 0.0), scaledWidth, 1); + + vgDestroyImage(topImage); + + // (8) Bottom (scaled via horizontalTileRule) + VGImage bottomImage = vgChildImage(image, bottomSourceRect.x(), bottomSourceRect.y(), bottomSourceRect.width(), bottomSourceRect.height()); + scaledWidth = (bottomTargetRect.width() / subSourceRect.width()) / bottomSourceRect.width(); + + QSGOpenVGHelpers::qDrawTiled(bottomImage, bottomSourceRect.size().toSize(), bottomTargetRect, QPoint(0.0, 0.0), scaledWidth, 1); + + vgDestroyImage(bottomImage); + + // (4) Left (scaled via verticalTileRule) + VGImage leftImage = vgChildImage(image, leftSourceRect.x(), leftSourceRect.y(), leftSourceRect.width(), leftSourceRect.height()); + scaledHeight = (leftTargetRect.height() / subSourceRect.height()) / leftSourceRect.height(); + QSGOpenVGHelpers::qDrawTiled(leftImage, leftSourceRect.size().toSize(), leftTargetRect, QPointF(0.0, 0.0), 1, scaledHeight); + + vgDestroyImage(leftImage); + + // (6) Right (scaled via verticalTileRule) + VGImage rightImage = vgChildImage(image, rightSourceRect.x(), rightSourceRect.y(), rightSourceRect.width(), rightSourceRect.height()); + scaledHeight = (rightTargetRect.height() / subSourceRect.height()) / rightSourceRect.height(); + + QSGOpenVGHelpers::qDrawTiled(rightImage, rightSourceRect.size().toSize(), rightTargetRect, QPointF(0, 0), 1, scaledHeight); + + vgDestroyImage(rightImage); + + // (5) Center (saled via verticalTileRule and horizontalTileRule) + VGImage centerImage = vgChildImage(image, centerSourceRect.x(), centerSourceRect.y(), centerSourceRect.width(), centerSourceRect.height()); + + scaledWidth = (innerTargetRect.width() / subSourceRect.width()) / centerSourceRect.width(); + scaledHeight = (innerTargetRect.height() / subSourceRect.height()) / centerSourceRect.height(); + + QSGOpenVGHelpers::qDrawTiled(centerImage, centerSourceRect.size().toSize(), innerTargetRect, QPointF(0, 0), scaledWidth, scaledHeight); + + vgDestroyImage(centerImage); +} + +void qDrawSubImage(VGImage image, const QRectF &sourceRect, const QPointF &destOffset) +{ + // Check for valid source size + if (sourceRect.width() <= 0 || sourceRect.height() <= 0) + return; + + // Save the current image transform matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + QVector originalMatrix(9); + vgGetMatrix(originalMatrix.data()); + + // Get the child Image + VGImage childRectImage = vgChildImage(image, sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height()); + vgTranslate(destOffset.x(), destOffset.y()); + vgDrawImage(childRectImage); + vgDestroyImage(childRectImage); + + // Pop Matrix + vgLoadMatrix(originalMatrix.constData()); +} + +const QVector qColorToVGColor(const QColor &color, float opacity) +{ + QVector vgColor(4); + vgColor[0] = color.redF(); + vgColor[1] = color.greenF(); + vgColor[2] = color.blueF(); + vgColor[3] = color.alphaF() * opacity; + return vgColor; +} + +VGImageFormat qImageFormatToVGImageFormat(QImage::Format format) +{ + VGImageFormat vgFormat; + + switch (format) { + case QImage::Format_Mono: + case QImage::Format_MonoLSB: + vgFormat = VG_BW_1; + break; + case QImage::Format_RGB32: + vgFormat = VG_sXRGB_8888; + break; + case QImage::Format_ARGB32: + vgFormat = VG_sARGB_8888; + break; + case QImage::Format_ARGB32_Premultiplied: + vgFormat = VG_sARGB_8888_PRE; + break; + case QImage::Format_RGB16: + vgFormat = VG_sRGB_565; + break; + case QImage::Format_RGBX8888: + vgFormat = VG_sRGBX_8888; + break; + case QImage::Format_RGBA8888: + vgFormat = VG_sRGBA_8888; + break; + case QImage::Format_RGBA8888_Premultiplied: + vgFormat = VG_sRGBA_8888_PRE; + break; + case QImage::Format_Alpha8: + vgFormat = VG_A_8; + break; + case QImage::Format_Grayscale8: + vgFormat = VG_sL_8; + break; + default: + //Invalid + vgFormat = (VGImageFormat)-1; + break; + } + + return vgFormat; +} + +QImage::Format qVGImageFormatToQImageFormat(VGImageFormat format) +{ + QImage::Format qImageFormat; + + switch (format) { + case VG_BW_1: + qImageFormat = QImage::Format_Mono; + break; + case VG_sXRGB_8888: + qImageFormat = QImage::Format_RGB32; + break; + case VG_sARGB_8888: + qImageFormat = QImage::Format_ARGB32; + break; + case VG_sARGB_8888_PRE: + qImageFormat = QImage::Format_ARGB32_Premultiplied; + break; + case VG_sRGB_565: + qImageFormat = QImage::Format_RGB16; + break; + case VG_sRGBX_8888: + qImageFormat = QImage::Format_RGBX8888; + break; + case VG_sRGBA_8888: + qImageFormat = QImage::Format_RGBA8888; + break; + case VG_sRGBA_8888_PRE: + qImageFormat = QImage::Format_RGBA8888_Premultiplied; + break; + case VG_A_8: + qImageFormat = QImage::Format_Alpha8; + break; + case VG_sL_8: + qImageFormat = QImage::Format_Grayscale8; + default: + qImageFormat = QImage::Format_ARGB32; + break; + } + + return qImageFormat; +} + +} // end namespace QSGOpenVGHelpers + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvghelpers.h b/src/plugins/scenegraph/openvg/qsgopenvghelpers.h new file mode 100644 index 0000000000..ee8ff73ca8 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvghelpers.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGHELPERS_H +#define QSGOPENVGHELPERS_H + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QSGOpenVGHelpers { + +VGPath qPainterPathToVGPath(const QPainterPath &path); +void qDrawTiled(VGImage image, const QSize imageSize, const QRectF &targetRect, const QPointF offset, float scaleX, float scaleY); +void qDrawBorderImage(VGImage image, const QSizeF &textureSize, const QRectF &targetRect, const QRectF &innerTargetRect, const QRectF &subSourceRect); +void qDrawSubImage(VGImage image, const QRectF &sourceRect, const QPointF &destOffset); +const QVector qColorToVGColor(const QColor &color, float opacity = 1.0f); +VGImageFormat qImageFormatToVGImageFormat(QImage::Format format); +QImage::Format qVGImageFormatToQImageFormat(VGImageFormat format); + +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGHELPERS_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp new file mode 100644 index 0000000000..2ab477f116 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvginternalimagenode.h" +#include "qsgopenvghelpers.h" + +#include + +QT_BEGIN_NAMESPACE + +QSGOpenVGInternalImageNode::QSGOpenVGInternalImageNode() +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); +} + +QSGOpenVGInternalImageNode::~QSGOpenVGInternalImageNode() +{ + if (m_subSourceRectImage != 0) + vgDestroyImage(m_subSourceRectImage); +} + +void QSGOpenVGInternalImageNode::render() +{ + if (!m_texture) { + return; + } + + // Set Draw Mode + if (opacity() < 1.0) { + //Transparent + vgSetPaint(opacityPaint(), VG_FILL_PATH); + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); + } else { + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); + } + + + VGImage image = static_cast(m_texture->textureId()); + QSize textureSize = m_texture->textureSize(); + + + // If Mirrored + if (m_mirror) { + vgTranslate(m_targetRect.width(), 0.0f); + vgScale(-1.0, 1.0); + } + + if (m_smooth) + vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER); + else + vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED); + + + if (m_innerTargetRect != m_targetRect) { + // border image + QSGOpenVGHelpers::qDrawBorderImage(image, textureSize, m_targetRect, m_innerTargetRect, m_subSourceRect); + } else if (m_tileHorizontal || m_tileVertical) { + // Tilled Image + + float sx = m_targetRect.width() / (m_subSourceRect.width() * textureSize.width()); + float sy = m_targetRect.height() / (m_subSourceRect.height() * textureSize.height()); + QPointF offset(m_subSourceRect.left() * textureSize.width(), m_subSourceRect.top() * textureSize.height()); + + QSGOpenVGHelpers::qDrawTiled(image, textureSize, m_targetRect, offset, sx, sy); + + } else { + // Regular BLIT + + QRectF sr(m_subSourceRect.left() * textureSize.width(), m_subSourceRect.top() * textureSize.height(), + m_subSourceRect.width() * textureSize.width(), m_subSourceRect.height() * textureSize.height()); + + if (m_subSourceRectImageDirty) { + if (m_subSourceRectImage != 0) + vgDestroyImage(m_subSourceRectImage); + m_subSourceRectImage = vgChildImage(image, sr.x(), sr.y(), sr.width(), sr.height()); + m_subSourceRectImageDirty = false; + } + + // If the the source rect is the same as the target rect + if (sr == m_targetRect) { + vgDrawImage(image); + } else { + // Scale + float scaleX = m_targetRect.width() / sr.width(); + float scaleY = m_targetRect.height() / sr.height(); + vgTranslate(m_targetRect.x(), m_targetRect.y()); + vgScale(scaleX, scaleY); + vgDrawImage(m_subSourceRectImage); + } + } +} + +void QSGOpenVGInternalImageNode::setTargetRect(const QRectF &rect) +{ + if (rect == m_targetRect) + return; + m_targetRect = rect; + markDirty(DirtyGeometry); +} + +void QSGOpenVGInternalImageNode::setInnerTargetRect(const QRectF &rect) +{ + if (rect == m_innerTargetRect) + return; + m_innerTargetRect = rect; + markDirty(DirtyGeometry); +} + +void QSGOpenVGInternalImageNode::setInnerSourceRect(const QRectF &rect) +{ + if (rect == m_innerSourceRect) + return; + m_innerSourceRect = rect; + markDirty(DirtyGeometry); +} + +void QSGOpenVGInternalImageNode::setSubSourceRect(const QRectF &rect) +{ + if (rect == m_subSourceRect) + return; + m_subSourceRect = rect; + m_subSourceRectImageDirty = true; + markDirty(DirtyGeometry); +} + +void QSGOpenVGInternalImageNode::setTexture(QSGTexture *texture) +{ + m_texture = texture; + m_subSourceRectImageDirty = true; + markDirty(DirtyMaterial); +} + +void QSGOpenVGInternalImageNode::setMirror(bool mirror) +{ + if (m_mirror != mirror) { + m_mirror = mirror; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGInternalImageNode::setMipmapFiltering(QSGTexture::Filtering) +{ +} + +void QSGOpenVGInternalImageNode::setFiltering(QSGTexture::Filtering filtering) +{ + bool smooth = (filtering == QSGTexture::Linear); + if (smooth == m_smooth) + return; + + m_smooth = smooth; + markDirty(DirtyMaterial); +} + +void QSGOpenVGInternalImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) +{ + bool tileHorizontal = (wrapMode == QSGTexture::Repeat); + if (tileHorizontal == m_tileHorizontal) + return; + + m_tileHorizontal = tileHorizontal; + markDirty(DirtyMaterial); +} + +void QSGOpenVGInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode) +{ + bool tileVertical = (wrapMode == QSGTexture::Repeat); + if (tileVertical == m_tileVertical) + return; + + m_tileVertical = (wrapMode == QSGTexture::Repeat); + markDirty(DirtyMaterial); +} + +void QSGOpenVGInternalImageNode::update() +{ +} + +void QSGOpenVGInternalImageNode::preprocess() +{ + bool doDirty = false; + QSGLayer *t = qobject_cast(m_texture); + if (t) { + doDirty = t->updateTexture(); + markDirty(DirtyGeometry); + } + if (doDirty) + markDirty(DirtyMaterial); +} + +QT_END_NAMESPACE + + + + diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h new file mode 100644 index 0000000000..2361aa4892 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGINTERNALIMAGENODE_H +#define QSGOPENVGINTERNALIMAGENODE_H + +#include +#include "qsgopenvgrenderable.h" + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGInternalImageNode : public QSGInternalImageNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGInternalImageNode(); + ~QSGOpenVGInternalImageNode(); + + void render() override; + + void setTargetRect(const QRectF &rect) override; + void setInnerTargetRect(const QRectF &rect) override; + void setInnerSourceRect(const QRectF &rect) override; + void setSubSourceRect(const QRectF &rect) override; + void setTexture(QSGTexture *texture) override; + void setMirror(bool mirror) override; + void setMipmapFiltering(QSGTexture::Filtering filtering) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) override; + void setVerticalWrapMode(QSGTexture::WrapMode wrapMode) override; + void update() override; + + void preprocess() override; + +private: + + QRectF m_targetRect; + QRectF m_innerTargetRect; + QRectF m_innerSourceRect = QRectF(0, 0, 1, 1); + QRectF m_subSourceRect = QRectF(0, 0, 1, 1); + + bool m_mirror = false; + bool m_smooth = true; + bool m_tileHorizontal = false; + bool m_tileVertical = false; + + QSGTexture *m_texture = nullptr; + + VGImage m_subSourceRectImage = 0; + bool m_subSourceRectImageDirty = true; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGINTERNALIMAGENODE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp new file mode 100644 index 0000000000..372dffbbc2 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp @@ -0,0 +1,613 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvginternalrectanglenode.h" +#include "qsgopenvghelpers.h" + +#include + +QSGOpenVGInternalRectangleNode::QSGOpenVGInternalRectangleNode() +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); + createVGResources(); +} + +QSGOpenVGInternalRectangleNode::~QSGOpenVGInternalRectangleNode() +{ + destroyVGResources(); +} + + +void QSGOpenVGInternalRectangleNode::setRect(const QRectF &rect) +{ + m_rect = rect; + m_pathDirty = true; +} + +void QSGOpenVGInternalRectangleNode::setColor(const QColor &color) +{ + m_fillColor = color; + m_fillDirty = true; +} + +void QSGOpenVGInternalRectangleNode::setPenColor(const QColor &color) +{ + m_strokeColor = color; + m_strokeDirty = true; +} + +void QSGOpenVGInternalRectangleNode::setPenWidth(qreal width) +{ + m_penWidth = width; + m_strokeDirty = true; + m_pathDirty = true; +} + +//Move first stop by pos relative to seconds +static QGradientStop interpolateStop(const QGradientStop &firstStop, const QGradientStop &secondStop, double newPos) +{ + double distance = secondStop.first - firstStop.first; + double distanceDelta = newPos - firstStop.first; + double modifierValue = distanceDelta / distance; + int redDelta = (secondStop.second.red() - firstStop.second.red()) * modifierValue; + int greenDelta = (secondStop.second.green() - firstStop.second.green()) * modifierValue; + int blueDelta = (secondStop.second.blue() - firstStop.second.blue()) * modifierValue; + int alphaDelta = (secondStop.second.alpha() - firstStop.second.alpha()) * modifierValue; + + QGradientStop newStop; + newStop.first = newPos; + newStop.second = QColor(firstStop.second.red() + redDelta, + firstStop.second.green() + greenDelta, + firstStop.second.blue() + blueDelta, + firstStop.second.alpha() + alphaDelta); + + return newStop; +} + +void QSGOpenVGInternalRectangleNode::setGradientStops(const QGradientStops &stops) +{ + + //normalize stops + bool needsNormalization = false; + for (const QGradientStop &stop : qAsConst(stops)) { + if (stop.first < 0.0 || stop.first > 1.0) { + needsNormalization = true; + continue; + } + } + + if (needsNormalization) { + QGradientStops normalizedStops; + if (stops.count() == 1) { + //If there is only one stop, then the position does not matter + //It is just treated as a color + QGradientStop stop = stops.at(0); + stop.first = 0.0; + normalizedStops.append(stop); + } else { + //Clip stops to only the first below 0.0 and above 1.0 + int below = -1; + int above = -1; + QVector between; + for (int i = 0; i < stops.count(); ++i) { + if (stops.at(i).first < 0.0) { + below = i; + } else if (stops.at(i).first > 1.0) { + above = i; + break; + } else { + between.append(i); + } + } + + //Interpoloate new color values for above and below + if (below != -1 ) { + //If there are more than one stops left, interpolate + if (below + 1 < stops.count()) { + normalizedStops.append(interpolateStop(stops.at(below), stops.at(below + 1), 0.0)); + } else { + QGradientStop singleStop; + singleStop.first = 0.0; + singleStop.second = stops.at(below).second; + normalizedStops.append(singleStop); + } + } + + for (int i = 0; i < between.count(); ++i) + normalizedStops.append(stops.at(between.at(i))); + + if (above != -1) { + //If there stops before above, interpolate + if (above >= 1) { + normalizedStops.append(interpolateStop(stops.at(above), stops.at(above - 1), 1.0)); + } else { + QGradientStop singleStop; + singleStop.first = 1.0; + singleStop.second = stops.at(above).second; + normalizedStops.append(singleStop); + } + } + } + + m_gradientStops = normalizedStops; + + } else { + m_gradientStops = stops; + } + + m_fillDirty = true; +} + +void QSGOpenVGInternalRectangleNode::setRadius(qreal radius) +{ + m_radius = radius; + m_pathDirty = true; +} + +void QSGOpenVGInternalRectangleNode::setAligned(bool aligned) +{ + m_aligned = aligned; +} + +void QSGOpenVGInternalRectangleNode::update() +{ +} + +void QSGOpenVGInternalRectangleNode::render() +{ + // If path is dirty + if (m_pathDirty) { + vgClearPath(m_rectanglePath, VG_PATH_CAPABILITY_APPEND_TO); + vgClearPath(m_borderPath, VG_PATH_CAPABILITY_APPEND_TO); + + if (m_penWidth == 0) { + generateRectanglePath(m_rect, m_radius, m_rectanglePath); + } else { + generateRectangleAndBorderPaths(m_rect, m_penWidth, m_radius, m_rectanglePath, m_borderPath); + } + + m_pathDirty = false; + } + + //If fill is drity + if (m_fillDirty) { + if (m_gradientStops.isEmpty()) { + vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); + vgSetParameterfv(m_rectanglePaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_fillColor, opacity()).constData()); + } else { + // Linear Gradient + vgSetParameteri(m_rectanglePaint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT); + const VGfloat verticalLinearGradient[] = { + 0.0f, + 0.0f, + 0.0f, + static_cast(m_rect.height()) + }; + vgSetParameterfv(m_rectanglePaint, VG_PAINT_LINEAR_GRADIENT, 4, verticalLinearGradient); + vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_PAD); + vgSetParameteri(m_rectanglePaint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, false); + + QVector stops; + for (const QGradientStop &stop : qAsConst(m_gradientStops)) { + // offset + stops.append(stop.first); + // color + stops.append(QSGOpenVGHelpers::qColorToVGColor(stop.second, opacity())); + } + + vgSetParameterfv(m_rectanglePaint, VG_PAINT_COLOR_RAMP_STOPS, stops.length(), stops.constData()); + } + + m_fillDirty = false; + } + + //If stroke is dirty + if (m_strokeDirty) { + vgSetParameteri(m_borderPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); + vgSetParameterfv(m_borderPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_strokeColor, opacity()).constData()); + + m_strokeDirty = false; + } + + //Draw + if (m_penWidth > 0) { + vgSetPaint(m_borderPaint, VG_FILL_PATH); + vgDrawPath(m_borderPath, VG_FILL_PATH); + vgSetPaint(m_rectanglePaint, VG_FILL_PATH); + vgDrawPath(m_rectanglePath, VG_FILL_PATH); + } else { + vgSetPaint(m_rectanglePaint, VG_FILL_PATH); + vgDrawPath(m_rectanglePath, VG_FILL_PATH); + } +} + +void QSGOpenVGInternalRectangleNode::setOpacity(float opacity) +{ + if (opacity != QSGOpenVGRenderable::opacity()) { + QSGOpenVGRenderable::setOpacity(opacity); + m_strokeDirty = true; + m_fillDirty = true; + } +} + +void QSGOpenVGInternalRectangleNode::createVGResources() +{ + m_rectanglePaint = vgCreatePaint(); + m_borderPaint = vgCreatePaint(); + m_rectanglePath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, + VG_PATH_CAPABILITY_APPEND_TO); + m_borderPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, + VG_PATH_CAPABILITY_APPEND_TO); +} + +void QSGOpenVGInternalRectangleNode::destroyVGResources() +{ + vgDestroyPaint(m_rectanglePaint); + vgDestroyPaint(m_borderPaint); + vgDestroyPath(m_rectanglePath); + vgDestroyPath(m_borderPath); +} + +void QSGOpenVGInternalRectangleNode::generateRectanglePath(const QRectF &rect, float radius, VGPath path) const +{ + if (radius == 0) { + // Generate a rectangle + + // Create command list + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Create command data + QVector coordinates(5); + coordinates[0] = rect.x(); + coordinates[1] = rect.y(); + coordinates[2] = rect.width(); + coordinates[3] = rect.height(); + coordinates[4] = -rect.width(); + + vgAppendPathData(path, 5, rectCommands, coordinates.constData()); + } else { + // Generate a rounded rectangle + //Radius should never exceeds half of the width or half of the height + float adjustedRadius = qMin((float)qMin(rect.width(), rect.height()) * 0.5f, radius); + + // OpenVG expectes radius to be 2x what we expect + adjustedRadius *= 2; + + // Create command list + static const VGubyte roundedRectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_CLOSE_PATH + }; + + // Create command data + QVector coordinates(26); + + coordinates[0] = rect.x() + adjustedRadius / 2; + coordinates[1] = rect.y(); + + coordinates[2] = rect.width() - adjustedRadius; + + coordinates[3] = adjustedRadius / 2; + coordinates[4] = adjustedRadius / 2; + coordinates[5] = 0; + coordinates[6] = adjustedRadius / 2; + coordinates[7] = adjustedRadius / 2; + + coordinates[8] = rect.height() - adjustedRadius; + + coordinates[9] = adjustedRadius / 2; + coordinates[10] = adjustedRadius / 2; + coordinates[11] = 0; + coordinates[12] = -adjustedRadius / 2; + coordinates[13] = adjustedRadius / 2; + + coordinates[14] = -(rect.width() - adjustedRadius); + + coordinates[15] = adjustedRadius / 2; + coordinates[16] = adjustedRadius / 2; + coordinates[17] = 0; + coordinates[18] = -adjustedRadius / 2; + coordinates[19] = -adjustedRadius / 2; + + coordinates[20] = -(rect.height() - adjustedRadius); + + coordinates[21] = adjustedRadius / 2; + coordinates[22] = adjustedRadius / 2; + coordinates[23] = 0; + coordinates[24] = adjustedRadius / 2; + coordinates[25] = -adjustedRadius / 2; + + vgAppendPathData(path, 10, roundedRectCommands, coordinates.constData()); + } +} + +void QSGOpenVGInternalRectangleNode::generateBorderPath(const QRectF &rect, float borderWidth, float borderHeight, float radius, VGPath path) const +{ + if (radius == 0) { + // squared frame + // Create command list + static const VGubyte squaredBorderCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_MOVE_TO_ABS, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Create command data + QVector coordinates(10); + // Outside Square + coordinates[0] = rect.x(); + coordinates[1] = rect.y(); + coordinates[2] = rect.width(); + coordinates[3] = rect.height(); + coordinates[4] = -rect.width(); + // Inside Square (opposite direction) + coordinates[5] = rect.x() + borderWidth; + coordinates[6] = rect.y() + borderHeight; + coordinates[7] = rect.height() - (borderHeight * 2); + coordinates[8] = rect.width() - (borderWidth * 2); + coordinates[9] = -(rect.height() - (borderHeight * 2)); + + vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData()); + } else if (radius < qMax(borderWidth, borderHeight)){ + // rounded outside, squared inside + // Create command list + static const VGubyte roundedRectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_MOVE_TO_ABS, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Ajust for OpenVG's usage or radius + float adjustedRadius = radius * 2; + + // Create command data + QVector coordinates(31); + // Outside Rounded Rect + coordinates[0] = rect.x() + adjustedRadius / 2; + coordinates[1] = rect.y(); + + coordinates[2] = rect.width() - adjustedRadius; + + coordinates[3] = adjustedRadius / 2; + coordinates[4] = adjustedRadius / 2; + coordinates[5] = 0; + coordinates[6] = adjustedRadius / 2; + coordinates[7] = adjustedRadius / 2; + + coordinates[8] = rect.height() - adjustedRadius; + + coordinates[9] = adjustedRadius / 2; + coordinates[10] = adjustedRadius / 2; + coordinates[11] = 0; + coordinates[12] = -adjustedRadius / 2; + coordinates[13] = adjustedRadius / 2; + + coordinates[14] = -(rect.width() - adjustedRadius); + + coordinates[15] = adjustedRadius / 2; + coordinates[16] = adjustedRadius / 2; + coordinates[17] = 0; + coordinates[18] = -adjustedRadius / 2; + coordinates[19] = -adjustedRadius / 2; + + coordinates[20] = -(rect.height() - adjustedRadius); + + coordinates[21] = adjustedRadius / 2; + coordinates[22] = adjustedRadius / 2; + coordinates[23] = 0; + coordinates[24] = adjustedRadius / 2; + coordinates[25] = -adjustedRadius / 2; + + // Inside Square (opposite direction) + coordinates[26] = rect.x() + borderWidth; + coordinates[27] = rect.y() + borderHeight; + coordinates[28] = rect.height() - (borderHeight * 2); + coordinates[29] = rect.width() - (borderWidth * 2); + coordinates[30] = -(rect.height() - (borderHeight * 2)); + + vgAppendPathData(path, 14, roundedRectCommands, coordinates.constData()); + } else { + // rounded outside, rounded inside + + static const VGubyte roundedBorderCommands[] = { + // Outer + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_HLINE_TO_REL, + VG_SCCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCCWARC_TO_REL, + // Inner + VG_MOVE_TO_ABS, + VG_SCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCWARC_TO_REL, + VG_HLINE_TO_REL, + VG_SCWARC_TO_REL, + VG_VLINE_TO_REL, + VG_SCWARC_TO_REL, + VG_HLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Adjust for OpenVG's usage or radius + float adjustedRadius = radius * 2; + float adjustedInnerRadius = (radius - qMax(borderWidth, borderHeight)) * 2; + + // Create command data + QVector coordinates(52); + + // Outer + coordinates[0] = rect.x() + adjustedRadius / 2; + coordinates[1] = rect.y(); + + coordinates[2] = rect.width() - adjustedRadius; + + coordinates[3] = adjustedRadius / 2; + coordinates[4] = adjustedRadius / 2; + coordinates[5] = 0; + coordinates[6] = adjustedRadius / 2; + coordinates[7] = adjustedRadius / 2; + + coordinates[8] = rect.height() - adjustedRadius; + + coordinates[9] = adjustedRadius / 2; + coordinates[10] = adjustedRadius / 2; + coordinates[11] = 0; + coordinates[12] = -adjustedRadius / 2; + coordinates[13] = adjustedRadius / 2; + + coordinates[14] = -(rect.width() - adjustedRadius); + + coordinates[15] = adjustedRadius / 2; + coordinates[16] = adjustedRadius / 2; + coordinates[17] = 0; + coordinates[18] = -adjustedRadius / 2; + coordinates[19] = -adjustedRadius / 2; + + coordinates[20] = -(rect.height() - adjustedRadius); + + coordinates[21] = adjustedRadius / 2; + coordinates[22] = adjustedRadius / 2; + coordinates[23] = 0; + coordinates[24] = adjustedRadius / 2; + coordinates[25] = -adjustedRadius / 2; + + // Inner + coordinates[26] = rect.width() - (adjustedInnerRadius / 2 + borderWidth); + coordinates[27] = rect.height() - borderHeight; + + coordinates[28] = adjustedInnerRadius / 2; + coordinates[29] = adjustedInnerRadius / 2; + coordinates[30] = 0; + coordinates[31] = adjustedInnerRadius / 2; + coordinates[32] = -adjustedInnerRadius / 2; + + coordinates[33] = -((rect.height() - borderHeight * 2) - adjustedInnerRadius); + + coordinates[34] = adjustedInnerRadius / 2; + coordinates[35] = adjustedInnerRadius / 2; + coordinates[36] = 0; + coordinates[37] = -adjustedInnerRadius / 2; + coordinates[38] = -adjustedInnerRadius / 2; + + coordinates[39] = -((rect.width() - borderWidth * 2) - adjustedInnerRadius); + + coordinates[40] = adjustedInnerRadius / 2; + coordinates[41] = adjustedInnerRadius / 2; + coordinates[42] = 0; + coordinates[43] = -adjustedInnerRadius / 2; + coordinates[44] = adjustedInnerRadius / 2; + + coordinates[45] = (rect.height() - borderHeight * 2) - adjustedInnerRadius; + + coordinates[46] = adjustedInnerRadius / 2; + coordinates[47] = adjustedInnerRadius / 2; + coordinates[48] = 0; + coordinates[49] = adjustedInnerRadius / 2; + coordinates[50] = adjustedInnerRadius / 2; + + coordinates[51] = (rect.width() - borderWidth * 2) - adjustedInnerRadius; + + vgAppendPathData(path, 19, roundedBorderCommands, coordinates.constData()); + } +} + +void QSGOpenVGInternalRectangleNode::generateRectangleAndBorderPaths(const QRectF &rect, float penWidth, float radius, VGPath inside, VGPath outside) const +{ + //Borders can not be more than half the height/width of a rect + float borderWidth = qMin(penWidth, (float)rect.width() * 0.5f); + float borderHeight = qMin(penWidth, (float)rect.height() * 0.5f); + + //Radius should never exceeds half of the width or half of the height + float adjustedRadius = qMin((float)qMin(rect.width(), rect.height()) * 0.5f, radius); + + QRectF innerRect = rect; + innerRect.adjust(borderWidth, borderHeight, -borderWidth, -borderHeight); + + if (radius == 0) { + // Regular rect with border + generateRectanglePath(innerRect, 0, inside); + generateBorderPath(rect, borderWidth, borderHeight, 0, outside); + } else { + // Rounded Rect with border + float innerRadius = radius - qMax(borderWidth, borderHeight); + if (innerRadius < 0) + innerRadius = 0.0f; + + generateRectanglePath(innerRect, innerRadius, inside); + generateBorderPath(rect, borderWidth, borderHeight, adjustedRadius, outside); + } +} diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h new file mode 100644 index 0000000000..0d5283773f --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGINTERNALRECTANGLENODE_H +#define QSGOPENVGINTERNALRECTANGLENODE_H + +#include +#include "qsgopenvgrenderable.h" + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGInternalRectangleNode : public QSGInternalRectangleNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGInternalRectangleNode(); + ~QSGOpenVGInternalRectangleNode(); + + void setRect(const QRectF &rect) override; + void setColor(const QColor &color) override; + void setPenColor(const QColor &color) override; + void setPenWidth(qreal width) override; + void setGradientStops(const QGradientStops &stops) override; + void setRadius(qreal radius) override; + void setAligned(bool aligned) override; + void update() override; + + void render() override; + void setOpacity(float opacity) override; + +private: + void createVGResources(); + void destroyVGResources(); + + void generateRectanglePath(const QRectF &rect, float radius, VGPath path) const; + void generateRectangleAndBorderPaths(const QRectF &rect, float penWidth, float radius, VGPath inside, VGPath outside) const; + void generateBorderPath(const QRectF &rect, float borderWidth, float borderHeight, float radius, VGPath path) const; + + bool m_pathDirty = true; + bool m_fillDirty = true; + bool m_strokeDirty = true; + + QRectF m_rect; + QColor m_fillColor; + QColor m_strokeColor; + qreal m_penWidth = 0.0; + qreal m_radius = 0.0; + bool m_aligned = false; + QGradientStops m_gradientStops; + + VGPath m_rectanglePath; + VGPath m_borderPath; + VGPaint m_rectanglePaint; + VGPaint m_borderPaint; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGINTERNALRECTANGLENODE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp new file mode 100644 index 0000000000..03a82ca4ee --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp @@ -0,0 +1,360 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvglayer.h" +#include "qsgopenvgrenderer_p.h" +#include "qsgopenvgcontext_p.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGLayer::QSGOpenVGLayer(QSGRenderContext *renderContext) + : m_item(nullptr) + , m_renderer(nullptr) + , m_device_pixel_ratio(1) + , m_mirrorHorizontal(false) + , m_mirrorVertical(false) + , m_live(true) + , m_grab(true) + , m_recursive(false) + , m_dirtyTexture(true) + , m_image(0) + , m_renderTarget(0) + , m_layerContext(0) +{ + m_context = static_cast(renderContext); + m_vgContext = m_context->vgContext(); +} + +QSGOpenVGLayer::~QSGOpenVGLayer() +{ + invalidated(); +} + +int QSGOpenVGLayer::textureId() const +{ + return static_cast(m_image); +} + +QSize QSGOpenVGLayer::textureSize() const +{ + if (m_image != 0) { + VGint imageWidth = vgGetParameteri(m_image, VG_IMAGE_WIDTH); + VGint imageHeight = vgGetParameteri(m_image, VG_IMAGE_HEIGHT); + return QSize(imageWidth, imageHeight); + } + + return QSize(); +} + +bool QSGOpenVGLayer::hasAlphaChannel() const +{ + VGImageFormat format = static_cast(vgGetParameteri(m_image, VG_IMAGE_FORMAT)); + + switch (format) { + case VG_sRGBA_8888: + case VG_sRGBA_8888_PRE: + case VG_sRGBA_5551: + case VG_sRGBA_4444: + case VG_lRGBA_8888: + case VG_lRGBA_8888_PRE: + case VG_A_8: + case VG_A_1: + case VG_A_4: + case VG_sARGB_8888: + case VG_sARGB_8888_PRE: + case VG_sARGB_1555: + case VG_sARGB_4444: + case VG_lARGB_8888: + case VG_lARGB_8888_PRE: + case VG_sBGRA_8888: + case VG_sBGRA_8888_PRE: + case VG_sBGRA_5551: + case VG_sBGRA_4444: + case VG_lBGRA_8888: + case VG_lBGRA_8888_PRE: + case VG_sABGR_8888: + case VG_sABGR_8888_PRE: + case VG_sABGR_1555: + case VG_sABGR_4444: + case VG_lABGR_8888: + case VG_lABGR_8888_PRE: + return true; + break; + default: + break; + } + return false; +} + +bool QSGOpenVGLayer::hasMipmaps() const +{ + return false; +} + +void QSGOpenVGLayer::bind() +{ +} + +bool QSGOpenVGLayer::updateTexture() +{ + bool doGrab = (m_live || m_grab) && m_dirtyTexture; + if (doGrab) + grab(); + if (m_grab) + emit scheduledUpdateCompleted(); + m_grab = false; + return doGrab; +} + +void QSGOpenVGLayer::setItem(QSGNode *item) +{ + if (item == m_item) + return; + m_item = item; + + if (m_live && !m_item) { + vgDestroyImage(m_image); + m_image = 0; + } + + markDirtyTexture(); +} + +void QSGOpenVGLayer::setRect(const QRectF &rect) +{ + if (rect == m_rect) + return; + m_rect = rect; + markDirtyTexture(); +} + +void QSGOpenVGLayer::setSize(const QSize &size) +{ + if (size == m_size) + return; + m_size = size; + + if (m_live && m_size.isNull()) { + vgDestroyImage(m_image); + m_image = 0; + } + + markDirtyTexture(); +} + +void QSGOpenVGLayer::scheduleUpdate() +{ + if (m_grab) + return; + m_grab = true; + if (m_dirtyTexture) { + emit updateRequested(); + } +} + +QImage QSGOpenVGLayer::toImage() const +{ + // XXX + return QImage(); +} + +void QSGOpenVGLayer::setLive(bool live) +{ + if (live == m_live) + return; + m_live = live; + + if (m_live && (!m_item || m_size.isNull())) { + vgDestroyImage(m_image); + m_image = 0; + } + + markDirtyTexture(); +} + +void QSGOpenVGLayer::setRecursive(bool recursive) +{ + m_recursive = recursive; +} + +void QSGOpenVGLayer::setFormat(uint format) +{ + Q_UNUSED(format) +} + +void QSGOpenVGLayer::setHasMipmaps(bool mipmap) +{ + Q_UNUSED(mipmap) +} + +void QSGOpenVGLayer::setDevicePixelRatio(qreal ratio) +{ + m_device_pixel_ratio = ratio; +} + +void QSGOpenVGLayer::setMirrorHorizontal(bool mirror) +{ + if (m_mirrorHorizontal == mirror) + return; + m_mirrorHorizontal = mirror; + markDirtyTexture(); +} + +void QSGOpenVGLayer::setMirrorVertical(bool mirror) +{ + if (m_mirrorVertical == mirror) + return; + m_mirrorVertical = mirror; + markDirtyTexture(); +} + +void QSGOpenVGLayer::markDirtyTexture() +{ + m_dirtyTexture = true; + if (m_live || m_grab) { + emit updateRequested(); + } +} + +void QSGOpenVGLayer::invalidated() +{ + delete m_renderer; + m_renderer = 0; +} + +void QSGOpenVGLayer::grab() +{ + if (!m_item || m_size.isNull()) { + vgDestroyImage(m_image); + m_image = 0; + m_dirtyTexture = false; + return; + } + QSGNode *root = m_item; + while (root->firstChild() && root->type() != QSGNode::RootNodeType) + root = root->firstChild(); + if (root->type() != QSGNode::RootNodeType) + return; + + if (!m_renderer) { + m_renderer = new QSGOpenVGRenderer(m_context); + connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture())); + } + m_renderer->setDevicePixelRatio(m_device_pixel_ratio); + m_renderer->setRootNode(static_cast(root)); + + if (m_image == 0 || m_imageSize != m_size ) { + if (m_image != 0) + vgDestroyImage(m_image); + + m_image = vgCreateImage(VG_lARGB_8888_PRE, m_size.width(), m_size.height(), VG_IMAGE_QUALITY_BETTER); + m_imageSize = m_size; + + //Destroy old RenderTarget + if (m_renderTarget != 0) + eglDestroySurface(m_vgContext->eglDisplay(), m_renderTarget); + + const EGLint configAttribs[] = { + EGL_CONFORMANT, EGL_OPENVG_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_ALPHA_MASK_SIZE, 8, + EGL_NONE + }; + + EGLConfig pbufferConfig; + EGLint numConfig; + eglChooseConfig(m_vgContext->eglDisplay(), configAttribs, &pbufferConfig, 1, &numConfig); + + if (m_layerContext == 0) { + // Create new context + m_layerContext = eglCreateContext(m_vgContext->eglDisplay(), pbufferConfig, m_vgContext->eglContext(), 0); + } + + m_renderTarget = eglCreatePbufferFromClientBuffer(m_vgContext->eglDisplay(), + EGL_OPENVG_IMAGE, + (EGLClientBuffer)m_image, + pbufferConfig, + 0); + } + + if (m_renderTarget == EGL_NO_SURFACE) { + qDebug() << "invalid renderTarget!"; + return; + } + + // Render texture. + root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update. + m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update. + + m_dirtyTexture = false; + + m_renderer->setDeviceRect(m_size); + m_renderer->setViewportRect(m_size); + QRect mirrored(m_mirrorHorizontal ? m_rect.right() * m_device_pixel_ratio : m_rect.left() * m_device_pixel_ratio, + m_mirrorVertical ? m_rect.top() * m_device_pixel_ratio : m_rect.bottom() * m_device_pixel_ratio, + m_mirrorHorizontal ? -m_rect.width() * m_device_pixel_ratio : m_rect.width() * m_device_pixel_ratio, + m_mirrorVertical ? m_rect.height() * m_device_pixel_ratio : -m_rect.height() * m_device_pixel_ratio); + m_renderer->setProjectionMatrixToRect(mirrored); + m_renderer->setClearColor(Qt::transparent); + + eglMakeCurrent(m_vgContext->eglDisplay(), m_renderTarget, m_renderTarget, m_layerContext); + + // Before Rendering setup context for adjusting to Qt Coordinates to PixelBuffer + // Should already be inverted by default + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + + m_renderer->renderScene(); + + eglSwapBuffers(m_vgContext->eglDisplay(), m_renderTarget); + + // make the default surface current again + m_vgContext->makeCurrent(); + + root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update. + + if (m_recursive) + markDirtyTexture(); // Continuously update if 'live' and 'recursive'. +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.h b/src/plugins/scenegraph/openvg/qsgopenvglayer.h new file mode 100644 index 0000000000..ee9984b9d9 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGLAYER_H +#define QSGOPENVGLAYER_H + +#include +#include + +#include "qopenvgcontext_p.h" + +QT_BEGIN_NAMESPACE + +class QSGOpenVGRenderer; +class QSGOpenVGRenderContext; + +class QSGOpenVGLayer : public QSGLayer +{ +public: + QSGOpenVGLayer(QSGRenderContext *renderContext); + ~QSGOpenVGLayer(); + + // QSGTexture interface +public: + int textureId() const override; + QSize textureSize() const override; + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + void bind() override; + + // QSGDynamicTexture interface +public: + bool updateTexture() override; + + // QSGLayer interface +public: + void setItem(QSGNode *item) override; + void setRect(const QRectF &rect) override; + void setSize(const QSize &size) override; + void scheduleUpdate() override; + QImage toImage() const override; + void setLive(bool live) override; + void setRecursive(bool recursive) override; + void setFormat(uint format) override; + void setHasMipmaps(bool mipmap) override; + void setDevicePixelRatio(qreal ratio) override; + void setMirrorHorizontal(bool mirror) override; + void setMirrorVertical(bool mirror) override; + +public slots: + void markDirtyTexture() override; + void invalidated() override; + +private: + void grab(); + + QSGNode *m_item; + QSGOpenVGRenderContext *m_context; + QSGOpenVGRenderer *m_renderer; + QRectF m_rect; + QSize m_size; + qreal m_device_pixel_ratio; + bool m_mirrorHorizontal; + bool m_mirrorVertical; + bool m_live; + bool m_grab; + bool m_recursive; + bool m_dirtyTexture; + + QOpenVGContext *m_vgContext; + VGImage m_image; + QSize m_imageSize; + EGLSurface m_renderTarget; + EGLContext m_layerContext; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGLAYER_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp new file mode 100644 index 0000000000..fc9f5eb57c --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp @@ -0,0 +1,283 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgnodevisitor.h" +#include "qsgopenvginternalrectanglenode.h" +#include "qsgopenvginternalimagenode.h" +#include "qsgopenvgpublicnodes.h" +#include "qsgopenvgglyphnode_p.h" +#include "qsgopenvgpainternode.h" +#include "qsgopenvgspritenode.h" +#include "qsgopenvgrenderable.h" + +#include "qopenvgcontext_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QSGOpenVGNodeVisitor::QSGOpenVGNodeVisitor() +{ + //Store the current matrix state + QVector matrix(9); + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgGetMatrix(matrix.data()); + + m_transformStack.push(QOpenVGMatrix(matrix.constData())); + + // Opacity + m_opacityState.push(1.0f); +} + +bool QSGOpenVGNodeVisitor::visit(QSGTransformNode *node) +{ + const QVector matrixData = { node->matrix().constData()[0], node->matrix().constData()[1], node->matrix().constData()[3], + node->matrix().constData()[4], node->matrix().constData()[5], node->matrix().constData()[7], + node->matrix().constData()[12], node->matrix().constData()[13], node->matrix().constData()[15] }; + const QOpenVGMatrix matrix2d(matrixData.constData()); + + m_transformStack.push(m_transformStack.top() * matrix2d); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGTransformNode *) +{ + m_transformStack.pop(); +} + +bool QSGOpenVGNodeVisitor::visit(QSGClipNode *node) +{ + VGMaskOperation maskOperation = VG_INTERSECT_MASK; + if (m_clipStack.count() == 0) { + vgSeti(VG_MASKING, VG_TRUE); + vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT); + } + + // Render clip node geometry to mask + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + VGPath clipPath = generateClipPath(node->clipRect()); + vgRenderToMask(clipPath, VG_FILL_PATH, maskOperation); + + auto clipState = new ClipState(clipPath, m_transformStack.top()); + m_clipStack.push(clipState); + + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGClipNode *) +{ + // Remove clip node geometry from mask + auto clipState = m_clipStack.pop(); + vgDestroyPath(clipState->path); + + if (m_clipStack.count() == 0) { + vgSeti(VG_MASKING, VG_FALSE); + } else { + // Recreate the mask + vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT); + for (auto state : m_clipStack) { + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(state->transform.constData()); + vgRenderToMask(state->path, VG_FILL_PATH, VG_INTERSECT_MASK); + } + } + + delete clipState; +} + +bool QSGOpenVGNodeVisitor::visit(QSGGeometryNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + if (QSGSimpleRectNode *rectNode = dynamic_cast(node)) { + // TODO: Try and render the QSGSimpleRectNode + Q_UNUSED(rectNode) + return false; + } else if (QSGSimpleTextureNode *tn = dynamic_cast(node)) { + // TODO: Try and render the QSGSimpleTextureNode + Q_UNUSED(tn) + return false; + } else if (QSGOpenVGNinePatchNode *nn = dynamic_cast(node)) { + renderRenderableNode(nn); + } else if (QSGOpenVGRectangleNode *rn = dynamic_cast(node)) { + renderRenderableNode(rn); + } else if (QSGOpenVGImageNode *n = dynamic_cast(node)) { + renderRenderableNode(n); + } else { + // We dont know, so skip + return false; + } + + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGGeometryNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGOpacityNode *node) +{ + m_opacityState.push(m_opacityState.top() * node->opacity()); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGOpacityNode *) +{ + m_opacityState.pop(); +} + +bool QSGOpenVGNodeVisitor::visit(QSGInternalImageNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + renderRenderableNode(static_cast(node)); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGInternalImageNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGPainterNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + renderRenderableNode(static_cast(node)); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGPainterNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGInternalRectangleNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + renderRenderableNode(static_cast(node)); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGInternalRectangleNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGGlyphNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + renderRenderableNode(static_cast(node)); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGGlyphNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGRootNode *) +{ + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGRootNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGSpriteNode *node) +{ + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(m_transformStack.top().constData()); + renderRenderableNode(static_cast(node)); + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGSpriteNode *) +{ +} + +bool QSGOpenVGNodeVisitor::visit(QSGRenderNode *) +{ + return true; +} + +void QSGOpenVGNodeVisitor::endVisit(QSGRenderNode *) +{ +} + +VGPath QSGOpenVGNodeVisitor::generateClipPath(const QRectF &rect) const +{ + VGPath clipPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, + VG_PATH_CAPABILITY_APPEND_TO); + + // Create command list + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Create command data + QVector coordinates(5); + coordinates[0] = rect.x(); + coordinates[1] = rect.y(); + coordinates[2] = rect.width(); + coordinates[3] = rect.height(); + coordinates[4] = -rect.width(); + + vgAppendPathData(clipPath, 5, rectCommands, coordinates.constData()); + return clipPath; +} + +void QSGOpenVGNodeVisitor::renderRenderableNode(QSGOpenVGRenderable *node) +{ + if (!node) + return; + + node->setOpacity(m_opacityState.top()); + node->render(); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h new file mode 100644 index 0000000000..3105f2076d --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGNODEVISITOR_H +#define QSGOPENVGNODEVISITOR_H + +#include +#include + +#include "qopenvgmatrix.h" + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGRenderable; +class QSGOpenVGNodeVisitor : public QSGNodeVisitorEx +{ +public: + QSGOpenVGNodeVisitor(); + + bool visit(QSGTransformNode *) override; + void endVisit(QSGTransformNode *) override; + bool visit(QSGClipNode *) override; + void endVisit(QSGClipNode *) override; + bool visit(QSGGeometryNode *) override; + void endVisit(QSGGeometryNode *) override; + bool visit(QSGOpacityNode *) override; + void endVisit(QSGOpacityNode *) override; + bool visit(QSGInternalImageNode *) override; + void endVisit(QSGInternalImageNode *) override; + bool visit(QSGPainterNode *) override; + void endVisit(QSGPainterNode *) override; + bool visit(QSGInternalRectangleNode *) override; + void endVisit(QSGInternalRectangleNode *) override; + bool visit(QSGGlyphNode *) override; + void endVisit(QSGGlyphNode *) override; + bool visit(QSGRootNode *) override; + void endVisit(QSGRootNode *) override; + bool visit(QSGSpriteNode *) override; + void endVisit(QSGSpriteNode *) override; + bool visit(QSGRenderNode *) override; + void endVisit(QSGRenderNode *) override; + +private: + struct ClipState { + ClipState(VGPath p, QOpenVGMatrix t) + { + path = p; + transform = t; + } + + VGPath path; + QOpenVGMatrix transform; + }; + + VGPath generateClipPath(const QRectF &rect) const; + void renderRenderableNode(QSGOpenVGRenderable *node); + + + QStack m_transformStack; + QStack m_opacityState; + QStack m_clipStack; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGNODEVISITOR_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp new file mode 100644 index 0000000000..c09ca6a47e --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp @@ -0,0 +1,249 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgpainternode.h" +#include "qsgopenvgtexture.h" +#include + +#include + +QT_BEGIN_NAMESPACE + +QSGOpenVGPainterNode::QSGOpenVGPainterNode(QQuickPaintedItem *item) + : m_preferredRenderTarget(QQuickPaintedItem::Image) + , m_item(item) + , m_texture(nullptr) + , m_dirtyContents(false) + , m_opaquePainting(false) + , m_linear_filtering(false) + , m_smoothPainting(false) + , m_fillColor(Qt::transparent) + , m_contentsScale(1.0) + , m_dirtyGeometry(false) +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); +} + +QSGOpenVGPainterNode::~QSGOpenVGPainterNode() +{ + delete m_texture; +} + +void QSGOpenVGPainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget) +{ +} + +void QSGOpenVGPainterNode::setSize(const QSize &size) +{ + if (size == m_size) + return; + + m_size = size; + + m_dirtyGeometry = true; +} + +void QSGOpenVGPainterNode::setDirty(const QRect &dirtyRect) +{ + m_dirtyContents = true; + m_dirtyRect = dirtyRect; + markDirty(DirtyMaterial); +} + +void QSGOpenVGPainterNode::setOpaquePainting(bool opaque) +{ + if (opaque == m_opaquePainting) + return; + + m_opaquePainting = opaque; +} + +void QSGOpenVGPainterNode::setLinearFiltering(bool linearFiltering) +{ + if (linearFiltering == m_linear_filtering) + return; + + m_linear_filtering = linearFiltering; +} + +void QSGOpenVGPainterNode::setMipmapping(bool) +{ + +} + +void QSGOpenVGPainterNode::setSmoothPainting(bool s) +{ + if (s == m_smoothPainting) + return; + + m_smoothPainting = s; +} + +void QSGOpenVGPainterNode::setFillColor(const QColor &c) +{ + if (c == m_fillColor) + return; + + m_fillColor = c; + markDirty(DirtyMaterial); +} + +void QSGOpenVGPainterNode::setContentsScale(qreal s) +{ + if (s == m_contentsScale) + return; + + m_contentsScale = s; + markDirty(DirtyMaterial); +} + +void QSGOpenVGPainterNode::setFastFBOResizing(bool) +{ +} + +void QSGOpenVGPainterNode::setTextureSize(const QSize &size) +{ + if (size == m_textureSize) + return; + + m_textureSize = size; + m_dirtyGeometry = true; +} + +QImage QSGOpenVGPainterNode::toImage() const +{ + return m_image; +} + +void QSGOpenVGPainterNode::update() +{ + if (m_dirtyGeometry) { + if (!m_opaquePainting) + m_image = QImage(m_size, QImage::Format_ARGB32_Premultiplied); + else + m_image = QImage(m_size, QImage::Format_RGB32); + } + + if (m_dirtyContents) + paint(); + + m_dirtyGeometry = false; + m_dirtyContents = false; +} + +QSGTexture *QSGOpenVGPainterNode::texture() const +{ + return m_texture; +} + +void QSGOpenVGPainterNode::render() +{ + if (!m_texture) + return; + + // Set Draw Mode + if (opacity() < 1.0) { + //Transparent + vgSetPaint(opacityPaint(), VG_FILL_PATH); + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); + } else { + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); + } + + if (m_linear_filtering) + vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_BETTER); + else + vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED); + + vgDrawImage(static_cast(m_texture->textureId())); +} + +void QSGOpenVGPainterNode::paint() +{ + QRect dirtyRect = m_dirtyRect.isNull() ? QRect(0, 0, m_size.width(), m_size.height()) : m_dirtyRect; + + QPainter painter; + + painter.begin(&m_image); + if (m_smoothPainting) { + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform); + } + + QRect clipRect; + + if (m_contentsScale == 1) { + qreal scaleX = m_textureSize.width() / (qreal) m_size.width(); + qreal scaleY = m_textureSize.height() / (qreal) m_size.height(); + painter.scale(scaleX, scaleY); + clipRect = dirtyRect; + } else { + painter.scale(m_contentsScale, m_contentsScale); + + QRect sclip(qFloor(dirtyRect.x()/m_contentsScale), + qFloor(dirtyRect.y()/m_contentsScale), + qCeil(dirtyRect.width()/m_contentsScale+dirtyRect.x()/m_contentsScale-qFloor(dirtyRect.x()/m_contentsScale)), + qCeil(dirtyRect.height()/m_contentsScale+dirtyRect.y()/m_contentsScale-qFloor(dirtyRect.y()/m_contentsScale))); + + clipRect = sclip; + } + + if (!m_dirtyRect.isNull()) + painter.setClipRect(clipRect); + + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(clipRect, m_fillColor); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + + m_item->paint(&painter); + painter.end(); + + m_dirtyRect = QRect(); + + if (m_texture) + delete m_texture; + + uint textureFlags = m_opaquePainting ? 0 : QSGRenderContext::CreateTexture_Alpha; + m_texture = new QSGOpenVGTexture(m_image, textureFlags); +} + +QT_END_NAMESPACE + + diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h new file mode 100644 index 0000000000..1fe992115f --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGPAINTERNODE_H +#define QSGOPENVGPAINTERNODE_H + +#include +#include +#include "qsgopenvgrenderable.h" + +QT_BEGIN_NAMESPACE + +class QSGOpenVGTexture; + +class QSGOpenVGPainterNode : public QSGPainterNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGPainterNode(QQuickPaintedItem *item); + ~QSGOpenVGPainterNode(); + + void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override; + void setSize(const QSize &size) override; + void setDirty(const QRect &dirtyRect) override; + void setOpaquePainting(bool opaque) override; + void setLinearFiltering(bool linearFiltering) override; + void setMipmapping(bool mipmapping) override; + void setSmoothPainting(bool s) override; + void setFillColor(const QColor &c) override; + void setContentsScale(qreal s) override; + void setFastFBOResizing(bool dynamic) override; + void setTextureSize(const QSize &size) override; + QImage toImage() const override; + void update() override; + QSGTexture *texture() const override; + + void render() override; + void paint(); + +private: + QQuickPaintedItem::RenderTarget m_preferredRenderTarget; + + QQuickPaintedItem *m_item; + QSGOpenVGTexture *m_texture; + QImage m_image; + + QSize m_size; + bool m_dirtyContents; + QRect m_dirtyRect; + bool m_opaquePainting; + bool m_linear_filtering; + bool m_smoothPainting; + QColor m_fillColor; + qreal m_contentsScale; + QSize m_textureSize; + + bool m_dirtyGeometry; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGPAINTERNODE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp new file mode 100644 index 0000000000..f5890210a9 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp @@ -0,0 +1,266 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgpublicnodes.h" +#include "qsgopenvghelpers.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGRectangleNode::QSGOpenVGRectangleNode() +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); + + m_rectPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1, 0, 0, 0, + VG_PATH_CAPABILITY_APPEND_TO); + m_rectPaint = vgCreatePaint(); +} + +QSGOpenVGRectangleNode::~QSGOpenVGRectangleNode() +{ + vgDestroyPaint(m_rectPaint); + vgDestroyPath(m_rectPath); +} + +void QSGOpenVGRectangleNode::setRect(const QRectF &rect) +{ + m_rect = rect; + m_pathDirty = true; + markDirty(DirtyMaterial); +} + +void QSGOpenVGRectangleNode::setColor(const QColor &color) +{ + m_color = color; + m_paintDirty = true; + markDirty(DirtyMaterial); +} + +void QSGOpenVGRectangleNode::render() +{ + if (m_pathDirty) { + vgClearPath(m_rectPath, VG_PATH_CAPABILITY_APPEND_TO); + // Create command list + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_CLOSE_PATH + }; + + // Create command data + QVector coordinates(5); + coordinates[0] = m_rect.x(); + coordinates[1] = m_rect.y(); + coordinates[2] = m_rect.width(); + coordinates[3] = m_rect.height(); + coordinates[4] = -m_rect.width(); + + vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData()); + m_pathDirty = false; + } + + if (m_paintDirty) { + vgSetPaint(m_rectPaint, VG_FILL_PATH); + vgSetParameteri(m_rectPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR); + vgSetParameterfv(m_rectPaint, VG_PAINT_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(m_color).constData()); + + m_paintDirty = false; + } + + vgSetPaint(m_rectPaint, VG_FILL_PATH); + vgDrawPath(m_rectPath, VG_FILL_PATH); + +} + +QSGOpenVGImageNode::QSGOpenVGImageNode() +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); + +} + +QSGOpenVGImageNode::~QSGOpenVGImageNode() +{ + if (m_owns) { + m_texture->deleteLater(); + } +} + +void QSGOpenVGImageNode::setTexture(QSGTexture *texture) +{ + m_texture = texture; + markDirty(DirtyMaterial); +} + +void QSGOpenVGImageNode::setTextureCoordinatesTransform(QSGImageNode::TextureCoordinatesTransformMode transformNode) +{ + if (m_transformMode == transformNode) + return; + m_transformMode = transformNode; + markDirty(DirtyGeometry); +} + +void QSGOpenVGImageNode::render() +{ + if (!m_texture) { + return; + } + + // Set Draw Mode + if (opacity() < 1.0) { + //Transparent + vgSetPaint(opacityPaint(), VG_FILL_PATH); + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); + } else { + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); + } + + VGImage image = static_cast(m_texture->textureId()); + + //Apply the TextureCoordinateTransform Flag + if (m_transformMode != QSGImageNode::NoTransform) { + float translateX = 0.0f; + float translateY = 0.0f; + float scaleX = 1.0f; + float scaleY = 1.0f; + + if (m_transformMode & QSGImageNode::MirrorHorizontally) { + translateX = m_rect.width(); + scaleX = -1.0; + } + + if (m_transformMode & QSGImageNode::MirrorVertically) { + translateY = m_rect.height(); + scaleY = -1.0; + } + + vgTranslate(translateX, translateY); + vgScale(scaleX, scaleY); + } + + // If the the source rect is the same as the target rect + if (m_sourceRect == m_rect) { + vgDrawImage(image); + } else { + // Scale + float scaleX = m_rect.width() / m_sourceRect.width(); + float scaleY = m_rect.height() / m_sourceRect.height(); + vgScale(scaleX, scaleY); + VGImage subImage = vgChildImage(image, m_sourceRect.x(), m_sourceRect.y(), m_sourceRect.width(), m_sourceRect.height()); + vgDrawImage(subImage); + vgDestroyImage(subImage); + } + +} + +QSGOpenVGNinePatchNode::QSGOpenVGNinePatchNode() +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); + +} + +void QSGOpenVGNinePatchNode::setTexture(QSGTexture *texture) +{ + m_texture = texture; + markDirty(DirtyMaterial); +} + +void QSGOpenVGNinePatchNode::setBounds(const QRectF &bounds) +{ + if (m_bounds == bounds) + return; + m_bounds = bounds; + markDirty(DirtyGeometry); +} + +void QSGOpenVGNinePatchNode::setDevicePixelRatio(qreal ratio) +{ + if (m_pixelRatio == ratio) + return; + m_pixelRatio = ratio; + markDirty(DirtyGeometry); +} + +void QSGOpenVGNinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom) +{ + QMarginsF margins(left, top, right, bottom); + if (m_margins == margins) + return; + m_margins = margins; + markDirty(DirtyGeometry); +} + +void QSGOpenVGNinePatchNode::update() +{ + +} + +void QSGOpenVGNinePatchNode::render() +{ + if (!m_texture) + return; + + // Set Draw Mode + if (opacity() < 1.0) { + //Transparent + vgSetPaint(opacityPaint(), VG_FILL_PATH); + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); + } else { + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); + } + + VGImage image = static_cast(m_texture->textureId()); + + //Draw borderImage + QSGOpenVGHelpers::qDrawBorderImage(image, m_texture->textureSize(), m_bounds, m_bounds.marginsRemoved(m_margins), QRectF(0, 0, 1, 1)); +} + +QRectF QSGOpenVGNinePatchNode::bounds() const +{ + return m_bounds; +} + + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h new file mode 100644 index 0000000000..70b087e9fc --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h @@ -0,0 +1,143 @@ +#ifndef QSGOPENVGPUBLICNODES_H +#define QSGOPENVGPUBLICNODES_H + +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 +#include +#include + +#include + +#include + +#include "qsgopenvgrenderable.h" + +QT_BEGIN_NAMESPACE + +class QSGOpenVGRectangleNode : public QSGRectangleNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGRectangleNode(); + ~QSGOpenVGRectangleNode(); + + void setRect(const QRectF &rect) override; + QRectF rect() const override { return m_rect; } + + void setColor(const QColor &color) override; + QColor color() const override { return m_color; } + + void render() override; + +private: + QRectF m_rect; + QColor m_color; + + + bool m_pathDirty = true; + bool m_paintDirty = true; + + VGPath m_rectPath; + VGPaint m_rectPaint; +}; + +class QSGOpenVGImageNode : public QSGImageNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGImageNode(); + ~QSGOpenVGImageNode(); + + void setRect(const QRectF &rect) override { m_rect = rect; markDirty(DirtyMaterial); } + QRectF rect() const override { return m_rect; } + + void setSourceRect(const QRectF &r) override { m_sourceRect = r; } + QRectF sourceRect() const override { return m_sourceRect; } + + void setTexture(QSGTexture *texture) override; + QSGTexture *texture() const override { return m_texture; } + + void setFiltering(QSGTexture::Filtering filtering) override { m_filtering = filtering; markDirty(DirtyMaterial); } + QSGTexture::Filtering filtering() const override { return m_filtering; } + + void setMipmapFiltering(QSGTexture::Filtering) override { } + QSGTexture::Filtering mipmapFiltering() const override { return QSGTexture::None; } + + void setTextureCoordinatesTransform(TextureCoordinatesTransformMode transformNode) override; + TextureCoordinatesTransformMode textureCoordinatesTransform() const override { return m_transformMode; } + + void setOwnsTexture(bool owns) override { m_owns = owns; } + bool ownsTexture() const override { return m_owns; } + + void render() override; + +private: + QSGTexture *m_texture; + QRectF m_rect; + QRectF m_sourceRect; + bool m_owns; + QSGTexture::Filtering m_filtering; + TextureCoordinatesTransformMode m_transformMode; +}; + +class QSGOpenVGNinePatchNode : public QSGNinePatchNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGNinePatchNode(); + + void setTexture(QSGTexture *texture) override; + void setBounds(const QRectF &bounds) override; + void setDevicePixelRatio(qreal ratio) override; + void setPadding(qreal left, qreal top, qreal right, qreal bottom) override; + void update() override; + + void render() override; + + QRectF bounds() const; + +private: + QSGTexture *m_texture; + QRectF m_bounds; + qreal m_pixelRatio; + QMarginsF m_margins; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGPUBLICNODES_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp new file mode 100644 index 0000000000..0856acfc9a --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgrenderable.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGRenderable::QSGOpenVGRenderable() + : m_opacity(1.0f) +{ + m_opacityPaint = vgCreatePaint(); +} + +QSGOpenVGRenderable::~QSGOpenVGRenderable() +{ + vgDestroyPaint(m_opacityPaint); +} + +void QSGOpenVGRenderable::setOpacity(float opacity) +{ + if (m_opacity == opacity) + return; + + m_opacity = opacity; + VGfloat values[] = { + 1.0f, 1.0f, 1.0f, m_opacity + }; + vgSetParameterfv(m_opacityPaint, VG_PAINT_COLOR, 4, values); +} + +float QSGOpenVGRenderable::opacity() const +{ + return m_opacity; +} + +VGPaint QSGOpenVGRenderable::opacityPaint() const +{ + return m_opacityPaint; +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h new file mode 100644 index 0000000000..7a09f2afbe --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGRENDERABLE_H +#define QSGOPENVGRENDERABLE_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGRenderable +{ +public: + QSGOpenVGRenderable(); + virtual ~QSGOpenVGRenderable(); + + virtual void render() = 0; + + virtual void setOpacity(float opacity); + float opacity() const; + VGPaint opacityPaint() const; + +private: + float m_opacity; + VGPaint m_opacityPaint; + +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGRENDERABLE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp new file mode 100644 index 0000000000..acd4cf88dc --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderer.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgrenderer_p.h" +#include "qsgopenvgcontext_p.h" +#include "qsgopenvgnodevisitor.h" +#include "qopenvgcontext_p.h" +#include "qsgopenvghelpers.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +QSGOpenVGRenderer::QSGOpenVGRenderer(QSGRenderContext *context) + : QSGRenderer(context) +{ + +} + +QSGOpenVGRenderer::~QSGOpenVGRenderer() +{ + +} + +void QSGOpenVGRenderer::renderScene(uint fboId) +{ + Q_UNUSED(fboId) + class B : public QSGBindable + { + public: + void bind() const { } + } bindable; + QSGRenderer::renderScene(bindable); +} + +void QSGOpenVGRenderer::render() +{ + //Clear the window geometry with the clear color + vgSetfv(VG_CLEAR_COLOR, 4, QSGOpenVGHelpers::qColorToVGColor(clearColor()).constData()); + vgClear(0, 0, VG_MAXINT, VG_MAXINT); + + // Visit each node to render scene + QSGOpenVGNodeVisitor rendererVisitor; + rendererVisitor.visitChildren(rootNode()); +} + +void QSGOpenVGRenderer::nodeChanged(QSGNode *node, QSGNode::DirtyState state) +{ + QSGRenderer::nodeChanged(node, state); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h new file mode 100644 index 0000000000..24cabd1b89 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderer_p.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGRENDERER_H +#define QSGOPENVGRENDERER_H + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGRenderer : public QSGRenderer +{ +public: + QSGOpenVGRenderer(QSGRenderContext *context); + virtual ~QSGOpenVGRenderer(); + + void nodeChanged(QSGNode *node, QSGNode::DirtyState state) override; + + void renderScene(uint fboId = 0) final; + void render() final; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGRENDERER_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp new file mode 100644 index 0000000000..290ee8028c --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp @@ -0,0 +1,257 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgrenderloop_p.h" +#include "qsgopenvgcontext_p.h" + +#include +#include + +#include +#include + +#include "qopenvgcontext_p.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGRenderLoop::QSGOpenVGRenderLoop() + : vg(nullptr) +{ + sg = QSGContext::createDefaultContext(); + rc = sg->createRenderContext(); +} + +QSGOpenVGRenderLoop::~QSGOpenVGRenderLoop() +{ + delete rc; + delete sg; +} + +void QSGOpenVGRenderLoop::show(QQuickWindow *window) +{ + WindowData data; + data.updatePending = false; + data.grabOnly = false; + m_windows[window] = data; + + maybeUpdate(window); +} + +void QSGOpenVGRenderLoop::hide(QQuickWindow *window) +{ + QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); + cd->fireAboutToStop(); +} + +void QSGOpenVGRenderLoop::windowDestroyed(QQuickWindow *window) +{ + m_windows.remove(window); + hide(window); + + QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); + d->cleanupNodesOnShutdown(); + + if (m_windows.size() == 0) { + rc->invalidate(); + delete vg; + vg = nullptr; + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + } else if (vg && window == vg->window()) { + vg->doneCurrent(); + } +} + +void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window) +{ + if (window->isExposed()) { + m_windows[window].updatePending = true; + renderWindow(window); + } +} + +QImage QSGOpenVGRenderLoop::grab(QQuickWindow *window) +{ + if (!m_windows.contains(window)) + return QImage(); + + m_windows[window].grabOnly = true; + + renderWindow(window); + + QImage grabbed = grabContent; + grabContent = QImage(); + return grabbed; +} + +void QSGOpenVGRenderLoop::update(QQuickWindow *window) +{ + maybeUpdate(window); +} + +void QSGOpenVGRenderLoop::handleUpdateRequest(QQuickWindow *window) +{ + renderWindow(window); +} + +void QSGOpenVGRenderLoop::maybeUpdate(QQuickWindow *window) +{ + if (!m_windows.contains(window)) + return; + + m_windows[window].updatePending = true; + window->requestUpdate(); +} + +QAnimationDriver *QSGOpenVGRenderLoop::animationDriver() const +{ + return nullptr; +} + +QSGContext *QSGOpenVGRenderLoop::sceneGraphContext() const +{ + return sg; +} + +QSGRenderContext *QSGOpenVGRenderLoop::createRenderContext(QSGContext *) const +{ + return rc; +} + +void QSGOpenVGRenderLoop::releaseResources(QQuickWindow *window) +{ + Q_UNUSED(window) +} + +QSurface::SurfaceType QSGOpenVGRenderLoop::windowSurfaceType() const +{ + return QSurface::OpenVGSurface; +} + +void QSGOpenVGRenderLoop::renderWindow(QQuickWindow *window) +{ + QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); + if (!cd->isRenderable() || !m_windows.contains(window)) + return; + + WindowData &data = const_cast(m_windows[window]); + + if (vg == nullptr) { + vg = new QOpenVGContext(window); + vg->makeCurrent(); + cd->context->initialize(vg); + } else { + vg->makeCurrent(); + } + + bool alsoSwap = data.updatePending; + data.updatePending = false; + + if (!data.grabOnly) { + // Event delivery/processing triggered the window to be deleted or stop rendering. + if (!m_windows.contains(window)) + return; + } + QElapsedTimer renderTimer; + qint64 renderTime = 0, syncTime = 0, polishTime = 0; + bool profileFrames = QSG_OPENVG_LOG_TIME_RENDERLOOP().isDebugEnabled(); + if (profileFrames) + renderTimer.start(); + Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishFrame); + + cd->polishItems(); + + if (profileFrames) + polishTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, + QQuickProfiler::SceneGraphRenderLoopFrame); + + emit window->afterAnimating(); + + cd->syncSceneGraph(); + + if (profileFrames) + syncTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + + // setup coordinate system for window + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + vgTranslate(0.0f, window->size().height()); + vgScale(1.0, -1.0); + + cd->renderSceneGraph(window->size()); + + if (profileFrames) + renderTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + + if (data.grabOnly) { + grabContent = vg->readFramebuffer(window->size() * window->effectiveDevicePixelRatio()); + data.grabOnly = false; + } + + if (alsoSwap && window->isVisible()) { + vg->swapBuffers(); + cd->fireFrameSwapped(); + } + + qint64 swapTime = 0; + if (profileFrames) + swapTime = renderTimer.nsecsElapsed(); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + + if (QSG_OPENVG_LOG_TIME_RENDERLOOP().isDebugEnabled()) { + static QTime lastFrameTime = QTime::currentTime(); + qCDebug(QSG_OPENVG_LOG_TIME_RENDERLOOP, + "Frame rendered with 'basic' renderloop in %dms, polish=%d, sync=%d, render=%d, swap=%d, frameDelta=%d", + int(swapTime / 1000000), + int(polishTime / 1000000), + int((syncTime - polishTime) / 1000000), + int((renderTime - syncTime) / 1000000), + int((swapTime - renderTime) / 10000000), + int(lastFrameTime.msecsTo(QTime::currentTime()))); + lastFrameTime = QTime::currentTime(); + } + + // Might have been set during syncSceneGraph() + if (data.updatePending) + maybeUpdate(window); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h new file mode 100644 index 0000000000..f35b689e00 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGRENDERLOOP_H +#define QSGOPENVGRENDERLOOP_H + +#include + +QT_BEGIN_NAMESPACE + +class QOpenVGContext; + +class QSGOpenVGRenderLoop : public QSGRenderLoop +{ +public: + QSGOpenVGRenderLoop(); + ~QSGOpenVGRenderLoop(); + + + void show(QQuickWindow *window) override; + void hide(QQuickWindow *window) override; + + void windowDestroyed(QQuickWindow *window) override; + + void renderWindow(QQuickWindow *window); + void exposureChanged(QQuickWindow *window) override; + QImage grab(QQuickWindow *window) override; + + void maybeUpdate(QQuickWindow *window) override; + void update(QQuickWindow *window) override; + void handleUpdateRequest(QQuickWindow *window) override; + + void releaseResources(QQuickWindow *) override; + + QSurface::SurfaceType windowSurfaceType() const override; + + QAnimationDriver *animationDriver() const override; + + QSGContext *sceneGraphContext() const override; + QSGRenderContext *createRenderContext(QSGContext *) const override; + + struct WindowData { + bool updatePending : 1; + bool grabOnly : 1; + }; + + QHash m_windows; + + QSGContext *sg; + QSGRenderContext *rc; + QOpenVGContext *vg; + + QImage grabContent; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGRENDERLOOP_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp new file mode 100644 index 0000000000..9bce12c83f --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgspritenode.h" +#include "qsgopenvgtexture.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGSpriteNode::QSGOpenVGSpriteNode() + : m_time(0.0f) +{ + // Set Dummy material and geometry to avoid asserts + setMaterial((QSGMaterial*)1); + setGeometry((QSGGeometry*)1); +} + +QSGOpenVGSpriteNode::~QSGOpenVGSpriteNode() +{ + +} + +void QSGOpenVGSpriteNode::setTexture(QSGTexture *texture) +{ + m_texture = static_cast(texture); + markDirty(DirtyMaterial); +} + +void QSGOpenVGSpriteNode::setTime(float time) +{ + if (m_time != time) { + m_time = time; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGSpriteNode::setSourceA(const QPoint &source) +{ + if (m_sourceA != source) { + m_sourceA = source; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGSpriteNode::setSourceB(const QPoint &source) +{ + if (m_sourceB != source) { + m_sourceB = source; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGSpriteNode::setSpriteSize(const QSize &size) +{ + if (m_spriteSize != size) { + m_spriteSize = size; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGSpriteNode::setSheetSize(const QSize &size) +{ + if (m_sheetSize != size) { + m_sheetSize = size; + markDirty(DirtyMaterial); + } +} + +void QSGOpenVGSpriteNode::setSize(const QSizeF &size) +{ + if (m_size != size) { + m_size = size; + markDirty(DirtyGeometry); + } +} + +void QSGOpenVGSpriteNode::setFiltering(QSGTexture::Filtering) +{ +} + +void QSGOpenVGSpriteNode::update() +{ +} + +void QSGOpenVGSpriteNode::render() +{ + if (!m_texture) + return; + + VGImage image = static_cast(m_texture->textureId()); + + QRectF sourceRect(m_sourceA, m_spriteSize); + QRectF targetRect(0, 0, m_size.width(), m_size.height()); + + VGImage sourceImage = vgChildImage(image, sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height()); + + // Set Draw Mode + if (opacity() < 1.0) { + //Transparent + vgSetPaint(opacityPaint(), VG_FILL_PATH); + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_MULTIPLY); + } else { + vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); + } + + if (sourceRect != targetRect) { + // Scale + float scaleX = targetRect.width() / sourceRect.width(); + float scaleY = targetRect.height() / sourceRect.height(); + vgScale(scaleX, scaleY); + } + + vgDrawImage(sourceImage); + + vgDestroyImage(sourceImage); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h new file mode 100644 index 0000000000..3ade2ef8ad --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGSPRITENODE_H +#define QSGOPENVGSPRITENODE_H + +#include +#include "qsgopenvgrenderable.h" + +QT_BEGIN_NAMESPACE +class QSGOpenVGTexture; +class QSGOpenVGSpriteNode : public QSGSpriteNode, public QSGOpenVGRenderable +{ +public: + QSGOpenVGSpriteNode(); + ~QSGOpenVGSpriteNode(); + + void setTexture(QSGTexture *texture) override; + void setTime(float time) override; + void setSourceA(const QPoint &source) override; + void setSourceB(const QPoint &source) override; + void setSpriteSize(const QSize &size) override; + void setSheetSize(const QSize &size) override; + void setSize(const QSizeF &size) override; + void setFiltering(QSGTexture::Filtering filtering) override; + void update() override; + + void render() override; + +private: + QSGOpenVGTexture *m_texture; + float m_time; + QPoint m_sourceA; + QPoint m_sourceB; + QSize m_spriteSize; + QSize m_sheetSize; + QSizeF m_size; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGSPRITENODE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp b/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp new file mode 100644 index 0000000000..dd2fdc7020 --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgtexture.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qsgopenvgtexture.h" +#include "qsgopenvghelpers.h" + +QT_BEGIN_NAMESPACE + +QSGOpenVGTexture::QSGOpenVGTexture(const QImage &image, uint flags) +{ + Q_UNUSED(flags) + + VGImageFormat format = QSGOpenVGHelpers::qImageFormatToVGImageFormat(image.format()); + m_image = vgCreateImage(format, image.width(), image.height(), VG_IMAGE_QUALITY_BETTER); + + // Do Texture Upload + vgImageSubData(m_image, image.constBits(), image.bytesPerLine(), format, 0, 0, image.width(), image.height()); +} + +QSGOpenVGTexture::~QSGOpenVGTexture() +{ + vgDestroyImage(m_image); +} + +int QSGOpenVGTexture::textureId() const +{ + return static_cast(m_image); +} + +QSize QSGOpenVGTexture::textureSize() const +{ + VGint imageWidth = vgGetParameteri(m_image, VG_IMAGE_WIDTH); + VGint imageHeight = vgGetParameteri(m_image, VG_IMAGE_HEIGHT); + return QSize(imageWidth, imageHeight); +} + +bool QSGOpenVGTexture::hasAlphaChannel() const +{ + VGImageFormat format = static_cast(vgGetParameteri(m_image, VG_IMAGE_FORMAT)); + + switch (format) { + case VG_sRGBA_8888: + case VG_sRGBA_8888_PRE: + case VG_sRGBA_5551: + case VG_sRGBA_4444: + case VG_lRGBA_8888: + case VG_lRGBA_8888_PRE: + case VG_A_8: + case VG_A_1: + case VG_A_4: + case VG_sARGB_8888: + case VG_sARGB_8888_PRE: + case VG_sARGB_1555: + case VG_sARGB_4444: + case VG_lARGB_8888: + case VG_lARGB_8888_PRE: + case VG_sBGRA_8888: + case VG_sBGRA_8888_PRE: + case VG_sBGRA_5551: + case VG_sBGRA_4444: + case VG_lBGRA_8888: + case VG_lBGRA_8888_PRE: + case VG_sABGR_8888: + case VG_sABGR_8888_PRE: + case VG_sABGR_1555: + case VG_sABGR_4444: + case VG_lABGR_8888: + case VG_lABGR_8888_PRE: + return true; + break; + default: + break; + } + return false; +} + +bool QSGOpenVGTexture::hasMipmaps() const +{ + return false; +} + +void QSGOpenVGTexture::bind() +{ + // No need to bind +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgtexture.h b/src/plugins/scenegraph/openvg/qsgopenvgtexture.h new file mode 100644 index 0000000000..523c9e690d --- /dev/null +++ b/src/plugins/scenegraph/openvg/qsgopenvgtexture.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QSGOPENVGTEXTURE_H +#define QSGOPENVGTEXTURE_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QSGOpenVGTexture : public QSGTexture +{ +public: + QSGOpenVGTexture(const QImage &image, uint flags); + ~QSGOpenVGTexture(); + + int textureId() const override; + QSize textureSize() const override; + bool hasAlphaChannel() const override; + bool hasMipmaps() const override; + void bind() override; + +private: + VGImage m_image;; +}; + +QT_END_NAMESPACE + +#endif // QSGOPENVGTEXTURE_H diff --git a/src/plugins/scenegraph/scenegraph.pro b/src/plugins/scenegraph/scenegraph.pro index a90e8d4814..39c0c0815c 100644 --- a/src/plugins/scenegraph/scenegraph.pro +++ b/src/plugins/scenegraph/scenegraph.pro @@ -1,3 +1,5 @@ TEMPLATE = subdirs QT_FOR_CONFIG += quick qtConfig(d3d12): SUBDIRS += d3d12 +qtConfig(openvg): SUBDIRS += openvg + diff --git a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc index 9ce26e1bb8..3fd92177f9 100644 --- a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc +++ b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc @@ -58,6 +58,8 @@ The supported backends are the following \li Direct3D 12 - Requested by the string \c{"d3d12"} or the enum value QSGRendererInterface::Direct3D12. +\li OpenVG - Requested by the string \c{"openvg"} or the enum value QSGRendererInterface::OpenVG. + \endlist When in doubt which backend is in use, enable basic scenegraph information @@ -92,6 +94,14 @@ running on Windows 10, both for Win32 and UWP applications. The details for this adaptation are available here: \l{qtquick-visualcanvas-adaptations-d3d12.html}{Direct3D 12 Adaptation} +\section1 OpenVG + +The OpenVG adaptation is an alternative renderer for \l {Qt Quick} 2 that will +renderer the contents of the scene graph using OpenVG commands to provide +hardware-acclerated 2D vector and raster graphics. The details for this +adaptation are available here: +\l{qtquick-visualcanvas-scenegraph-openvg.html}{OpenVG Adaptation} + */ @@ -387,3 +397,73 @@ between the frames). By default blocking present is disabled. \endlist */ + +/*! +\title Qt Quick OpenVG Adaptation +\page qtquick-visualcanvas-adaptations-openvg.html + +The OpenVG adaptation is an alternative renderer for \l {Qt Quick} 2 that will +renderer the contents of the scene graph using OpenVG commands to provide +hardware-acclerated 2D vector and raster graphics. Much like the Software +adaptation, some features and optimizations are no longer available. Most +Qt Quick 2 applications will run without modification though any attempts to +use unsupported features will be ignored. + +\section2 EGL Requirement +Unlike the defualt OpenGL Renderer, there is no built in support for acquiring +an OpenVG context. This means that the renderer has the responsbility of +requesting and managing the the current context. To do this EGL has to be used +directly in the OpenVG renderer. This means that the OpenVG renderer is only +usable with platform plugins that support creating QWindows with support for +QSurfaceFormat::OpenVG. From this window, the renderer can get an EGLSurface +which can be used with an EGLContext to render OpenVG content. + +\section2 Renderer +The OpenVG Renderer works by using the OpenVG API to send commands and data to +a Vector GPU which will render the scenegraph in an accelerated manner, offloading +graphics rendering from the CPU. Many operations like the rendering of rectangles +and fonts glyphs ideal for OpenVG because these can be represented as paths which +are stroked and filled. Rendering scenegraph items that would typically involve +textures are handled in the OpenVG renderer by using VGImage. In addition when +rendering to offscreen surfaces (like when using Layers), the scene subtree is +rendered to a VGImage which can be reused in the scene. + +\section2 Render Loop +The OpenVG Renderer mirrors the behavior of the Basic render loop and will execute +all OpenVG commands in a single thread. + +See the \l{qtquick-visualcanvas-scenegraph.html}{Scene Graph page} for more +information on render loops + +\section2 Shader Effects +ShaderEffect components in QtQuick 2 can not be rendered by the OpenVG adaptation. +While it is possible to user ShaderEffectSource and QML Item Layers (which are both +offscreen surfaces), it is not actually possible to apply shader effects to them +via the ShaderEffect item. This is because OpenVG lacks an API for applying per +vertex and per fragment shader operations. It may be possible however to take +advantage of Image Filter operations in the OpenVG API to get similar effects to +what is provided by ShaderEffects in custom items. To integrate custom OpenVG +rendering, use QSGRenderNode in combination with QSGRendererInterface. + +\section2 Qt Graphical Effects Module +\l {Qt Graphical Effects} uses ShaderEffect items to render effects. If you use +graphical effects from this module, then you should not hide the source +item so that the original item can still be rendered. + +\section2 Particle Effects +It is not possible to render particle effects with the OpenVG adaptation. Whenever +possible, remove particles completely from the scene. Otherwise they will still +require some processing, even though they are not visible. + +\section2 Rendering Text +The text rendering with the OpenVG adaptation is based on rendering the glpyh +paths, and does not use the distance fields technique used by the OpenGL backend. + +\section2 Perspective Transforms +The OpenVG API does not allow paths to be transformed with non-affine transforms, +while it is possible with Qt Quick. This means that rendering components using +paths like Rectangles and Text, when applying perspective transforms the OpenVG +backend will first render to a VGImage before applying transformations. This uses +more memory at runtime and is a slower path so avoid doing this if necessary. + +*/ diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp index d309044e8f..3b0b2faf97 100644 --- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp +++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp @@ -77,6 +77,7 @@ QT_BEGIN_NAMESPACE \value Software The Qt Quick 2D Renderer is in use \value OpenGL OpenGL ES 2.0 or higher \value Direct3D12 Direct3D 12 + \value OpenVG OpenVG via EGL */ /*! diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.h b/src/quick/scenegraph/coreapi/qsgrendererinterface.h index cf8fcf9015..722488201b 100644 --- a/src/quick/scenegraph/coreapi/qsgrendererinterface.h +++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.h @@ -53,7 +53,8 @@ public: Unknown, Software, OpenGL, - Direct3D12 + Direct3D12, + OpenVG }; enum Resource { -- cgit v1.2.3 From 0119439c9d25dfd892bbee47068e9d726f4bff97 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 29 Nov 2016 15:29:39 +0100 Subject: OpenVG: Support rendering paths with non-affine transforms The current approach to rendering paths (used by Rectangles and Glyph nodes) does not support rendering with non-affine transformations. That is because OpenVG does not support passing a non-affine transformation matrix when rendering paths. So instead when using a non-affine transform we will fallback to rendering to an offscreen VGImage, then rendering that as an image which can have a perspective transform. Change-Id: I01508bcb67b339323cb6400c7ff6d885b62c5e02 Reviewed-by: Laszlo Agocs --- src/plugins/scenegraph/openvg/openvg.pro | 6 +- src/plugins/scenegraph/openvg/qopenvgmatrix.cpp | 53 ++++++ src/plugins/scenegraph/openvg/qopenvgmatrix.h | 9 + .../scenegraph/openvg/qopenvgoffscreensurface.cpp | 113 +++++++++++ .../scenegraph/openvg/qopenvgoffscreensurface.h | 73 ++++++++ .../scenegraph/openvg/qsgopenvgglyphnode.cpp | 23 +++ .../openvg/qsgopenvginternalimagenode.cpp | 3 + .../openvg/qsgopenvginternalrectanglenode.cpp | 207 ++++++++++++++++----- .../openvg/qsgopenvginternalrectanglenode.h | 4 + src/plugins/scenegraph/openvg/qsgopenvglayer.cpp | 126 +++---------- src/plugins/scenegraph/openvg/qsgopenvglayer.h | 7 +- .../scenegraph/openvg/qsgopenvgnodevisitor.cpp | 60 +++--- .../scenegraph/openvg/qsgopenvgnodevisitor.h | 14 +- .../scenegraph/openvg/qsgopenvgpainternode.cpp | 4 + .../scenegraph/openvg/qsgopenvgpublicnodes.cpp | 59 ++++++ .../scenegraph/openvg/qsgopenvgpublicnodes.h | 2 + .../scenegraph/openvg/qsgopenvgrenderable.cpp | 10 + .../scenegraph/openvg/qsgopenvgrenderable.h | 6 + .../scenegraph/openvg/qsgopenvgspritenode.cpp | 4 + 19 files changed, 586 insertions(+), 197 deletions(-) create mode 100644 src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp create mode 100644 src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h diff --git a/src/plugins/scenegraph/openvg/openvg.pro b/src/plugins/scenegraph/openvg/openvg.pro index fb9b3b93f5..8a58796a05 100644 --- a/src/plugins/scenegraph/openvg/openvg.pro +++ b/src/plugins/scenegraph/openvg/openvg.pro @@ -31,7 +31,8 @@ HEADERS += \ qsgopenvgfontglyphcache.h \ qsgopenvgpainternode.h \ qsgopenvgspritenode.h \ - qsgopenvgrenderable.h + qsgopenvgrenderable.h \ + qopenvgoffscreensurface.h SOURCES += \ qsgopenvgadaptation.cpp \ @@ -51,4 +52,5 @@ SOURCES += \ qsgopenvgfontglyphcache.cpp \ qsgopenvgpainternode.cpp \ qsgopenvgspritenode.cpp \ - qsgopenvgrenderable.cpp + qsgopenvgrenderable.cpp \ + qopenvgoffscreensurface.cpp diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp index e55de2ce0d..83ce96578e 100644 --- a/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp +++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.cpp @@ -97,6 +97,19 @@ void QOpenVGMatrix::setToIdentity() m[2][2] = 1.0f; } +bool QOpenVGMatrix::isAffine() const +{ + if (m[0][2] == 0.0f && m[1][2] == 0.0f && m[2][2] == 1.0f) + return true; + + return false; +} + +QPointF QOpenVGMatrix::map(const QPointF &point) const +{ + return *this * point; +} + void QOpenVGMatrix::fill(float value) { m[0][0] = value; @@ -287,6 +300,46 @@ QOpenVGMatrix operator*(const QOpenVGMatrix &m1, const QOpenVGMatrix &m2) return matrix; } +QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix) +{ + float xin = point.x(); + float yin = point.y(); + float x = xin * matrix.m[0][0] + + yin * matrix.m[0][1] + + matrix.m[0][2]; + float y = xin * matrix.m[1][0] + + yin * matrix.m[1][1] + + matrix.m[1][2]; + float w = xin * matrix.m[2][0] + + yin * matrix.m[2][1] + + matrix.m[2][2]; + if (w == 1.0f) { + return QPointF(float(x), float(y)); + } else { + return QPointF(float(x / w), float(y / w)); + } +} + +QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point) +{ + float xin = point.x(); + float yin = point.y(); + float x = xin * matrix.m[0][0] + + yin * matrix.m[1][0] + + matrix.m[2][0]; + float y = xin * matrix.m[0][1] + + yin * matrix.m[1][1] + + matrix.m[2][1]; + float w = xin * matrix.m[0][2] + + yin * matrix.m[1][2] + + matrix.m[2][2]; + if (w == 1.0f) { + return QPointF(float(x), float(y)); + } else { + return QPointF(float(x / w), float(y / w)); + } +} + QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m) { QDebugStateSaver saver(dbg); diff --git a/src/plugins/scenegraph/openvg/qopenvgmatrix.h b/src/plugins/scenegraph/openvg/qopenvgmatrix.h index 644c9da5bc..f51bf8147d 100644 --- a/src/plugins/scenegraph/openvg/qopenvgmatrix.h +++ b/src/plugins/scenegraph/openvg/qopenvgmatrix.h @@ -42,6 +42,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -57,6 +58,10 @@ public: bool isIdentity() const; void setToIdentity(); + bool isAffine() const; + + QPointF map(const QPointF& point) const; + void fill(float value); QOpenVGMatrix transposed() const; @@ -67,6 +72,8 @@ public: QOpenVGMatrix& operator*=(float factor); QOpenVGMatrix& operator/=(float divisor); friend QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2); + friend QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix); + friend QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point); #ifndef QT_NO_DEBUG_STREAM friend QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m); #endif @@ -84,6 +91,8 @@ private: }; QOpenVGMatrix operator*(const QOpenVGMatrix& m1, const QOpenVGMatrix& m2); +QPointF operator*(const QPointF& point, const QOpenVGMatrix& matrix); +QPointF operator*(const QOpenVGMatrix& matrix, const QPointF& point); #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QOpenVGMatrix &m); diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp new file mode 100644 index 0000000000..3a4643ab5a --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 "qopenvgoffscreensurface.h" + +QT_BEGIN_NAMESPACE + +QOpenVGOffscreenSurface::QOpenVGOffscreenSurface(const QSize &size) + : m_size(size) +{ + m_display = eglGetCurrentDisplay(); + m_image = vgCreateImage(VG_sARGB_8888_PRE, m_size.width(), m_size.height(), VG_IMAGE_QUALITY_BETTER); + + const EGLint configAttribs[] = { + EGL_CONFORMANT, EGL_OPENVG_BIT, + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_ALPHA_MASK_SIZE, 8, + EGL_NONE + }; + + EGLConfig pbufferConfig; + EGLint numConfig; + eglChooseConfig(m_display, configAttribs, &pbufferConfig, 1, &numConfig); + + m_context = eglCreateContext(m_display, pbufferConfig, eglGetCurrentContext(), 0); + if (m_context == EGL_NO_CONTEXT) + qWarning("QOpenVGOffscreenSurface: failed to create EGLContext"); + + m_renderTarget = eglCreatePbufferFromClientBuffer(m_display, + EGL_OPENVG_IMAGE, + (EGLClientBuffer)m_image, + pbufferConfig, + 0); + if (m_renderTarget == EGL_NO_SURFACE) + qWarning("QOpenVGOffscreenSurface: failed to create EGLSurface from VGImage"); +} + +QOpenVGOffscreenSurface::~QOpenVGOffscreenSurface() +{ + vgDestroyImage(m_image); + eglDestroySurface(m_display, m_renderTarget); +} + +void QOpenVGOffscreenSurface::makeCurrent() +{ + EGLContext currentContext = eglGetCurrentContext(); + if (m_context != currentContext) { + m_previousContext = eglGetCurrentContext(); + m_previousReadSurface = eglGetCurrentSurface(EGL_READ); + m_previousDrawSurface = eglGetCurrentSurface(EGL_DRAW); + + eglMakeCurrent(m_display, m_renderTarget, m_renderTarget, m_context); + } +} + +void QOpenVGOffscreenSurface::doneCurrent() +{ + EGLContext currentContext = eglGetCurrentContext(); + if (m_context == currentContext) { + eglMakeCurrent(m_display, m_previousDrawSurface, m_previousReadSurface, m_previousContext); + m_context = EGL_NO_CONTEXT; + m_previousContext = EGL_NO_CONTEXT; + m_previousReadSurface = EGL_NO_SURFACE; + m_previousDrawSurface = EGL_NO_SURFACE; + } +} + +void QOpenVGOffscreenSurface::swapBuffers() +{ + eglSwapBuffers(m_display, m_renderTarget); +} + +QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h new file mode 100644 index 0000000000..833c9669bf --- /dev/null +++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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 QOPENVGOFFSCREENSURFACE_H +#define QOPENVGOFFSCREENSURFACE_H + +#include "qopenvgcontext_p.h" + +QT_BEGIN_NAMESPACE + +class QOpenVGOffscreenSurface +{ +public: + QOpenVGOffscreenSurface(const QSize &size); + ~QOpenVGOffscreenSurface(); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + + VGImage image() { return m_image; } + QSize size() const { return m_size; } + +private: + VGImage m_image; + QSize m_size; + EGLContext m_context; + EGLSurface m_renderTarget; + EGLContext m_previousContext = EGL_NO_CONTEXT; + EGLSurface m_previousReadSurface = EGL_NO_SURFACE; + EGLSurface m_previousDrawSurface = EGL_NO_SURFACE; + EGLDisplay m_display; +}; + +QT_END_NAMESPACE + +#endif // QOPENVGOFFSCREENSURFACE_H diff --git a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp index c90f0f0bbe..8be2a97034 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgglyphnode.cpp @@ -42,6 +42,7 @@ #include "qsgopenvgcontext_p.h" #include "qsgopenvghelpers.h" #include "qsgopenvgfontglyphcache.h" +#include "qopenvgoffscreensurface.h" QT_BEGIN_NAMESPACE @@ -82,6 +83,7 @@ void QSGOpenVGGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &gly m_position = position; m_glyphRun = glyphs; + m_bounding_rect = glyphs.boundingRect().translated(m_position - QPointF(0.0, glyphs.rawFont().ascent())); // Recreate ajustments m_xAdjustments.clear(); @@ -133,8 +135,22 @@ void QSGOpenVGGlyphNode::render() // Rendering Style qreal offset = 1.0; + QOpenVGOffscreenSurface *offscreenSurface = nullptr; + + // Set Transform + vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE); + if (transform().isAffine()) { + vgLoadMatrix(transform().constData()); + } else { + vgLoadIdentity(); + offscreenSurface = new QOpenVGOffscreenSurface(QSize(ceil(m_bounding_rect.width()), ceil(m_bounding_rect.height()))); + offscreenSurface->makeCurrent(); + } + + // Set Quality vgSeti(VG_RENDERING_QUALITY, VG_RENDERING_QUALITY_BETTER); + switch (m_style) { case QQuickText::Normal: break; case QQuickText::Outline: @@ -159,6 +175,13 @@ void QSGOpenVGGlyphNode::render() vgSetPaint(m_fontColorPaint, VG_FILL_PATH); drawGlyphsAtOffset(QPointF(0.0, 0.0)); + if (!transform().isAffine()) { + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + offscreenSurface->doneCurrent(); + vgDrawImage(offscreenSurface->image()); + delete offscreenSurface; + } } void QSGOpenVGGlyphNode::setOpacity(float opacity) diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp index 2ab477f116..c9545d5e9a 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp @@ -72,6 +72,9 @@ void QSGOpenVGInternalImageNode::render() vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); } + // Set Transform + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); VGImage image = static_cast(m_texture->textureId()); QSize textureSize = m_texture->textureSize(); diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp index 372dffbbc2..be437303bc 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.cpp @@ -193,6 +193,33 @@ void QSGOpenVGInternalRectangleNode::update() void QSGOpenVGInternalRectangleNode::render() { + // Set Transform + if (transform().isAffine()) { + // Use current transform matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + if (m_offscreenSurface) { + delete m_offscreenSurface; + m_offscreenSurface = nullptr; + } + } else { + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + if (m_radius > 0) { + // Fallback to rendering to an image for rounded rects with perspective transforms + if (m_offscreenSurface == nullptr || m_offscreenSurface->size() != QSize(ceil(m_rect.width()), ceil(m_rect.height()))) { + delete m_offscreenSurface; + m_offscreenSurface = new QOpenVGOffscreenSurface(QSize(ceil(m_rect.width()), ceil(m_rect.height()))); + } + + m_offscreenSurface->makeCurrent(); + } else if (m_offscreenSurface) { + delete m_offscreenSurface; + m_offscreenSurface = nullptr; + } + } + + // If path is dirty if (m_pathDirty) { vgClearPath(m_rectanglePath, VG_PATH_CAPABILITY_APPEND_TO); @@ -257,6 +284,14 @@ void QSGOpenVGInternalRectangleNode::render() vgSetPaint(m_rectanglePaint, VG_FILL_PATH); vgDrawPath(m_rectanglePath, VG_FILL_PATH); } + + if (!transform().isAffine() && m_radius > 0) { + m_offscreenSurface->doneCurrent(); + // Render offscreen surface + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + vgDrawImage(m_offscreenSurface->image()); + } } void QSGOpenVGInternalRectangleNode::setOpacity(float opacity) @@ -268,6 +303,15 @@ void QSGOpenVGInternalRectangleNode::setOpacity(float opacity) } } +void QSGOpenVGInternalRectangleNode::setTransform(const QOpenVGMatrix &transform) +{ + // if there transform matrix is not affine, regenerate the path + if (transform.isAffine()) + m_pathDirty = true; + + QSGOpenVGRenderable::setTransform(transform); +} + void QSGOpenVGInternalRectangleNode::createVGResources() { m_rectanglePaint = vgCreatePaint(); @@ -280,6 +324,9 @@ void QSGOpenVGInternalRectangleNode::createVGResources() void QSGOpenVGInternalRectangleNode::destroyVGResources() { + if (m_offscreenSurface) + delete m_offscreenSurface; + vgDestroyPaint(m_rectanglePaint); vgDestroyPaint(m_borderPaint); vgDestroyPath(m_rectanglePath); @@ -290,25 +337,50 @@ void QSGOpenVGInternalRectangleNode::generateRectanglePath(const QRectF &rect, f { if (radius == 0) { // Generate a rectangle + if (transform().isAffine()) { + // Create command list + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_CLOSE_PATH + }; - // Create command list - static const VGubyte rectCommands[] = { - VG_MOVE_TO_ABS, - VG_HLINE_TO_REL, - VG_VLINE_TO_REL, - VG_HLINE_TO_REL, - VG_CLOSE_PATH - }; + // Create command data + QVector coordinates(5); + coordinates[0] = rect.x(); + coordinates[1] = rect.y(); + coordinates[2] = rect.width(); + coordinates[3] = rect.height(); + coordinates[4] = -rect.width(); + vgAppendPathData(path, 5, rectCommands, coordinates.constData()); + } else { + // Pre-transform path + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_CLOSE_PATH + }; - // Create command data - QVector coordinates(5); - coordinates[0] = rect.x(); - coordinates[1] = rect.y(); - coordinates[2] = rect.width(); - coordinates[3] = rect.height(); - coordinates[4] = -rect.width(); - - vgAppendPathData(path, 5, rectCommands, coordinates.constData()); + QVector coordinates(8); + const QPointF topLeft = transform().map(rect.topLeft()); + const QPointF topRight = transform().map(rect.topRight()); + const QPointF bottomLeft = transform().map(rect.bottomLeft()); + const QPointF bottomRight = transform().map(rect.bottomRight()); + coordinates[0] = bottomLeft.x(); + coordinates[1] = bottomLeft.y(); + coordinates[2] = bottomRight.x(); + coordinates[3] = bottomRight.y(); + coordinates[4] = topRight.x(); + coordinates[5] = topRight.y(); + coordinates[6] = topLeft.x(); + coordinates[7] = topLeft.y(); + + vgAppendPathData(path, 5, rectCommands, coordinates.constData()); + } } else { // Generate a rounded rectangle //Radius should never exceeds half of the width or half of the height @@ -377,35 +449,82 @@ void QSGOpenVGInternalRectangleNode::generateBorderPath(const QRectF &rect, floa { if (radius == 0) { // squared frame - // Create command list - static const VGubyte squaredBorderCommands[] = { - VG_MOVE_TO_ABS, - VG_HLINE_TO_REL, - VG_VLINE_TO_REL, - VG_HLINE_TO_REL, - VG_MOVE_TO_ABS, - VG_VLINE_TO_REL, - VG_HLINE_TO_REL, - VG_VLINE_TO_REL, - VG_CLOSE_PATH - }; + if (transform().isAffine()) { + // Create command list + static const VGubyte squaredBorderCommands[] = { + VG_MOVE_TO_ABS, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_MOVE_TO_ABS, + VG_VLINE_TO_REL, + VG_HLINE_TO_REL, + VG_VLINE_TO_REL, + VG_CLOSE_PATH + }; - // Create command data - QVector coordinates(10); - // Outside Square - coordinates[0] = rect.x(); - coordinates[1] = rect.y(); - coordinates[2] = rect.width(); - coordinates[3] = rect.height(); - coordinates[4] = -rect.width(); - // Inside Square (opposite direction) - coordinates[5] = rect.x() + borderWidth; - coordinates[6] = rect.y() + borderHeight; - coordinates[7] = rect.height() - (borderHeight * 2); - coordinates[8] = rect.width() - (borderWidth * 2); - coordinates[9] = -(rect.height() - (borderHeight * 2)); + // Create command data + QVector coordinates(10); + // Outside Square + coordinates[0] = rect.x(); + coordinates[1] = rect.y(); + coordinates[2] = rect.width(); + coordinates[3] = rect.height(); + coordinates[4] = -rect.width(); + // Inside Square (opposite direction) + coordinates[5] = rect.x() + borderWidth; + coordinates[6] = rect.y() + borderHeight; + coordinates[7] = rect.height() - (borderHeight * 2); + coordinates[8] = rect.width() - (borderWidth * 2); + coordinates[9] = -(rect.height() - (borderHeight * 2)); + + vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData()); + } else { + // persepective transform + static const VGubyte squaredBorderCommands[] = { + VG_MOVE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_MOVE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_CLOSE_PATH + }; - vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData()); + QVector coordinates(16); + QRectF insideRect = rect.marginsRemoved(QMarginsF(borderWidth, borderHeight, borderWidth, borderHeight)); + QPointF outsideBottomLeft = transform().map(rect.bottomLeft()); + QPointF outsideBottomRight = transform().map(rect.bottomRight()); + QPointF outsideTopRight = transform().map(rect.topRight()); + QPointF outsideTopLeft = transform().map(rect.topLeft()); + QPointF insideBottomLeft = transform().map(insideRect.bottomLeft()); + QPointF insideTopLeft = transform().map(insideRect.topLeft()); + QPointF insideTopRight = transform().map(insideRect.topRight()); + QPointF insideBottomRight = transform().map(insideRect.bottomRight()); + + // Outside + coordinates[0] = outsideBottomLeft.x(); + coordinates[1] = outsideBottomLeft.y(); + coordinates[2] = outsideBottomRight.x(); + coordinates[3] = outsideBottomRight.y(); + coordinates[4] = outsideTopRight.x(); + coordinates[5] = outsideTopRight.y(); + coordinates[6] = outsideTopLeft.x(); + coordinates[7] = outsideTopLeft.y(); + // Inside + coordinates[8] = insideBottomLeft.x(); + coordinates[9] = insideBottomLeft.y(); + coordinates[10] = insideTopLeft.x(); + coordinates[11] = insideTopLeft.y(); + coordinates[12] = insideTopRight.x(); + coordinates[13] = insideTopRight.y(); + coordinates[14] = insideBottomRight.x(); + coordinates[15] = insideBottomRight.y(); + + vgAppendPathData(path, 9, squaredBorderCommands, coordinates.constData()); + } } else if (radius < qMax(borderWidth, borderHeight)){ // rounded outside, squared inside // Create command list diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h index 0d5283773f..e8d25c94f8 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalrectanglenode.h @@ -42,6 +42,7 @@ #include #include "qsgopenvgrenderable.h" +#include "qopenvgoffscreensurface.h" #include @@ -64,6 +65,7 @@ public: void render() override; void setOpacity(float opacity) override; + void setTransform(const QOpenVGMatrix &transform) override; private: void createVGResources(); @@ -89,6 +91,8 @@ private: VGPath m_borderPath; VGPaint m_rectanglePaint; VGPaint m_borderPaint; + + QOpenVGOffscreenSurface *m_offscreenSurface = nullptr; }; QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp index 03a82ca4ee..cafd0d4e1e 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp @@ -53,12 +53,9 @@ QSGOpenVGLayer::QSGOpenVGLayer(QSGRenderContext *renderContext) , m_grab(true) , m_recursive(false) , m_dirtyTexture(true) - , m_image(0) - , m_renderTarget(0) - , m_layerContext(0) + , m_offscreenSurface(nullptr) { m_context = static_cast(renderContext); - m_vgContext = m_context->vgContext(); } QSGOpenVGLayer::~QSGOpenVGLayer() @@ -68,15 +65,16 @@ QSGOpenVGLayer::~QSGOpenVGLayer() int QSGOpenVGLayer::textureId() const { - return static_cast(m_image); + if (m_offscreenSurface) + return static_cast(m_offscreenSurface->image()); + else + return 0; } QSize QSGOpenVGLayer::textureSize() const { - if (m_image != 0) { - VGint imageWidth = vgGetParameteri(m_image, VG_IMAGE_WIDTH); - VGint imageHeight = vgGetParameteri(m_image, VG_IMAGE_HEIGHT); - return QSize(imageWidth, imageHeight); + if (m_offscreenSurface) { + return m_offscreenSurface->size(); } return QSize(); @@ -84,42 +82,7 @@ QSize QSGOpenVGLayer::textureSize() const bool QSGOpenVGLayer::hasAlphaChannel() const { - VGImageFormat format = static_cast(vgGetParameteri(m_image, VG_IMAGE_FORMAT)); - - switch (format) { - case VG_sRGBA_8888: - case VG_sRGBA_8888_PRE: - case VG_sRGBA_5551: - case VG_sRGBA_4444: - case VG_lRGBA_8888: - case VG_lRGBA_8888_PRE: - case VG_A_8: - case VG_A_1: - case VG_A_4: - case VG_sARGB_8888: - case VG_sARGB_8888_PRE: - case VG_sARGB_1555: - case VG_sARGB_4444: - case VG_lARGB_8888: - case VG_lARGB_8888_PRE: - case VG_sBGRA_8888: - case VG_sBGRA_8888_PRE: - case VG_sBGRA_5551: - case VG_sBGRA_4444: - case VG_lBGRA_8888: - case VG_lBGRA_8888_PRE: - case VG_sABGR_8888: - case VG_sABGR_8888_PRE: - case VG_sABGR_1555: - case VG_sABGR_4444: - case VG_lABGR_8888: - case VG_lABGR_8888_PRE: - return true; - break; - default: - break; - } - return false; + return true; } bool QSGOpenVGLayer::hasMipmaps() const @@ -149,8 +112,8 @@ void QSGOpenVGLayer::setItem(QSGNode *item) m_item = item; if (m_live && !m_item) { - vgDestroyImage(m_image); - m_image = 0; + delete m_offscreenSurface; + m_offscreenSurface = nullptr; } markDirtyTexture(); @@ -171,8 +134,8 @@ void QSGOpenVGLayer::setSize(const QSize &size) m_size = size; if (m_live && m_size.isNull()) { - vgDestroyImage(m_image); - m_image = 0; + delete m_offscreenSurface; + m_offscreenSurface = nullptr; } markDirtyTexture(); @@ -201,8 +164,8 @@ void QSGOpenVGLayer::setLive(bool live) m_live = live; if (m_live && (!m_item || m_size.isNull())) { - vgDestroyImage(m_image); - m_image = 0; + delete m_offscreenSurface; + m_offscreenSurface = nullptr; } markDirtyTexture(); @@ -254,15 +217,17 @@ void QSGOpenVGLayer::markDirtyTexture() void QSGOpenVGLayer::invalidated() { + delete m_offscreenSurface; delete m_renderer; - m_renderer = 0; + m_renderer = nullptr; + m_offscreenSurface = nullptr; } void QSGOpenVGLayer::grab() { if (!m_item || m_size.isNull()) { - vgDestroyImage(m_image); - m_image = 0; + delete m_offscreenSurface; + m_offscreenSurface = nullptr; m_dirtyTexture = false; return; } @@ -279,47 +244,12 @@ void QSGOpenVGLayer::grab() m_renderer->setDevicePixelRatio(m_device_pixel_ratio); m_renderer->setRootNode(static_cast(root)); - if (m_image == 0 || m_imageSize != m_size ) { - if (m_image != 0) - vgDestroyImage(m_image); - - m_image = vgCreateImage(VG_lARGB_8888_PRE, m_size.width(), m_size.height(), VG_IMAGE_QUALITY_BETTER); - m_imageSize = m_size; - - //Destroy old RenderTarget - if (m_renderTarget != 0) - eglDestroySurface(m_vgContext->eglDisplay(), m_renderTarget); - - const EGLint configAttribs[] = { - EGL_CONFORMANT, EGL_OPENVG_BIT, - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_ALPHA_MASK_SIZE, 8, - EGL_NONE - }; - - EGLConfig pbufferConfig; - EGLint numConfig; - eglChooseConfig(m_vgContext->eglDisplay(), configAttribs, &pbufferConfig, 1, &numConfig); - - if (m_layerContext == 0) { - // Create new context - m_layerContext = eglCreateContext(m_vgContext->eglDisplay(), pbufferConfig, m_vgContext->eglContext(), 0); - } - - m_renderTarget = eglCreatePbufferFromClientBuffer(m_vgContext->eglDisplay(), - EGL_OPENVG_IMAGE, - (EGLClientBuffer)m_image, - pbufferConfig, - 0); - } - if (m_renderTarget == EGL_NO_SURFACE) { - qDebug() << "invalid renderTarget!"; - return; + if (m_offscreenSurface == nullptr || m_offscreenSurface->size() != m_size ) { + if (m_offscreenSurface != nullptr) + delete m_offscreenSurface; + + m_offscreenSurface = new QOpenVGOffscreenSurface(m_size); } // Render texture. @@ -337,7 +267,7 @@ void QSGOpenVGLayer::grab() m_renderer->setProjectionMatrixToRect(mirrored); m_renderer->setClearColor(Qt::transparent); - eglMakeCurrent(m_vgContext->eglDisplay(), m_renderTarget, m_renderTarget, m_layerContext); + m_offscreenSurface->makeCurrent(); // Before Rendering setup context for adjusting to Qt Coordinates to PixelBuffer // Should already be inverted by default @@ -346,10 +276,8 @@ void QSGOpenVGLayer::grab() m_renderer->renderScene(); - eglSwapBuffers(m_vgContext->eglDisplay(), m_renderTarget); - - // make the default surface current again - m_vgContext->makeCurrent(); + // Make the previous surface and context active again + m_offscreenSurface->doneCurrent(); root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update. diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.h b/src/plugins/scenegraph/openvg/qsgopenvglayer.h index ee9984b9d9..760a22f0bc 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvglayer.h +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.h @@ -44,6 +44,7 @@ #include #include "qopenvgcontext_p.h" +#include "qopenvgoffscreensurface.h" QT_BEGIN_NAMESPACE @@ -103,11 +104,7 @@ private: bool m_recursive; bool m_dirtyTexture; - QOpenVGContext *m_vgContext; - VGImage m_image; - QSize m_imageSize; - EGLSurface m_renderTarget; - EGLContext m_layerContext; + QOpenVGOffscreenSurface *m_offscreenSurface; }; QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp index fc9f5eb57c..8aa179f705 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.cpp @@ -93,12 +93,11 @@ bool QSGOpenVGNodeVisitor::visit(QSGClipNode *node) // Render clip node geometry to mask vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); + vgLoadIdentity(); VGPath clipPath = generateClipPath(node->clipRect()); vgRenderToMask(clipPath, VG_FILL_PATH, maskOperation); - auto clipState = new ClipState(clipPath, m_transformStack.top()); - m_clipStack.push(clipState); + m_clipStack.push(clipPath); return true; } @@ -107,29 +106,23 @@ void QSGOpenVGNodeVisitor::endVisit(QSGClipNode *) { // Remove clip node geometry from mask auto clipState = m_clipStack.pop(); - vgDestroyPath(clipState->path); + vgDestroyPath(clipState); if (m_clipStack.count() == 0) { vgSeti(VG_MASKING, VG_FALSE); } else { // Recreate the mask vgMask(0,VG_FILL_MASK, 0, 0, VG_MAXINT, VG_MAXINT); - for (auto state : m_clipStack) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - vgLoadMatrix(state->transform.constData()); - vgRenderToMask(state->path, VG_FILL_PATH, VG_INTERSECT_MASK); + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + for (auto path : qAsConst(m_clipStack)) { + vgRenderToMask(path, VG_FILL_PATH, VG_INTERSECT_MASK); } } - - delete clipState; } bool QSGOpenVGNodeVisitor::visit(QSGGeometryNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); - vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); if (QSGSimpleRectNode *rectNode = dynamic_cast(node)) { // TODO: Try and render the QSGSimpleRectNode Q_UNUSED(rectNode) @@ -169,8 +162,6 @@ void QSGOpenVGNodeVisitor::endVisit(QSGOpacityNode *) bool QSGOpenVGNodeVisitor::visit(QSGInternalImageNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); renderRenderableNode(static_cast(node)); return true; } @@ -181,8 +172,6 @@ void QSGOpenVGNodeVisitor::endVisit(QSGInternalImageNode *) bool QSGOpenVGNodeVisitor::visit(QSGPainterNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); renderRenderableNode(static_cast(node)); return true; } @@ -193,8 +182,6 @@ void QSGOpenVGNodeVisitor::endVisit(QSGPainterNode *) bool QSGOpenVGNodeVisitor::visit(QSGInternalRectangleNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); renderRenderableNode(static_cast(node)); return true; } @@ -205,8 +192,6 @@ void QSGOpenVGNodeVisitor::endVisit(QSGInternalRectangleNode *) bool QSGOpenVGNodeVisitor::visit(QSGGlyphNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); renderRenderableNode(static_cast(node)); return true; } @@ -226,8 +211,6 @@ void QSGOpenVGNodeVisitor::endVisit(QSGRootNode *) bool QSGOpenVGNodeVisitor::visit(QSGSpriteNode *node) { - vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); - vgLoadMatrix(m_transformStack.top().constData()); renderRenderableNode(static_cast(node)); return true; } @@ -253,19 +236,28 @@ VGPath QSGOpenVGNodeVisitor::generateClipPath(const QRectF &rect) const // Create command list static const VGubyte rectCommands[] = { VG_MOVE_TO_ABS, - VG_HLINE_TO_REL, - VG_VLINE_TO_REL, - VG_HLINE_TO_REL, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, VG_CLOSE_PATH }; + const QOpenVGMatrix &transform = m_transformStack.top(); + // Create command data - QVector coordinates(5); - coordinates[0] = rect.x(); - coordinates[1] = rect.y(); - coordinates[2] = rect.width(); - coordinates[3] = rect.height(); - coordinates[4] = -rect.width(); + QVector coordinates(8); + const QPointF topLeft = transform.map(rect.topLeft()); + const QPointF topRight = transform.map(rect.topRight()); + const QPointF bottomLeft = transform.map(rect.bottomLeft()); + const QPointF bottomRight = transform.map(rect.bottomRight()); + coordinates[0] = bottomLeft.x(); + coordinates[1] = bottomLeft.y(); + coordinates[2] = bottomRight.x(); + coordinates[3] = bottomRight.y(); + coordinates[4] = topRight.x(); + coordinates[5] = topRight.y(); + coordinates[6] = topLeft.x(); + coordinates[7] = topLeft.y(); vgAppendPathData(clipPath, 5, rectCommands, coordinates.constData()); return clipPath; @@ -275,7 +267,7 @@ void QSGOpenVGNodeVisitor::renderRenderableNode(QSGOpenVGRenderable *node) { if (!node) return; - + node->setTransform(m_transformStack.top()); node->setOpacity(m_opacityState.top()); node->render(); } diff --git a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h index 3105f2076d..4805d63024 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h +++ b/src/plugins/scenegraph/openvg/qsgopenvgnodevisitor.h @@ -79,24 +79,12 @@ public: void endVisit(QSGRenderNode *) override; private: - struct ClipState { - ClipState(VGPath p, QOpenVGMatrix t) - { - path = p; - transform = t; - } - - VGPath path; - QOpenVGMatrix transform; - }; - VGPath generateClipPath(const QRectF &rect) const; void renderRenderableNode(QSGOpenVGRenderable *node); - QStack m_transformStack; QStack m_opacityState; - QStack m_clipStack; + QStack m_clipStack; }; QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp index c09ca6a47e..fb68ebf2bc 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgpainternode.cpp @@ -193,6 +193,10 @@ void QSGOpenVGPainterNode::render() else vgSeti(VG_IMAGE_QUALITY, VG_IMAGE_QUALITY_NONANTIALIASED); + // Set Transform + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + vgDrawImage(static_cast(m_texture->textureId())); } diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp index f5890210a9..1afc5ea7ca 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.cpp @@ -73,10 +73,33 @@ void QSGOpenVGRectangleNode::setColor(const QColor &color) markDirty(DirtyMaterial); } +void QSGOpenVGRectangleNode::setTransform(const QOpenVGMatrix &transform) +{ + // if there transform matrix is not affine, regenerate the path + if (transform.isAffine()) + m_pathDirty = true; + markDirty(DirtyGeometry); + + QSGOpenVGRenderable::setTransform(transform); +} + void QSGOpenVGRectangleNode::render() { + // Set Transform + if (transform().isAffine()) { + // Use current transform matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + } else { + // map the path's to handle the perspective matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); + vgLoadIdentity(); + } + if (m_pathDirty) { vgClearPath(m_rectPath, VG_PATH_CAPABILITY_APPEND_TO); + + if (transform().isAffine()) { // Create command list static const VGubyte rectCommands[] = { VG_MOVE_TO_ABS, @@ -95,6 +118,34 @@ void QSGOpenVGRectangleNode::render() coordinates[4] = -m_rect.width(); vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData()); + + } else { + // Pre-transform path + static const VGubyte rectCommands[] = { + VG_MOVE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_LINE_TO_ABS, + VG_CLOSE_PATH + }; + + QVector coordinates(8); + const QPointF topLeft = transform().map(m_rect.topLeft()); + const QPointF topRight = transform().map(m_rect.topRight()); + const QPointF bottomLeft = transform().map(m_rect.bottomLeft()); + const QPointF bottomRight = transform().map(m_rect.bottomRight()); + coordinates[0] = bottomLeft.x(); + coordinates[1] = bottomLeft.y(); + coordinates[2] = bottomRight.x(); + coordinates[3] = bottomRight.y(); + coordinates[4] = topRight.x(); + coordinates[5] = topRight.y(); + coordinates[6] = topLeft.x(); + coordinates[7] = topLeft.y(); + + vgAppendPathData(m_rectPath, 5, rectCommands, coordinates.constData()); + } + m_pathDirty = false; } @@ -155,6 +206,10 @@ void QSGOpenVGImageNode::render() vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); } + // Set Transform + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + VGImage image = static_cast(m_texture->textureId()); //Apply the TextureCoordinateTransform Flag @@ -251,6 +306,10 @@ void QSGOpenVGNinePatchNode::render() vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); } + // Set Transform + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + VGImage image = static_cast(m_texture->textureId()); //Draw borderImage diff --git a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h index 70b087e9fc..34c8e50615 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h +++ b/src/plugins/scenegraph/openvg/qsgopenvgpublicnodes.h @@ -64,6 +64,8 @@ public: void setColor(const QColor &color) override; QColor color() const override { return m_color; } + void setTransform(const QOpenVGMatrix &transform) override; + void render() override; private: diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp index 0856acfc9a..97d0be99c8 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.cpp @@ -74,4 +74,14 @@ VGPaint QSGOpenVGRenderable::opacityPaint() const return m_opacityPaint; } +void QSGOpenVGRenderable::setTransform(const QOpenVGMatrix &transform) +{ + m_transform = transform; +} + +const QOpenVGMatrix &QSGOpenVGRenderable::transform() const +{ + return m_transform; +} + QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h index 7a09f2afbe..a544ae743e 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderable.h @@ -44,6 +44,8 @@ #include +#include "qopenvgmatrix.h" + QT_BEGIN_NAMESPACE class QSGOpenVGRenderable @@ -58,9 +60,13 @@ public: float opacity() const; VGPaint opacityPaint() const; + virtual void setTransform(const QOpenVGMatrix &transform); + const QOpenVGMatrix &transform() const; + private: float m_opacity; VGPaint m_opacityPaint; + QOpenVGMatrix m_transform; }; diff --git a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp index 9bce12c83f..fb24df7471 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgspritenode.cpp @@ -138,6 +138,10 @@ void QSGOpenVGSpriteNode::render() vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL); } + // Set Image Matrix + vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); + vgLoadMatrix(transform().constData()); + if (sourceRect != targetRect) { // Scale float scaleX = targetRect.width() / sourceRect.width(); -- cgit v1.2.3 From 4cdeeea8e2fd90b984c49edeb3765d2079487d79 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Fri, 2 Dec 2016 11:19:48 +0100 Subject: OpenVG: Use QRawFont qHash function in font cache A qHash function was added for QRawFont, so use that instead of our own. Change-Id: Iad8deb8a0e2a727039ec752e38e42cef2127735c Reviewed-by: Laszlo Agocs --- .../scenegraph/openvg/qsgopenvgfontglyphcache.cpp | 27 ++-------------------- .../scenegraph/openvg/qsgopenvgfontglyphcache.h | 4 +--- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp index 1ed54f7b6a..dd630c776f 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.cpp @@ -56,37 +56,14 @@ QSGOpenVGFontGlyphCacheManager::~QSGOpenVGFontGlyphCacheManager() QSGOpenVGFontGlyphCache *QSGOpenVGFontGlyphCacheManager::cache(const QRawFont &font) { - return m_caches.value(fontKey(font), nullptr); + return m_caches.value(font, nullptr); } void QSGOpenVGFontGlyphCacheManager::insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache) { - m_caches.insert(fontKey(font), cache); + m_caches.insert(font, cache); } -QString QSGOpenVGFontGlyphCacheManager::fontKey(const QRawFont &font) -{ - QFontEngine *fe = QRawFontPrivate::get(font)->fontEngine; - if (!fe->faceId().filename.isEmpty()) { - QByteArray keyName = fe->faceId().filename; - if (font.style() != QFont::StyleNormal) - keyName += QByteArray(" I"); - if (font.weight() != QFont::Normal) - keyName += ' ' + QByteArray::number(font.weight()); - keyName += " " + QString::number(font.pixelSize()); - keyName += QByteArray(" DF"); - return QString::fromUtf8(keyName); - } else { - return QString::fromLatin1("%1_%2_%3_%4_%5") - .arg(font.familyName()) - .arg(font.styleName()) - .arg(font.weight()) - .arg(font.style()) - .arg(font.pixelSize()); - } -} - - QSGOpenVGFontGlyphCache::QSGOpenVGFontGlyphCache(QSGOpenVGFontGlyphCacheManager *manager, const QRawFont &font) : m_manager(manager) { diff --git a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h index a4a51cd2b6..a88d28b0fe 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h +++ b/src/plugins/scenegraph/openvg/qsgopenvgfontglyphcache.h @@ -59,9 +59,7 @@ public: void insertCache(const QRawFont &font, QSGOpenVGFontGlyphCache *cache); private: - static QString fontKey(const QRawFont &font); - - QHash m_caches; + QHash m_caches; }; class QSGOpenVGFontGlyphCache -- cgit v1.2.3 From 9fbc5aa8866bbc19cc0db9f5f247276f36f3e283 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Wed, 7 Dec 2016 14:14:31 +0100 Subject: OpenVG: Fix Recursive Layers OpenVG also needed to ping-pong between two offscreen surfaces like the OpenGL renderer. Change-Id: I41f671d98d361eb114be5c00ebfe62710a971aaa Reviewed-by: Laszlo Agocs --- .../scenegraph/openvg/qopenvgoffscreensurface.cpp | 12 ++++- .../scenegraph/openvg/qopenvgoffscreensurface.h | 2 + .../openvg/qsgopenvginternalimagenode.cpp | 3 ++ src/plugins/scenegraph/openvg/qsgopenvglayer.cpp | 51 +++++++++++++++++----- src/plugins/scenegraph/openvg/qsgopenvglayer.h | 1 + 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp index 3a4643ab5a..80af227fb4 100644 --- a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp +++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.cpp @@ -39,6 +39,9 @@ #include "qopenvgoffscreensurface.h" +#include +#include + QT_BEGIN_NAMESPACE QOpenVGOffscreenSurface::QOpenVGOffscreenSurface(const QSize &size) @@ -79,6 +82,7 @@ QOpenVGOffscreenSurface::~QOpenVGOffscreenSurface() { vgDestroyImage(m_image); eglDestroySurface(m_display, m_renderTarget); + eglDestroyContext(m_display, m_context); } void QOpenVGOffscreenSurface::makeCurrent() @@ -98,7 +102,6 @@ void QOpenVGOffscreenSurface::doneCurrent() EGLContext currentContext = eglGetCurrentContext(); if (m_context == currentContext) { eglMakeCurrent(m_display, m_previousDrawSurface, m_previousReadSurface, m_previousContext); - m_context = EGL_NO_CONTEXT; m_previousContext = EGL_NO_CONTEXT; m_previousReadSurface = EGL_NO_SURFACE; m_previousDrawSurface = EGL_NO_SURFACE; @@ -110,4 +113,11 @@ void QOpenVGOffscreenSurface::swapBuffers() eglSwapBuffers(m_display, m_renderTarget); } +QImage QOpenVGOffscreenSurface::readbackQImage() +{ + QImage readbackImage(m_size, QImage::Format_ARGB32_Premultiplied); + vgGetImageSubData(m_image, readbackImage.bits(), readbackImage.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, m_size.width(), m_size.height()); + return readbackImage; +} + QT_END_NAMESPACE diff --git a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h index 833c9669bf..746e4de1cd 100644 --- a/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h +++ b/src/plugins/scenegraph/openvg/qopenvgoffscreensurface.h @@ -57,6 +57,8 @@ public: VGImage image() { return m_image; } QSize size() const { return m_size; } + QImage readbackQImage(); + private: VGImage m_image; QSize m_size; diff --git a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp index c9545d5e9a..3dd1f9133c 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvginternalimagenode.cpp @@ -79,6 +79,9 @@ void QSGOpenVGInternalImageNode::render() VGImage image = static_cast(m_texture->textureId()); QSize textureSize = m_texture->textureSize(); + if (image == VG_INVALID_HANDLE || !textureSize.isValid()) + return; + // If Mirrored if (m_mirror) { diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp index cafd0d4e1e..047539d431 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.cpp @@ -54,6 +54,7 @@ QSGOpenVGLayer::QSGOpenVGLayer(QSGRenderContext *renderContext) , m_recursive(false) , m_dirtyTexture(true) , m_offscreenSurface(nullptr) + , m_secondaryOffscreenSurface(nullptr) { m_context = static_cast(renderContext); } @@ -113,7 +114,9 @@ void QSGOpenVGLayer::setItem(QSGNode *item) if (m_live && !m_item) { delete m_offscreenSurface; + delete m_secondaryOffscreenSurface; m_offscreenSurface = nullptr; + m_secondaryOffscreenSurface = nullptr; } markDirtyTexture(); @@ -135,7 +138,9 @@ void QSGOpenVGLayer::setSize(const QSize &size) if (m_live && m_size.isNull()) { delete m_offscreenSurface; + delete m_secondaryOffscreenSurface; m_offscreenSurface = nullptr; + m_secondaryOffscreenSurface = nullptr; } markDirtyTexture(); @@ -153,8 +158,7 @@ void QSGOpenVGLayer::scheduleUpdate() QImage QSGOpenVGLayer::toImage() const { - // XXX - return QImage(); + return m_offscreenSurface->readbackQImage(); } void QSGOpenVGLayer::setLive(bool live) @@ -165,7 +169,9 @@ void QSGOpenVGLayer::setLive(bool live) if (m_live && (!m_item || m_size.isNull())) { delete m_offscreenSurface; + delete m_secondaryOffscreenSurface; m_offscreenSurface = nullptr; + m_secondaryOffscreenSurface = nullptr; } markDirtyTexture(); @@ -218,16 +224,20 @@ void QSGOpenVGLayer::markDirtyTexture() void QSGOpenVGLayer::invalidated() { delete m_offscreenSurface; + delete m_secondaryOffscreenSurface; delete m_renderer; m_renderer = nullptr; m_offscreenSurface = nullptr; + m_secondaryOffscreenSurface = nullptr; } void QSGOpenVGLayer::grab() { if (!m_item || m_size.isNull()) { delete m_offscreenSurface; + delete m_secondaryOffscreenSurface; m_offscreenSurface = nullptr; + m_secondaryOffscreenSurface = nullptr; m_dirtyTexture = false; return; } @@ -244,14 +254,23 @@ void QSGOpenVGLayer::grab() m_renderer->setDevicePixelRatio(m_device_pixel_ratio); m_renderer->setRootNode(static_cast(root)); - + bool deleteOffscreenSurfaceLater = false; if (m_offscreenSurface == nullptr || m_offscreenSurface->size() != m_size ) { - if (m_offscreenSurface != nullptr) + if (m_recursive) { + deleteOffscreenSurfaceLater = true; + delete m_secondaryOffscreenSurface; + m_secondaryOffscreenSurface = new QOpenVGOffscreenSurface(m_size); + } else { delete m_offscreenSurface; - - m_offscreenSurface = new QOpenVGOffscreenSurface(m_size); + delete m_secondaryOffscreenSurface; + m_offscreenSurface = new QOpenVGOffscreenSurface(m_size); + m_secondaryOffscreenSurface = nullptr; + } } + if (m_recursive && !m_secondaryOffscreenSurface) + m_secondaryOffscreenSurface = new QOpenVGOffscreenSurface(m_size); + // Render texture. root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip and opacity update. m_renderer->nodeChanged(root, QSGNode::DirtyForceUpdate); // Force render list update. @@ -267,17 +286,25 @@ void QSGOpenVGLayer::grab() m_renderer->setProjectionMatrixToRect(mirrored); m_renderer->setClearColor(Qt::transparent); - m_offscreenSurface->makeCurrent(); - // Before Rendering setup context for adjusting to Qt Coordinates to PixelBuffer - // Should already be inverted by default - vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - vgLoadIdentity(); + if (m_recursive) + m_secondaryOffscreenSurface->makeCurrent(); + else + m_offscreenSurface->makeCurrent(); m_renderer->renderScene(); // Make the previous surface and context active again - m_offscreenSurface->doneCurrent(); + if (m_recursive) { + if (deleteOffscreenSurfaceLater) { + delete m_offscreenSurface; + m_offscreenSurface = new QOpenVGOffscreenSurface(m_size); + } + m_secondaryOffscreenSurface->doneCurrent(); + qSwap(m_offscreenSurface, m_secondaryOffscreenSurface); + } else { + m_offscreenSurface->doneCurrent(); + } root->markDirty(QSGNode::DirtyForceUpdate); // Force matrix, clip, opacity and render list update. diff --git a/src/plugins/scenegraph/openvg/qsgopenvglayer.h b/src/plugins/scenegraph/openvg/qsgopenvglayer.h index 760a22f0bc..2af0bfb40f 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvglayer.h +++ b/src/plugins/scenegraph/openvg/qsgopenvglayer.h @@ -105,6 +105,7 @@ private: bool m_dirtyTexture; QOpenVGOffscreenSurface *m_offscreenSurface; + QOpenVGOffscreenSurface *m_secondaryOffscreenSurface; }; QT_END_NAMESPACE -- cgit v1.2.3 From 7aaebe557476c088d339f1b4b114a671885c4ea8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 17 Nov 2016 15:18:17 +0100 Subject: TestCase: add createTemporaryObject(), createTemporaryQmlObject() A typical pattern with QML tests is to dynamically create an item and then destroy it at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = Qt.createQmlObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... item.destroy(); } } The problem with this pattern is that any failures in the test function will cause the call to item.destroy() to be skipped, leaving the item hanging around in the scene until the test case has finished. This can result in interference with future tests; for example, by blocking input events or producing unrelated debug output that makes it difficult to follow the code's execution. By calling e.g. createTemporaryQmlObject() instead, the object is guaranteed to be destroyed at the end of the test function: TestCase { id: testCase name: "MyTest" when: windowShown function test_click() { var item = createTemporaryObject("import QtQuick 2.0; Item {}", testCase); verify(item); // Test item... // Don't need to worry about destroying "item" here. } } [ChangeLog][TestCase] Added createTemporaryObject() and createTemporaryQmlObject() functions that can be used to ensure that dynamically created objects are destroyed at the end of each test function. Change-Id: I483342052462aa86464c86bf2082892712dceb58 Task-number: QTBUG-56361 Reviewed-by: Shawn Rutledge Reviewed-by: Michael Brasser --- src/imports/testlib/TestCase.qml | 160 +++++++++++++++++++++ src/imports/testlib/qmldir | 1 + .../selftests/tst_createTemporaryObject.qml | 113 +++++++++++++++ 3 files changed, 274 insertions(+) create mode 100644 tests/auto/qmltest/selftests/tst_createTemporaryObject.qml diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index a874fd4fe2..ad7533c550 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -206,6 +206,59 @@ import Qt.test.qtestroot 1.0 will fail. Use the \l when and windowShown properties to track when the main window has been shown. + \section1 Managing Dynamically Created Test Objects + + A typical pattern with QML tests is to + \l {Dynamic QML Object Creation from JavaScript}{dynamically create} + an item and then destroy it at the end of the test function: + + \code + TestCase { + id: testCase + name: "MyTest" + when: windowShown + + function test_click() { + var item = Qt.createQmlObject("import QtQuick 2.0; Item {}", testCase); + verify(item); + + // Test item... + + item.destroy(); + } + } + \endcode + + The problem with this pattern is that any failures in the test function + will cause the call to \c item.destroy() to be skipped, leaving the item + hanging around in the scene until the test case has finished. This can + result in interference with future tests; for example, by blocking input + events or producing unrelated debug output that makes it difficult to + follow the code's execution. + + By calling \l createTemporaryQmlObject() instead, the object is guaranteed + to be destroyed at the end of the test function: + + \code + TestCase { + id: testCase + name: "MyTest" + when: windowShown + + function test_click() { + var item = createTemporaryQmlObject("import QtQuick 2.0; Item {}", testCase); + verify(item); + + // Test item... + + // Don't need to worry about destroying "item" here. + } + } + \endcode + + For objects that are created via the \l {Component::}{createObject()} function + of \l Component, the \l createTemporaryObject() function can be used. + \sa {QtTest::SignalSpy}{SignalSpy}, {Qt Quick Test Reference Documentation} */ @@ -358,6 +411,8 @@ Item { /*! \internal */ property var qtest_events: qtest_events_normal TestEvent { id: qtest_events_normal } + /*! \internal */ + property var qtest_temporaryObjects: [] /*! \qmlmethod TestCase::fail(message = "") @@ -461,6 +516,110 @@ Item { throw new Error("QtQuickTest::fail") } + /*! + \since 5.9 + \qmlmethod object TestCase::createTemporaryQmlObject(string qml, object parent, string filePath) + + This function dynamically creates a QML object from the given \a qml + string with the specified \a parent. The returned object will be + destroyed (if it was not already) after \l cleanup() has finished + executing, meaning that objects created with this function are + guaranteed to be destroyed after each test, regardless of whether or + not the tests fail. + + If there was an error while creating the object, \c null will be + returned. + + If \a filePath is specified, it will be used for error reporting for + the created object. + + This function calls + \l {QtQml::Qt::createQmlObject()}{Qt.createQmlObject()} internally. + + \sa {Managing Dynamically Created Test Objects} + */ + function createTemporaryQmlObject(qml, parent, filePath) { + if (typeof qml !== "string") { + qtest_results.fail("First argument must be a string of QML; actual type is " + typeof qml, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + if (!parent || typeof parent !== "object") { + qtest_results.fail("Second argument must be a valid parent object; actual type is " + typeof parent, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + if (filePath !== undefined && typeof filePath !== "string") { + qtest_results.fail("Third argument must be a file path string; actual type is " + typeof filePath, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + var object = Qt.createQmlObject(qml, parent, filePath); + qtest_temporaryObjects.push(object); + return object; + } + + /*! + \since 5.9 + \qmlmethod object TestCase::createTemporaryObject(Component component, object parent, object properties) + + This function dynamically creates a QML object from the given + \a component with the specified \a parent and \a properties. + The returned object will be destroyed (if it was not already) after + \l cleanup() has finished executing, meaning that objects created with + this function are guaranteed to be destroyed after each test, + regardless of whether or not the tests fail. + + If there was an error while creating the object, \c null will be + returned. + + This function calls + \l {QtQml::Component::createObject()}{component.createObject()} + internally. + + \sa {Managing Dynamically Created Test Objects} + */ + function createTemporaryObject(component, parent, properties) { + if (typeof component !== "object") { + qtest_results.fail("First argument must be a Component; actual type is " + typeof component, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + if (!parent && parent !== null) { + qtest_results.fail("Second argument must be a parent object or null; actual type is " + typeof parent, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + if (properties && typeof properties !== "object") { + qtest_results.fail("Third argument must be an object; actual type is " + typeof properties, + util.callerFile(), util.callerLine()); + throw new Error("QtQuickTest::fail"); + } + + var object = component.createObject(parent, properties ? properties : ({})); + qtest_temporaryObjects.push(object); + return object; + } + + /*! + \internal + + Destroys all temporary objects that still exist. + */ + function qtest_destroyTemporaryObjects() { + for (var i = 0; i < qtest_temporaryObjects.length; ++i) { + var temporaryObject = qtest_temporaryObjects[i]; + if (temporaryObject) + temporaryObject.destroy(); + } + qtest_temporaryObjects = []; + } + /*! \internal */ // Determine what is o. // Discussions and reference: http://philrathe.com/articles/equiv @@ -1492,6 +1651,7 @@ Item { qtest_runInternal(prop, arg) qtest_results.finishTestData() qtest_runInternal("cleanup") + qtest_destroyTemporaryObjects() qtest_results.finishTestDataCleanup() // wait(0) will call processEvents() so objects marked for deletion // in the test function will be deleted. diff --git a/src/imports/testlib/qmldir b/src/imports/testlib/qmldir index 9da8ebb4be..e5757f6a88 100644 --- a/src/imports/testlib/qmldir +++ b/src/imports/testlib/qmldir @@ -3,4 +3,5 @@ plugin qmltestplugin classname QTestQmlModule typeinfo plugins.qmltypes TestCase 1.0 TestCase.qml +TestCase 1.2 TestCase.qml SignalSpy 1.0 SignalSpy.qml diff --git a/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml new file mode 100644 index 0000000000..c4912c7388 --- /dev/null +++ b/tests/auto/qmltest/selftests/tst_createTemporaryObject.qml @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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.8 +import QtQuick.Window 2.2 +import QtTest 1.2 + +TestCase { + id: testCase + name: "tst_createTemporaryObject" + width: 100 + height: 100 + when: windowShown + + property var createdObjectNames: [] + + function verifyNoChildren() { + for (var i = 0; i < createdObjectNames.length; ++i) { + verify(!findChild(testCase, createdObjectNames[i])); + } + } + + function init() { + // The items are destroyed after cleanup(), so we check here after every test, + // and once for the last test in cleanupTestCase(). + verifyNoChildren(); + } + + function cleanupTestCase() { + verifyNoChildren(); + } + + function test_fromQml_data() { + return [ + { tag: "QtObject", qml: "import QtQml 2.0; QtObject {}" }, + { tag: "Item", qml: "import QtQuick 2.0; Item {}" }, + ]; + } + + function test_fromQml(data) { + var object = createTemporaryQmlObject(data.qml, testCase); + verify(object); + + object.objectName = data.tag + "FromQml"; + compare(findChild(testCase, object.objectName), object); + + createdObjectNames.push(object.objectName); + } + + Component { + id: objectComponent + + QtObject {} + } + + Component { + id: itemComponent + + Item {} + } + + Component { + id: windowComponent + + Window {} + } + + function test_fromComponent_data() { + return [ + { tag: "QtObject", component: objectComponent }, + { tag: "Item", component: itemComponent }, + { tag: "Window", component: windowComponent }, + ]; + } + + function test_fromComponent(data) { + var object = createTemporaryObject(data.component, testCase); + verify(object); + + object.objectName = data.tag + "FromComponent"; + compare(findChild(testCase, object.objectName), object); + + if (object.hasOwnProperty("contentItem")) + object.contentItem.objectName = "WindowContentItemFromComponent"; + + createdObjectNames.push(object.objectName); + } +} -- cgit v1.2.3