Commit Graph

493 Commits

Author SHA1 Message Date
Fabian Kosmale df6d816fe3 QQmlPropertyCache: Avoid costly string comparison
The qqmlecmacsript required changes, because the call to id makes the
type now known to the QML engine.

Change-Id: I73aed804ae8769c71676b44d8450e1dabf5baa6d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-18 16:37:01 +01:00
Ulf Hermann 748411fa64 Store a QV4::ReturnedValue in QJSValue
Being careful, we can now save primitive values inline. We use the heap
pointer of QV4::Value as either QString* or QV4::Value* for complex
types. We cannot store persistent managed QV4::Value without the double
indirection as those need to be allocated in a special place.

The generic QVariant case is not supported anymore. The only place where
it was actually needed were the stream operators for QJSValue. Those
were fundamentally broken:

* A managed QJSValue saved and loaded from a stream was converted to a
  QVariant-type QJSValue
* QVariant-type QJSValues were not callable, could not be objects or
  arrays, or any of the special types.
* Cyclic references were forcibly broken when saving to a data stream.

In general the support for saving and loading of managed types to/from
a data stream was so abysmally bad that we don't lose much by dropping
it.

[ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a
QDataStream only primitive values or strings will be retained. Support
for objects and arrays was incomplete and unreliable already before. It
cannot work correctly as we don't necessarily have a JavaScript heap
when loading a QJSValue from a stream. Therefore, we don't have a proper
place to keep any managed values. Using QVariant to keep them instead is
a bad idea because QVariant cannot represent everything a QJSValue can
contain.

Fixes: QTBUG-75174
Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-18 16:35:02 +01:00
Ulf Hermann c5b48c735e Also support partly specified versions in JS .imports
Task-number: QTBUG-71278
Change-Id: Ie3167d44780a192b5010052eea5192eee8c21c32
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-03-18 11:00:31 +01:00
Fabian Kosmale f40e8aa17a Remove parts of sequence type test
The tests makes assumptions which simply don't hold anymore,
now that QProperty does automatic type registration, and
the engine supports magic conversions via QSequentialIterable.

Change-Id: I33e8eeca95757686e59da9db5ef5d92041364335
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-09 10:54:40 +01:00
Qt Forward Merge Bot d51d5ff3c1 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/compiler/qqmlirbuilder_p.h
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qmltyperegistrar/qmltypesclassdescription.cpp
	src/qmltyperegistrar/qmltypesclassdescription.h
	src/qmltyperegistrar/qmltypescreator.cpp
	src/quick/items/qquicktext_p.h
	src/quick/util/qquickvaluetypes_p.h

Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
2020-03-09 09:58:49 +01:00
Edward Welbourne 744246b112 Use Qt::SplitBehavior in preference to QString::SplitBehavior
The Qt version was added in 5.14 "for use as eventual replacement for
QString::SplitBehavior." Move another step cloaser to that goal.

Change-Id: I3214ad6ccaca9dfd4a026589cabeb40cbf4a6298
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-02 15:58:47 +01:00
Qt Forward Merge Bot 3e758800b4 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/imports/qtqml/plugin.cpp
	src/qml/qml/qqml.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmlmetatype_p.h
	src/qml/qml/qqmltypeloader.cpp
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquickitemsmodule.cpp
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
2020-02-17 10:21:59 +01:00
Qt Forward Merge Bot 7d86b35dc6 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	.qmake.conf
	src/qml/types/qqmlbind.cpp
	src/quick/items/qquicklistview.cpp
	tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp

Change-Id: Id6805c13256ad13d5651011e5dd09bba0ec02987
2020-02-06 08:41:57 +01:00
Fabian Kosmale a8bc011d45 QV4: Handle value tyes in sameValue algorithm
The sameValue(Zero) algorithm were implemented according to the
JavaScript specification; however QML has the concept of value types.
For those we need to check equality with the intrinsic isEqualTo method.
This aligns sameValue(Zero) with strict equality in its treatment of
value types.
This fixes Array.includes for value types

Fixes: QTBUG-81825
Change-Id: Idd3e09cbed94bca6ea44f5683610b87d184e432c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-02-04 12:46:48 +01:00
Fabian Kosmale ecdb4ed275 Enable conversion from QJSValues containing arrays to container types
We started to convert containers to QJSValues, so that we could use them
as JavaScript arrays. Unfortunately, this would then lead to a type missmatch
when those same values where to be stored in a property of the container
type. This commit fixes this by converting them back to the original
type.

Fixes: QTBUG-80916
Change-Id: I30a3b03e17c34b171d4a6881dfd7801c13e94d80
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-31 14:48:28 +01:00
Qt Forward Merge Bot 8a22c92b55 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/imports/folderlistmodel/plugin.cpp
	src/imports/layouts/plugin.cpp
	src/imports/localstorage/plugin.cpp
	src/imports/models/plugin.cpp
	src/imports/particles/plugin.cpp
	src/imports/qtqml/plugin.cpp
	src/imports/qtquick2/plugin.cpp
	src/imports/shapes/plugin.cpp
	src/imports/statemachine/plugin.cpp
	src/imports/testlib/main.cpp
	src/imports/wavefrontmesh/plugin.cpp
	src/imports/window/plugin.cpp
	src/imports/workerscript/plugin.cpp
	src/qml/jsruntime/qv4sequenceobject.cpp
	src/qml/qml/qqmlengine.cpp
	src/qmlmodels/qqmlmodelsmodule.cpp
	src/qmlmodels/qqmlmodelsmodule_p.h
	src/qmlworkerscript/qqmlworkerscriptmodule.cpp
	src/qmlworkerscript/qqmlworkerscriptmodule_p.h
	src/quick/items/qquickitemsmodule.cpp

Change-Id: I5f1fbc3d00e8f583d2c89afc5389de84d68633a7
2020-01-14 11:24:11 +01:00
Qt Forward Merge Bot ba10b0b9ed Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/particles/qquickitemparticle.cpp
	src/qmlmodels/qqmladaptormodel.cpp
	tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp

Change-Id: Ibd8fbb91da6893a09f4ffe61ad0b95d8149bbc87
2020-01-09 07:24:26 +00:00
Fabian Kosmale e72b032cc1 QV4MM: Fix crash caused by MarkStack overflow
MemoryManager::collectFromJSStack did push to the mark stack without
checking if there is actually still space available. To fix this, we now
drain the stack once we hit the limit.

The test case is a slightly modified version compared to the reported
one, removing one loop. This was required as our regular expression does
not throw an exception when there are too many capture groups. However,
to trigger the bug, looping was not actually necessary.

Change-Id: I4d00865f25a989c380f4f5b221f4068c80b71d2b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-01-07 10:20:30 +01:00
Qt Forward Merge Bot 1196b1ef6c Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/types/qqmlbind.cpp

Change-Id: Ib992d1a7ac6c1a96d39819be6f23955dc31b44b2
2019-12-12 10:06:06 +01:00
Qt Forward Merge Bot 8182a8044f Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/qml/common/qv4compileddata_p.h

Change-Id: I1150c8cd0161f0e22137d383013751394ae64e18
2019-12-09 12:22:24 +00:00
Ulf Hermann cc66dd33cc Compiler: Support >32k stack slots
Previously, the code generator would truncate the stack slots when
writing the compiled function, as that one only had a 16bit field for
them.

Also, add a debug-mode check for stack overflows to the interpreter.

Unfortunately, as it triggers a stack overflow, the test will not
reliably fail without this change.

Fixes: QTBUG-80511
Change-Id: I3019bb2de657ae4c3e1040db798a83533f854bff
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-12-05 10:02:11 +01:00
Lars Knoll 893100fba3 Fix build after QList->QVector changes in qtbase
Change-Id: I1575c247de26ba08fba349bf879ed3e017530975
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-31 10:44:44 +01:00
Qt Forward Merge Bot 66db74e53e Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: I1359574c7d89aaf3328958e2f667ba1e599ff7f1
2019-10-11 01:00:19 +02:00
Liang Qi aa057451b3 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/plugins/scenegraph/openvg/qsgopenvgcontext.cpp
	tests/auto/quick/qquickpathview/tst_qquickpathview.cpp

Change-Id: I117c8d62b21800329d1035021d312d9924f83a1b
2019-10-10 13:59:00 +02:00
Edward Welbourne 290dc2da70 Be more fussy about the MakeDay() calculation
The ES Date spec goes into minute detail about doing various
algorithms in the dumbest possible way (like InLeapYear() calling
DaysInYear(), rather than the other way round) but, in MakeDay(),
leaves the implementation to solve the problem of finding the start of
the first day of a specified month in a given year. So exercise the
freedom we have in that to be a little more robust; and actually check
we have met the conditions the spec requires, returning NaN (as
specified) if not.

Added tests for some denormal dates and date-times and for a date
mentioned in QTBUG-78996.

Task-number: QTBUG-78996
Change-Id: I8d9a841dd1f1d9995273a3de8f6f9130207c7c2b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2019-10-08 21:21:29 +02:00
Qt Forward Merge Bot 9c7121df15 Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
	src/imports/qtquick2/plugins.qmltypes
	src/quick/items/qquickitemsmodule.cpp

Change-Id: I841c65c9c131354788b4f3fcfe3d7ed27be316d5
2019-10-04 11:29:16 +02:00
Ulf Hermann 702249777f tst_qqmlecmascript: Don't leak created objects
The result from component.create() has to be deleted somewhere.

Change-Id: I23135cb639fc316641e399decc740d9f5d445a84
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-10-01 11:18:19 +02:00
Qt Forward Merge Bot cd9c5c2bf9 Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts:
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jsruntime/qv4vme_moth.cpp
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

Change-Id: Iec7cd27ddad0281bd3b7833fb6b252f66a6ae5d6
2019-09-17 09:58:09 +02:00
Ulf Hermann e38ab72a7c tst_qqmlecmascript: Cast pointer to unsigned for printing
Otherwise QString::number() will apparently extend "negative" values to 64bits
even if the actual type is only 32bits long.

Change-Id: Ibdecff2fe707616d2254b7e34e08247f0ff52489
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2019-09-12 15:44:54 +02:00
Qt Forward Merge Bot 7d96bae85e Merge remote-tracking branch 'origin/5.14' into 5.15
Change-Id: Icc46cb06ac1dbe7097d11bc0db5813eb39fbf758
2019-09-05 08:58:55 +02:00
Fabian Kosmale 45b1a3f979 Allow semicolon after property declaration
Most of the rules already had Semicolon at the end, however it was
missing for UiScriptStatement, list properties and UiObjectInitializer.

This change fixes the regression from 5.11.3 to 5.12.0, and keeps the
behavior consistent.

Fixes: QTBUG-77954
Change-Id: I45ef35fab399e3f971444b96d4a9ec6a99e29e09
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-09-03 11:14:24 +02:00
Fabian Kosmale 4ba86a9701 qqmljs.g: reduce number of conflicts
First, let the lexer create a T_FUNCTION_STAR token for "function *",
which makes the job of the parser significantly easier.

Then, by using GeneratorDeclaration instead of GeneratorExpression, we can
avoid the conflicts between UiObjectMember and PrimaryExpression

Change-Id: Ib08918e3977ed1a80cdea0948da80bf37886f7de
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-09-03 10:57:02 +02:00
Fabian Kosmale c0e0c755a1 Support top level generator functions
Extends grammar to support generator functions in QML components and
adjusts codegen accordingly

The corresponding test case must be blacklisted in tst_qmlmin, as qmlmin
cannot handle yield statements

Fixes: QTBUG-77096
Change-Id: I47d45dd56289cdf073b41932a585259d3052de04
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-23 16:37:41 +02:00
Jan Arve Sæther 3db15da8e1 Fix qqmlecmascript failures for Android
Some silly ignoreMessage failures on 32 bit systems..

QString::number((quint32)0xaabbccdd, 16) returns "0xaabbccdd"

while

QString::number((qint32)0xaabbccdd, 16) returns "0xffffffffaabbccdd"

We therefore change to use quintptr (which will follow the quint32
codepath).

Change-Id: I40530d8da83ee43862541f0e87684dc11ed07a53
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-19 13:38:38 +02:00
Ulf Hermann be600348ef Split qqmltypeloader{_p.h|.cpp} into a several files
No one can read this mess.

Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-07-11 09:42:52 +02:00
Qt Forward Merge Bot 07205972ca Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	.qmake.conf

Change-Id: I20ad6f8a260f387a3b73566a32c35a5772b401a5
2019-07-04 13:32:18 +02:00
Qt Forward Merge Bot 97aa001da9 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	.qmake.conf

Change-Id: Icd05d016de5b4cf9af5234cb47b5c3fd0f6a053e
2019-07-03 06:11:21 +00:00
Simon Hausmann cca5d1ec2f Fix bindings not being re-evaluated when changing context property
Commit 7cb6dce1f3 introduced an
optimization to remove bindings that after their initial evaluation had
no dependencies or errors (such as when accessing properties not set
yet). However when accessing a context property in a silent way -- using
typeof -- then no error state is set and the binding is removed. Any
later change of the context property results therefore in no binding
re-evaluation. This patch skips the optimization on bindings that are
associated with a context that has unresolved names. This fixes the
concrete bug at the expense of disabling further optimizations in the
context if other bindings access unresolved context properties. However
since context properties are discouraged anyway, this may be an
acceptable price to pay.

Change-Id: I95e120a4f71e8ebe0ec1fc44e8703c75f920dd28
Fixes: QTBUG-76796
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-07-01 16:45:36 +02:00
Qt Forward Merge Bot e6c6cc8fde Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/imports/imports.pro
	src/qml/qml/qqmlmetatype.cpp

Change-Id: I308436caf55402cb2246cb591c6ac8f83e1febf8
2019-07-01 10:29:06 +02:00
Qt Forward Merge Bot 63398defdb Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I59343fe228ca6b823b61577e5a0907e7381899c2
2019-06-28 13:28:10 +02:00
Ulf Hermann 5eceb1801e Fix thisObject when calling scope and context properties through lookups
Just like resolving the lookup initially, we need to set the base also
when hitting the cached lookup code path. The base is then used as this
object.

Fixes: QTBUG-76656
Change-Id: I6f6be05bc9875ddccc6e112e91176a0fa24a8fa1
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-06-26 15:48:00 +02:00
Qt Forward Merge Bot 10e3b24c02 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/jsruntime/qv4value_p.h
	src/qml/qml/qqmlmetatype.cpp
	src/qml/qml/qqmltypewrapper.cpp
	src/quick/items/qquicktableview.cpp

Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
2019-06-11 11:28:44 +02:00
David Faure 677d336def tst_qqmlecmascript: add expected warning
Change-Id: I6b5cebb75ceeed6664a5d239ee8ce66b171f2667
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-05-31 14:21:47 +02:00
Qt Forward Merge Bot 3ecdd85b2c Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I208cd36d2b7add94f36e4d86cf0c790a1e4a7e86
2019-05-26 23:04:41 +02:00
Simon Hausmann 2f4479857d Fix lookups of properties in QML singletons
An unqualified name that points to a QML singleton will evaluate to a
QQmlTypeWrapper JS object. A member lookup in such an object is not
guaranteed to always produce the same property. The property cache check
may protect us from that, but we must still retrieve the QObject
singleton for every lookup.

Task-number: QTBUG-75896
Change-Id: Ibd9bac6e5c2047f838758811790b299ace636446
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-05-21 12:42:45 +02:00
Qt Forward Merge Bot 0d409333d8 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I5d2c3da38df35922b2147c3c0bc55c6c3bae2fe5
2019-05-02 01:00:50 +02:00
Qt Forward Merge Bot ad6061b265 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ic008bf9223a9ac293c925044355ff218f7ed7f78
2019-05-01 01:00:45 +02:00
Ulf Hermann ac0d313ab1 Yarr: Reject quantifiers larger than 16M
Nobody needs those and we run into integer overflows later on if we
accept them.

Fixes: QTBUG-74048
Change-Id: Ib8ccd05e4bd6f662c38fbe95bf1350f81982e1b8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-30 12:37:19 +00:00
Qt Forward Merge Bot 0cf8e2fb97 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/qml/qqmlmetatype.cpp

Change-Id: Ieff61c076e46eb50a059c8b0210f7f4d7ce0cbcf
2019-04-23 09:53:31 +02:00
Qt Forward Merge Bot 53bd6b8111 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I9ef4be23bfe35aa48d4c65d4159e72c527943845
2019-04-19 01:00:04 +02:00
Ulf Hermann ea74f0c68c Don't crash when accessing invalid properties through QObjectWrapper
Change-Id: I613bf5dc685bb4235262b429d8f7318ea144fb9d
Fixes: QTBUG-75203
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2019-04-18 12:49:22 +00:00
Qt Forward Merge Bot 35f5963508 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/qml/qqmlmetatype.cpp
	src/qml/types/qqmlmodelsmodule.cpp

Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
2019-04-10 09:35:18 +02:00
Qt Forward Merge Bot 8c3172d724 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I68211a7d4568a1c31c6a124fe6777709c53736a5
2019-04-09 01:01:07 +02:00
Ulf Hermann 7878701165 Avoid INT_MIN % -1 and INT_MIN / -1
Those throw arithmetic exceptions as the result doesn't fit into an
integer.

Fixes: QTBUG-75030
Change-Id: Ibd978848f42cf1c9da1e4af2dc9d7da123ef8f5a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-08 13:48:24 +00:00
Friedemann Kleint 34c98070d1 Fix deprecation warnings about QVariant API
Fix warnings like:
sruntime/qv4serialize.cpp:378:45: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlListModelWorkerAgent::VariantRef]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qml/qqmlvmemetaobject.cpp:597:61: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1319:66: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
jsruntime/qv4engine.cpp:1350:60: warning: 'QVariant qVariantFromValue(const T&) [with T = QList<QObject*>]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8396:78: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickitem.cpp:8693:80: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:126:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickgenericshadereffect.cpp:127:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:713:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
items/qquickopenglshadereffect.cpp:714:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qquickcustomparticle.cpp:416:89: warning: 'QVariant qVariantFromValue(const T&) [with T = double]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]
qqmlenginedebugclient.cpp:403:47: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlEngineDebugObjectReference]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations]

Task-number: QTBUG-74043
Change-Id: I14cb7d7c1fb8dc6321e32208a7de15f6bdb19065
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-04-08 08:44:15 +00:00
Ulf Hermann a768780f36 Merge remote-tracking branch 'origin/5.13' into HEAD
Conflicts:
	src/qml/compiler/qv4compileddata_p.h
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jit/qv4jithelpers.cpp
	src/qml/jsruntime/qv4lookup.cpp
	src/qml/jsruntime/qv4runtime.cpp
	src/qml/jsruntime/qv4runtimeapi_p.h
	src/qml/jsruntime/qv4vme_moth.cpp
	src/qml/qml/qqmltypemodule_p.h

Change-Id: If28793e9e08418457a11fc2c5832f03cab2fcc76
2019-03-22 14:57:04 +01:00
Qt Forward Merge Bot 7a349710cc Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qqmltypecompiler.cpp
	src/qml/compiler/qv4bytecodehandler.cpp
	src/qml/compiler/qv4codegen.cpp
	src/qml/compiler/qv4compileddata_p.h
	src/qml/compiler/qv4compiler.cpp
	src/qml/compiler/qv4instr_moth.cpp
	src/qml/compiler/qv4instr_moth_p.h
	src/qml/jit/qv4baselinejit.cpp
	src/qml/jit/qv4baselinejit_p.h
	src/qml/jsruntime/qv4function.cpp
	src/qml/jsruntime/qv4vme_moth.cpp

Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
2019-03-21 10:59:45 +01:00
Simon Hausmann c9e6251cc8 Implement dummy QML lookups for "global" variables
When resolving names in the context of QML bindings, we now direct
runtime access to QQmlContextWrapper::resolveQmlPropertyLookupGetter. At the
moment this does basically the same as Runtime::method_loadName, which
we called earlier. However this now provides the opportunity to optimize
lookups in the QML context in a central place.

When performing a call on a scope or context object property, we also
did not use a CallName() instruction - which would have gotten the
thisObject wrong - but instead we use a dedicated
CallScopeObjectProperty and CallContextObjectProperty instruction. These
rely on identifying these properties at compile time, which goes away
with lookups (and also doesn't work when using ahead-of-time
compilation). Therefore the qml context property lookup is using a
getPropertyAndBase style signature and
Runtime::method_callQmlContextPropertyLookup uses that.

For the tests to pass, some error expectations need adjusting. In
particular the compile-time detection of write attempts to id objects is
now delayed to the run-time.

The old code path is still there and will be removed separately in the
next commit (as it is massive).

Task-number: QTBUG-69898
Change-Id: Iad1ff93d3758c4db984a7c2d003beee21ed2275c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-03-20 09:16:02 +00:00
Ulf Hermann d2fd8010d3 Support QRegularExpression on the same level as QRegExp
QRegularExpression is the recommended way to do regular expressions
nowadays. Support assignment of JavaScript regular expressions to
QRegularExpression properties of QObjects and the other way around.
QJSValue::toVariant() will create a QRegularExpression from a JavaScript
RegExp by default now.

[ChangeLog][QtQml][Important Behavior Changes] QRegularExpression is now
supported the same way QRegExp is in QML. QJSValue::toVariant() creates
a QRegularExpression variant rather than a QRegExp one from a JavaScript
regular expression now.

Fixes: QTBUG-73429
Change-Id: I301a02771cd17903406c2bc5c7aaeca6cce629f0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-20 08:05:04 +00:00
Ulf Hermann 0dd884aca1 Baseline JIT: Save accumulator in toInt32LhsAcc()
toInt32LhsAcc convertes both the lhs and the accumulator to int32. If
the accumulator is not saved, a GC run during the conversion of the lhs
might trash its value.

Fixes: QTBUG-74058
Change-Id: Ic42693061c7d483bb430d77bcc095de6ff9a6843
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-19 14:33:47 +00:00
Qt Forward Merge Bot e912c646e2 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qv4codegen.cpp

Change-Id: I66b7db42bf208855889094ace0267326595ce03c
2019-03-18 13:49:23 +01:00
Qt Forward Merge Bot 67cc0be410 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/compiler/qv4codegen.cpp

Change-Id: I604517d0948fb5056ce36cc104f13ac956fbcc24
2019-03-15 11:20:40 +01:00
Ulf Hermann 7e32be87c0 Don't keep raw pointers to SparseArrayNode
The nodes are owned by the SparseArrayData and will be freed whenever an
item is deleted from the array. Therefore, we have to look up the node
for each iteration. This is slightly slower, but at least it doesn't
crash.

Fixes: QTBUG-74188
Change-Id: Id24324a8c83b00b3ad1212cdaabccabd6c8a999f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-03-14 15:38:07 +00:00
Qt Forward Merge Bot 76be4abbbc Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/qml/compiler/qv4codegen.cpp
        src/qml/animations/qsequentialanimationgroupjob.cpp

Change-Id: I8b76e509fd7c8599d4cef25181d790ee28edab54
2019-03-13 10:10:09 +01:00
Qt Forward Merge Bot 5ad4faf773 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I7aa5284298990062fac9d9f1ab55d05f9b225ac9
2019-03-08 01:01:22 +01:00
Christian Ehrlicher 0d25cd5d97 QtDeclarative: replace deprecated functions
Replace the deprecated functions with it successors:
 - QProcess::finished(int) -> QProcess::finished(int, ExitStatus)
 - QDateTime::toTime_t() -> toSecsSinceEpoch()
 - QDateTime::setUtcOffset() -> setOffsetFromUtc()
 - QDateTime::utcOffset() -> offsetFromUtc()
 - QWindowSystemInterface::handleDrag/Drop(4 params) -> 6-params
 - QJSEngine::installTranslatorFunctions()
   -> installExtensions(QJSEngine::TranslationExtension)
 - QEasingCurve::cubicBezierSpline() -> toCubicSpline()

Change-Id: I96b4b2195887396b7a5182fce2749745380f5949
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-03-04 16:53:46 +00:00
Ulf Hermann 783ec60774 Disable tail calls for function called with more arguments than formals
We cannot easily find the required stack space to store the extra
arguments without adding a new stack frame. In principle it would be
possible, but heavily recursing on such functions should be a rare
problem.

Change-Id: I1a53a6d29e37ce67aa7bd64acb7b1f41197e84c0
Fixes: QTBUG-72807
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-03-04 15:07:41 +00:00
Ulf Hermann b959074afb Unify and fix number to string conversion with radix
Previously, the loop that generated the string could fail to terminate
with certain numbers as input. Also, the algorithm was duplicated in two
places.

Change-Id: Ie2075148d931e7cfcedb5bcd23af61e2e8afc232
Fixes: QTBUG-73999
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-02-25 12:49:13 +00:00
Erik Verbruggen cdb8eb988e V4: Rotate loop in ArrayPattern and eliminate "done" label
This prevents jumping over the resetting of the unwind handler when an
exception occurs.

(cherry-picked from commit 0282b89ec6)
Fixes: QTBUG-73985
Change-Id: I4a4da815f54c13980d239e0492f9b013991cfbd5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-02-25 12:49:10 +00:00
Qt Forward Merge Bot a1aee495c8 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/qml/qml/qqmlmetatype.cpp

Change-Id: I517c001ea4eb0fdd8e469f9fffe5b7559a5b0795
2019-02-25 09:20:43 +01:00
Liang Qi 3baa2d5505 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	tests/auto/quick/qquicktableview/tst_qquicktableview.cpp

Change-Id: If3bf1abc23a59c458be0bb862d92f2edcb16b79f
2019-02-22 14:26:13 +01:00
Ulf Hermann dca09f0973 Only warn about incompatible parameter types passed from QML
Throwing a TypeError is too drastic. We need to properly deprecate this
pattern before we actually enforce the compatibility.

Fixes: QTBUG-73943
Change-Id: I00313ad7aed4021a7368fd014e2bfc6443b177e3
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-21 11:15:38 +00:00
Qt Forward Merge Bot 573afc9fdd Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ie33d1c736992abcbde6568131374a7a7891f965c
2019-02-21 01:00:50 +01:00
Qt Forward Merge Bot 03097d5038 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I69c3e6610ff590d9c18f386fc17ed2e429b58d26
2019-02-20 01:00:04 +01:00
Ulf Hermann 94d30df911 Check parameter types when invoking C++ functions from QML
We now check if the given parameters can be converted to the expected
arguments of the function being invoked and throw a type error if not.
Previously we would still invoke the method with random parameters.

[ChangeLog][QtQml][Important Behavior Changes] The parameters passed to
C++ functions from QML are now checked for compatibility with the
expected arguments. If they cannot be converted, a type error is thrown
in JavaScript and the function is not invoked.

Fixes: QTBUG-73405
Change-Id: If16089510d314bb7cdb7d4db86478114c61281a8
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-02-17 08:10:17 +00:00
Erik Verbruggen 2b297cae4b V4: Clean up the runtime functions declarations
The declarations and usage of runtime functions have seen a number of
changes:
- we don't use the array of method pointers anymore because we don't use
  cross-platform AOT JITting
- the check if a method can throw a JS exception was invalid, and was
  not used anymore
- value-pointer vs. const-value-ref was inconsistent

This patch cleans that up. By fixing the exception checking, we can now
use it in the baseline JIT to automatically insert those checks. To make
that work correctly, all runtime methods are in a struct, which gets
annotated to indicate if that method throws. (The old way of checking
which type of engine was used is fragile: some non-throwing methods
do not take an engine parameter at all, and those got flagged as
throwing). By using a struct, we can also get rid of a bunch of
interesting macros.

The flags in the struct (as mentioned above) can later be extended to
capture more information, e.g. if a method will change the context.

Change-Id: I1e0b9ba62a0bf538eb728b4378e2678136e29a64
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-02-05 09:51:29 +00:00
Liang Qi 8ec2403603 Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
	src/3rdparty/masm/yarr/YarrJIT.cpp
	src/qml/compiler/qv4instr_moth.cpp
	src/quick/handlers/qquicksinglepointhandler_p.h
	src/quick/handlers/qquicktaphandler.cpp
	src/quick/items/context2d/qquickcontext2d.cpp

Done-With: Ulf Hermann <ulf.hermann@qt.io>
Change-Id: I109453131f9f0a05316ae37c7d6ed1edc8c0f9d4
2019-01-29 12:37:04 +01:00
Ulf Hermann ba6371fb2a MemoryManager: Only clear weak values once
We want to keep the weak values alive while the destruction callbacks
are running, so that they can still access them. We set them to
undefined later anyway because we expect the destruction callbacks to
mess with the values. Therefore there is no point in also setting them
in between.

Fixes: QTBUG-72137
Change-Id: I83f70230f5b4ad2761c74770f975b14a5ca71f18
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-01-23 07:43:38 +00:00
Ulf Hermann 0b863bca30 QML: Special case null as binding type
This gives us the opportunity to map the JavaScript null to QVariant's
concept of isNull().

[ChangeLog][QML] Assigning JavaScript null to incompatibly typed
properties generates a compile error now, rather than a runtime error.

Fixes: QTBUG-72098
Change-Id: I72fd1c30d84128c774230eaaea10455b2a0e064c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-01-21 08:40:33 +00:00
Ulf Hermann 75ebbd0b35 Quote stringified generic variants on JSON.stringify
A string representation of those is unlikely to be actual JSON, and even
if it is, we don't want to use it as such.

Fixes: QTBUG-72674
Change-Id: I6815366a0176d9725ff4840d3fc545792ce00535
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
2018-12-20 13:45:52 +00:00
Ulf Hermann 64ee4968b4 QML Lexer: Stop scanning template literals on closing '`'
Fixes: QTBUG-71812
Change-Id: I93b99496a7572c0f5128c69b865bb2b4f87d29af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-11-19 14:39:18 +00:00
Jüri Valdmann 627226520a Expose let/const variables from imported JS scripts
This patch allows QML to access let/const variables defined in JS files.

Detailed changes:

  - The recently added ContextType::ScriptImportedByQML is changed to avoid
    creating Push/PopScriptContext instructions, similar to
    ContextType::ESModule.

  - QV4::Module is changed to also work with CompilationUnits which are not
    ESModules. In this case QV4::Module will behave as if all lexically scoped
    variables were exported.

  - CompilationUnit is changed to support instantiating and evaluating
    QV4::Modules for non-ESModules as well.

  - QQmlTypeLoader is changed to always create QV4::Modules for evaluating
    scripts. For the non-ESModule case, the QV4::Module is evaluated inside a
    QV4::QmlContext, as before.

  - A pointer to the QV4::Module is added to QV4::QQmlContextWrapper, and used
    in virtualGet to access the let/const variables in the CallContext. Access
    is read-only.

Fixes: QTBUG-69408
Change-Id: I6f299363fdf5e1c5a4a0f1d9e655b4dc5112dd00
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-11-02 16:44:11 +00:00
Lars Knoll 19b8799958 Fix a crash when allocating huge memory segments
When allocating a huge item that requires it's own memory
segment, we were actually not committing enough memory from
the OS.

Fixes: QTBUG-71501
Change-Id: Ic86a648bba4d7f1eeeded78d8de0f0fc1d3a251d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-11-02 09:10:59 +00:00
Jüri Valdmann 1ac3dd0e7a Add test for importing let/const variables from scripts
Try to import let/const variables from JS scripts into QML.

Task-number: QTBUG-69408
Change-Id: Ie58cbc8cd9f8a47f5a077f95b07b5f9e1524707a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-10-22 15:05:29 +00:00
Lars Knoll 939014cb9c Fix logic error in JSCodeGen::fallbackNameLookup()
Don't return a name reference if we fail to lookup something in
the scope object, but rather continue trying in the context
object.

Task-number: QTBUG-70315
Change-Id: I73f8aa7b648320434ef0ef37a4c12dca1eb7b209
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-09-05 12:57:29 +00:00
Lars Knoll 123f01df33 Fix TDZ check for references
So far we've not been doing the TDZ check for expressions such as
x.name, a[x] and super[x] correctly. Fix this by adding a second
boolean that states whether a tdz check for the subscript is required
and use the first boolean to check the base of these references.

Change-Id: I658cd5b69f001fbdc714f252914ad9749734f027
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-08-29 18:10:48 +00:00
Lars Knoll db695c5b1d Unify the get and getIndexed vtable functions of QV4::Object
This finalizes the refactoring of Object's vtable API. Also added
the receiver argument to the method as required by the ES7 spec.

Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-02 19:29:29 +00:00
Rainer Keller 22ef109ccd Improve error message
Change-Id: I29b9a35c080c50469ac1a3ff5f83a31349e801ad
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-02 13:42:14 +00:00
Lars Knoll 4b7d56f65d Fix some of the finer details with regards to Completions
JS completion records have some finer details that can only be
seen when using eval(), where the value of the completion record
becomes important.

Fix most of those cases to be compliant with the spec.

Change-Id: I0c8105a8e778de7be3aea151d1bd64243aea067c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-21 13:30:19 +00:00
Lars Knoll 9333ea8649 Ensure we read context properties before the global object
Also global variables declared in a .pragma library script
should not be saved in the global object, as the script has
it's on context where those variables live.

[ChangeLog][QtQml] Properties of the JS global object will now
be looked up after local properties in the QML object. This
can lead to runtime incompatibilities if your qml file is named
the same as a property of the global object (e.g. Date.qml).

Task-number: QTBUG-51581
Change-Id: I108aea4c76d088ca8c2124700f91e8eac3fc19f3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-06-17 20:06:16 +00:00
Simon Hausmann 7cb6dce1f3 Remove bindings that have no dependencies
After the initial enabling of a binding we can quickly determine if
there is a chance whether this binding will be re-evaluated again in the
future as a consequence of dependency changes (properties or
translations). If that is not the case, then we can save memory by
removing that binding again.

One implementation consequence of this change is that such constant
bindings used with the "when" property of states require a proper
reference count increase, which was previously implicit through the
binding association with the target object.

In tst_qqmlecmascript a test that verifies that we don't create run-time
bindings for assignments of literal "null" to QObject pointer properties
now also covers the more complex case where we don't know the property
at parse time. We still evaluate the binding once though and perform one
property assignment.

Similarly on the QtQuick Designer Support API test side a binding such
as

    x: Math.max(0, 200)

will not create a persistent binding anymore and needs a tweak to
remain.

On a large scale application this optimization saved up to 5% of all
bindings on start-up (~9000 of ~180000). On Linux x86-64 one binding is
approximately 144 bytes, so the savings are in the range of ~1.2 MB of
heap, as well as reduced fragmentation.

Task-number: QTBUG-64541
Change-Id: Id3653008346fdf36611f5b4c4e82f5f78b5319aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-05-16 14:57:59 +00:00
Lars Knoll 9f20a3155c Isolate the different tests from each other
Those tests used a shared QQmlEngine so far, leading in some cases
to side effects that last across tests. Fix this by always creating
a new QQmlEngine for each test case.

Also renamed some paths still containing 'nokia' in them.

Change-Id: I4edbae66ac7a7930be66df8294ffbaf98636fb1c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-14 20:09:22 +00:00
Simon Hausmann d258c904a6 Throw type errors when attempting to mutate read-only sequence properties
Calling for example Qt.application.arguments.push("...") should throw an
exception.

Task-number: QTBUG-67774
Change-Id: Ifd5cd3357dde510cca77b9b32c9f55f8f72837ff
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2018-05-02 15:46:26 +00:00
Lars Knoll d499a99529 Make sure we call Codegen::defineFunction with proper arguments
So far, when instantiating QML bindings, the node parameter
could be the same or a child of the body. This will break
badly when we introduce lexical scopeing as that node
could be an AST::Block that opens it's own context.

Changing this requires some smaller adjustments to our autotests,
as error locations will now be slightly different (pointing to
the beginning of the binding, not the beginning of the RHS of
the binding).

Change-Id: I2c536a4fe6d8b549a138cc7967ef034eb2523f3b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:17:41 +00:00
Lars Knoll e9492e7b7b Rename the CompilationMode enum to ContextType
And make it an enum class. The new name fits better, as it's mainly
used to determine the type of the context when parsing. Also already
added the 'Block' value that will be needed.

Change-Id: I70d963b6a0b22db1a3c607cce6bdd2054b29e000
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-05-02 14:17:13 +00:00
Qt Forward Merge Bot f0f01cc379 Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I4a9c7802c180757e70fa4dd16df3287104a088bc
2018-04-18 01:00:06 +02:00
Lars Knoll 4909773f81 Fix calling Qt.binding() on bound functions
Calling Qt.binding() on a bound function object is a valid use
case and used to work until Qt 5.8.

The problem was that we optimized the code in QQmlBinding and
QQmlJavascriptExpression to directly work on a QV4::Function,
so this wouldn't work anymore.

To fix this make sure recursive calls to Function.bind() are
unrolled (so that the BoundFunction's target is never a bound
function itself), then add the bound function as an optional
member to the QQmlBinding and use it's bound arguments if
present.

Task-number: QTBUG-61927
Change-Id: I472214ddd82fc2a1212efd9b769861fc43d2ddaf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-16 17:52:13 +00:00
Simon Hausmann 8e2cfa1d77 Fix JSON.stringify with sequence types
Stringify::JA takes an ArrayObject* but it merely gets the length
property and does indexed get calls. Those work also on array-like
objects such as our sequence wrappers.

Task-number: QTBUG-45018
Change-Id: I4ec4f89a2e09c918fbc2ff1d48ae5915e67ce280
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2018-04-16 17:52:10 +00:00
Lars Knoll 278b144a35 Disambiguate different allocation functions in the memory manager
Some compilers (in this case MingW 5.3) don't manage to properly
disambiguate the template overloads, and try to instantiate the
wrong template function.

Solve this by renaming the one of the template functions.

Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-04-12 13:58:48 +00:00
Erik Verbruggen 9a2cfd5155 Add test for jump strict-not-equal undefined on 32bit
Commit 86702c3be5 and
e2218f8b5c were submitted directly to the
5.9 and 5.6 branches. As the problem does not exist per-se in 5.11 there
is no fix required. This commit only adds the test coverage for this
issue to avoid regressing.

Change-Id: Ic5f5d56f52f3855d20755f771804025f8a93acd9
Task-number: QTBUG-66832
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-03-26 09:35:32 +00:00
Simon Hausmann 80b5f8c2f4 Add a test that verifies the this object in signal handlers
Ask expected, this passes currently. The this object is set to the scope
object in QQmlJavaScriptExpression::evaluate, which
QQmlBoundSignalExpression::evaluate calls.

Task-number: QTBUG-66942
Change-Id: I16a709768f9c798910377a52b5e882bb6d554a5f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-03-17 08:01:59 +00:00
Shawn Rutledge 499ec43937 use nullptr consistently (clang-tidy)
From now on we prefer nullptr instead of 0 to clarify cases where
we are assigning or testing a pointer rather than a numeric zero.

Also, replaced cases where 0 was passed as Qt::KeyboardModifiers
with Qt::NoModifier (clang-tidy replaced them with nullptr, which
waas wrong, so it was just as well to make the tests more readable
rather than to revert those lines).

Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-26 07:13:18 +00:00
Erik Verbruggen cb9ea3df7e Make sure we can call properties of constants
This might not be the most useful thing to have, but it's part of JS, so
we better handle it.

Task-number: QTBUG-66027
Change-Id: Ib40c90515a3ffd1d065d962d6c79a5e3960e2703
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-23 12:38:19 +00:00
Mitch Curtis b2c71d6518 Fix "Expression depends on non-NOTIFYable properties" regression
CONSTANT properties are by nature non-NOTIFYable.

The issue behind the regression is caused by the fact that we were
capturing a property regardless of whether or not it was const.
There were two states that captureRequired was expressing:

true: We're reading the property of a QObject, and we're not quite sure
where the QObject comes from or what it is. So, when reading that
property at run-time, make sure that we capture where we read that
property so that if it changes we can re-evaluate the entire
expression.

false: We're reading the property of a QObject, and we know that it's
the scope object or context object, which we know very well. Instead of
registering a property capture every time, we can do that ahead of time
and then register all those captures in one shot in
registerQmlDependencies().

There is a third state that is only relevant when captureRequired is
false: We're reading a property from the scope or context object, but
it's a CONSTANT property, so we don't need to register a dependency
at all.

This patch adds replaces captureRequired with the PropertyCapturePolicy
enum, which accounts for the third state and, as a bonus, makes the
code easier to understand.

Task-number: QTBUG-66361
Change-Id: I6cef1deb76538fbdacf1324b4467403dd40dd7de
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-02-17 20:49:58 +00:00
Liang Qi 4d525de33e Merge remote-tracking branch 'origin/5.10' into 5.11
Conflicts:
	src/imports/shapes/qquickshape.cpp
	src/imports/shapes/qquickshape_p_p.h
	src/qml/compiler/qqmlpropertycachecreator_p.h
	src/qml/jsruntime/qv4value_p.h
	src/quick/items/qquickloader_p.h
	tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
	tools/qmlprofiler/qmlprofilerapplication.cpp

Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69
2018-02-12 16:31:13 +01:00