aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4qobjectwrapper.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Place all of qv4qobjectwrapper.cpp in namespace QV4Ulf Hermann2022-01-251-174/+170
| | | | | | | | | We already had to open the namespace once. This way we can avoid the using declaration and get rid of most of the QV4:: qualification. Task-number: QTBUG-90898 Change-Id: I83c82b20538c418998db8ab8860843b995b4f4a3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid ping-pong between plain pointers and QQmlRefPointerUlf Hermann2022-01-251-2/+2
| | | | | | | | | | | | | | | We want to deal in QQmlRefPointer as much as possible. In particular, assigning nullptr to a QQmlRefPointer triggers the creation of an empty QQmlRefPointer and the assignment of that one. Provide a reset() method to do this in a cleaner way. In turn, make QQmlGuardedContextData::reset() private. It's really dangerous and should not be called from outside. setContextData() is safer but may do additional work. The only place from where reset() was previously called in its public capacity is probably dead code, though. Change-Id: Idb72e255dbfad6e5dd963dc76d719bb9edc10471 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move propertyCache- and metaObject-related functions into QQmlMetaTypeUlf Hermann2022-01-181-4/+1
| | | | | | | | | | | | That's where the data resides. This allows us to lock the mutex only once for all those methods, and it makes a large number of engine pointers unnecessary. Finally, we can now find the element type of a QQmlListProperty without supplying an engine. Change-Id: If1ae8eafe8762a112d1ca06f9c92ab8a727d1bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move QJSEnginePrivate::cache() to QQmlMetaTypeUlf Hermann2022-01-181-17/+14
| | | | | | | | | It is just in line with the other propertyCache() methods, and should be treated the same way. The comment made no sense anymore. This allows us to drop more engine pointers. Change-Id: I2e9b479b555c7f771b619e4693d59cbfcf244df6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove the qml_sequence_object feature flagUlf Hermann2022-01-151-16/+0
| | | | | | | | | | | | | | | | | | | QML sequences are required for named lists of value types. The original reason for the introduction of this feature was the template code explosion caused by the way the sequence types were registered in Qt5. As we register them differently now, the code size overhead should be smaller. It makes very little sense to switch sequence types off these days. [ChangeLog][QtQml][Important Behavior Changes] The qml_sequence_object feature flag has been removed. Omitting sequences from the QML language does not make much sense now that we use them for lists of value types. The original reason to allow it was that the sequence support took up a lot of space in the binary. This is not the case anymore since 6.0. Change-Id: I2f1d43cdd29ba63853316b06113cb49ed30aa410 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify PropertyCache refcountingUlf Hermann2022-01-031-1/+1
| | | | | | | | | We should not keep plain QQmlPropertyCache pointers around. Also optimize self-assignment of QQmlRefPointer. Change-Id: I0e30b4ce29bb6b7acf288a9dc7b515d0e8f4ddfe Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do not copy lookupsUlf Hermann2021-12-161-18/+1
| | | | | | | | | | | | | It leads to data corruption. Also, be more careful about releasing the property cache. We can only do that if the qobjectlookup member of the union is active. Unfortunately we have to do a number of checks now, to make sure it is. In order to still keep the checks inline, we move some functions around. Pick-to: 6.2 6.3 Fixes: QTBUG-99211 Change-Id: If6dd879e67b172e1a9035e83fbfacbe73c6c7476 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSAotContext: flushPendingBinding() before capturing a propertyUlf Hermann2021-12-101-1/+1
| | | | | | | | This avoids duplicate evaluation and binding loops. Pick-to: 6.2 Change-Id: I5eba42d9dca0782dd964bd64c088c2e158faa9b3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4 Lookup: Do not leak property cachesUlf Hermann2021-12-091-4/+1
| | | | | | | | | | | | | | | | | | | | | | When a function that performs a lookup is called recursively via the flushing of initial bindings, we may initialize the same lookup twice. In that case, make sure to release the old property cache before overwriting it. We might suspect that this can only re-assign the same property cache again and therefore we can skip the whole operation if it has been done before. Yet, considering the dynamic nature of QML, it's very hard to guarantee this. There are cases where we have to revert lookups because the types don't match anymore at the time we call them again. I cannot rule out the possibility of this happening during initialization. Therefore, the code doesn't try to be clever about this case and instead just blindly overwrites the lookup (like it did before, just without leaking). Fixes: QTBUG-99025 Pick-to: 5.15 6.2 Change-Id: I536deef282bbff723f79a82e4d9e694c3d2d32df Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4::QObjectWrapper: Clean up CallArgumentUlf Hermann2021-11-091-258/+323
| | | | | | | | | | | Prefer comparison of metatypes by type rather than ID. When still comparing by ID take advantage of switching through the builtin types. Furthermore, restructure the code for more clarity and consistently apply the qml_sequence_type guards. Change-Id: I7572ba644621ac551ae1821a59229b60c1485a1d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Clean up PropertyCache life cycleUlf Hermann2021-11-091-10/+8
| | | | | | | | | | | | | We generally want to use QQmlRefPointer for it, rather than manually calling addref() and release() all over the place. Also, we can completely inline its ctor and drop an unused member. Also, do not keep property caches of dynamic meta objects in type registry. The dynamic metaobjects will change, and the outdated property caches will eventually be retrieved. Change-Id: I8042c85b32f3031b554f97a35c1545a3412d2acb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QV4::QObjectWrapper: Improve overload resolutionUlf Hermann2021-10-211-39/+59
| | | | | | | | QQmlV4Function should be used as the last fallback if there are other options available. Also, take QVariantMap into account. Change-Id: I9ebf39f4f860cf3bf44c6cbc80efbac7ea30c70b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Improve type conversions from/to QJSValueUlf Hermann2021-10-201-1/+3
| | | | | | | | | We can convert everything into a QJSValue if we have an engine and we can save a binding function in a QVariant by wrapping it into QJSValue. Change-Id: I48e7c13f3f744f1c50bf673b427fe9331250f313 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* disconnectNotifiers() more aggressively during object deletionUlf Hermann2021-09-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | When an object is queued for deletion, there is no point in notifying anyone anymore. The change notifications almost always result in the property that changes being read. Reading a property from a half-deleted scope object silently returns undefined, no matter what type the property is. Reading a property from a half-deleted object via some qualified lookup throws a type error. Neither of those is useful. Furthermore, when an object is deleted, often a large number of properties change, triggering a lot of unnecessary computation. [ChangeLog][QML][Important Behavior Changes] When an object is queued for deletion, for example because its parent object is being deleted, then all of its change notifiers are dropped. This means no binding or signal handler that depends on properties of such an object will be triggered anymore. As you cannot read properties from such half-deleted objects anyway, there was never a point in being notified about further property changes. There may be corner cases where the notifications are used for some unrelated processing, though. Task-number: QTBUG-95262 Change-Id: I7bab0e42dd892921be259ea764160f99a46a322d Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Skip superfluous property capture attemptFabian Kosmale2021-08-091-1/+2
| | | | | | | | | | If a QQmlProperyBinding tries to capture a QProperty, there is nothing to do as the dependency tracking happens in C++ anyway. Thus we can avoid calling captureProperty. Pick-to: 6.2 Change-Id: I96b2876d4b2ba10b00af8342be9beae660a95ef3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QV4::Scope::hasException() where applicableUlf Hermann2021-06-301-2/+1
| | | | | | | It is shorter and encapsulates the exception handling a bit. Change-Id: I8e2dc0eb3b930e222b8cb4852b73d99ca18a0379 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Pass QMetaType by value rather than by ID in more placesUlf Hermann2021-06-091-23/+36
| | | | | | | | | | This saves us some ping-pong between the IDs and the QMetaTypes, and avoids possible ambiguities if multiple metatypes are registered for the same C++ type. Change-Id: I81cec94a9cd05d69927dc884f65574f0ab2ddc22 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlMetaType::metaObjectForMetaType into metaObjectForValueTypeUlf Hermann2021-06-081-2/+2
| | | | | | | | It really only works for value types and it's not intended to do anythign else. The name should reflect this. Change-Id: Ib73bf7e9655971f7826fe72145e2d2fab363363c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clarify ambiguous Object to be one under V4Janne Koskinen2021-05-281-1/+1
| | | | | | | Fixes Integrity "ambiguous" compiler error Change-Id: Iea96eba25df83d97ea29b205fcb779f6efbe3d7f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Do not write back value type references on const method callsUlf Hermann2021-05-101-33/+47
| | | | | | | | | | | The property setters can have side effects. We should only call them if really necessary. We don't have to write back after calling const methods. Fixes: QTBUG-93480 Change-Id: I53a246edd37b7f0c31f0e0effe5dfa996548f74c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* V4: Write back value type references after function callsUlf Hermann2021-05-051-1/+10
| | | | | | | | | | | | If we call a function on a value type reference we have to assume that the value has changed. Therefore, we need to write back, just like we do when writing a property on the reference. Fixes: QTBUG-91783 Pick-to: 6.1 5.15 Change-Id: I6d2e957997d64e40e42eb5210350b6592a92ee26 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Redesign the AOT lookupsUlf Hermann2021-04-301-0/+11
| | | | | | | | | | | | | | | Each kind of lookup should come with a function that tries to execute the lookup, taking a minimal number of parameters, and another one that initializes the lookup, taking whatever is needed for that. No initialization should be done in the execution step and vice versa. Rather, the execution step should be repeated if an initialization had to be done first. This way, the happy path can be very fast if the lookups have been initialized before. Change-Id: Ic435b3dd4906d00144138cb05161a99a0a9c64ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compiler warnings from char*/QString conversionVolker Hilsheimer2021-04-281-1/+2
| | | | | Change-Id: I904c123f73a6c398d45215a976652a0712ce40fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix build without features.qml-sequence-objectTasuku Suzuki2021-04-191-0/+2
| | | | | Change-Id: I2da9712201f3057b4d20aa0176716442d69d0ab9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4QObjectWrapper: Store the whole signalFabian Kosmale2021-04-011-6/+7
| | | | | | | | | | | | | | | | | | | | | 90be89d771425044a84e9e79e4e668e065acc825 changed the connection logic to actually pass the receiver to connect in order to fix disconnect cleanup. However, we omitted to change QObjectSlotDispatcher::impl accordingly. The previous logic was: - store the index of the signal in signalIndex - In impl, in the call case, we would get passed the emitting object (sic!) as the receiver parameter. Then we would use the object and the signal index to obtain the QMetaMethod. - From the QMetaMethod, we could get the signal's number of parameters. After the aforementioned change, that does not work anymore: The receiver is now the actual receiver of the signal, thus we get the wrong method, and potentially the wrong number of parameters. To fix this, we now store the complete QMetaMethod of the signal. Pick-to: 6.1 Change-Id: I868c51edf24a61d14eaf958ed7942da27f54a5c3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4::Engine::toVariant: Use metatype instead of metatype idFabian Kosmale2021-03-251-6/+6
| | | | | | | | | | This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlMetaType: Remove qmlLists memberFabian Kosmale2021-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of using a hashmap which maps a QML lists metatype to its list element's metatype, we can just store a pointer in the list metatype to the element metatype. Moreover, listType now returns a metatype. This is a preparation for converting enginePriv->rawMetaObjectForType(typeId) to metaType.metaObject() calls once we can actually retrieve the metaobject from QML metatypes. The QML metatype interface classes are moved into a header, so that Qt for Python can use the same classes. This does not affect types registered from C++, as those use a different mechanism. Task-number: QTBUG-88766 Task-number: QTBUG-82931 Task-number: QTBUG-87134 Change-Id: I330c2bbe4ac92072a333c001750f7504b56df478 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Clean up JSCallData setupUlf Hermann2021-03-171-5/+5
| | | | | | | | | | | | | | | | | We either have pre-populated arguments and thisObject, then we can just use them and keep them const. Or, we want to allocate and populate the arguments and the thisObject. Then, do allocate them in a separate object, and transform that into JSCallData afterwards if necessary. Furthermore, avoid alloc(0) as that just returns the current stack top. Writing to it will clobber other data. Rather, just use nullptr and crash if it's written to. Also, remove the useless operator-> from JSCallData. That one just confuses the reader. Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't store the scope in JSCallDataUlf Hermann2021-03-171-4/+4
| | | | | | | | | | | We only need it when generating CallData, or when filling in any thisObject or arguments that weren't provided. Provide a constructor that expects thisObject and arguments to be pre-allocated and one that allocates them in a scope passed as argument. Change-Id: Iddfba63f4dbc5b09e2b33fb22a94eea88f515902 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlEnginePrivate: remove functions that only forward to QQmlMetaTypeFabian Kosmale2021-03-051-1/+1
| | | | | | | | | | As a drive-by, remove metatype-id to metatype conversion in qqmlproperty.cpp Task-number: QTBUG-82931 Change-Id: I88511bdc103bfb507b6c4401af103e0aec13894f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Engine: Cleanup method argument passingFabian Kosmale2021-03-041-46/+44
| | | | | | | | | | | | Instead of arguments around as a pointer to [argc, metaTypeId1, metaTypeId12, ...] pass argc and a pointer to [QMetaType1, QMetaType2] around. Moreover, make use of the fact that we now carry the metatype instead of only the id in a few places, to avoid id -> metatype lookups. Task-number: QTBUG-82931 Change-Id: Ib00e4d793727f85f3358a8162d1aac972daab3d3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Handle const QObject pointer correctlyFabian Kosmale2021-03-011-1/+18
| | | | | | | | | | | | | | | | | | | [ChangeLog][QML][Important Behavior Changes] If a QObject pointer is passed to the QML engine and subsequently frozen with Object.freeze, modifying its QObject properties now fails and throws a TypeError. The TypeError is thrown even in non-strict mode. [ChangeLog][QML] It is now possible to pass const QObject derived pointers to QML in properties, and to call Q_INVOKABLE functions which take such pointers as arguments. If the QML engine receives such a pointer, it is treated as if the object was frozen. Fixes: QTBUG-82354 Change-Id: Ib0dbcdfb2370654505936c3cf391d87dd2c9677b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlMetaObject::methodReturnType: provide metatypeFabian Kosmale2021-02-191-1/+1
| | | | | | Task-number: QTBUG-82931 Change-Id: Ifbaf32d1c4af5064d94ec379fcb1667ce1c0502c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4QObjectWrapper: handle bindable propertiesFabian Kosmale2021-02-191-9/+33
| | | | | | | | | | | | | | | A function created by Qt.binding should lead to the binding being set (and replacing any previously existing binding). This was not the case for bindable properties so far. For those, we would have kept any existing C++ or QQmlPropertyBinding binding, and instead created a brand new QML binding which would have been set in addition. This patch also introduces a new class, QQmlPropertyBindingJSForBoundFunction, which is used to handle the case where the binding function is not a simple function, but has its parameters bound instead. Change-Id: Ia1417162b9822efb3f17ca4a6ecc02f959392927 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4QObjectWrapper: Use new findAliasTarget overloadFabian Kosmale2021-02-191-3/+1
| | | | | Change-Id: I417eabb296eb4bc8a8276fb52d70f4df7fda576f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QObjectWrapper::setProperty: Simplify binding handling logicFabian Kosmale2021-02-191-23/+20
| | | | | | | | | By returning early in the binding case, we do not have to to check for binding being non-null in other branches. Furthermore, we can reduce the scope of a few variables. Change-Id: I4b97663ddfa7adf65bfac6eaec4259bd79a76d2d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Unregister value types when tearing down QML typesUlf Hermann2021-02-121-4/+4
| | | | | | | | | Move the value type registry into QQmlMetaTypeData. This way we can conveniently drop the relevant entries when unregistering a type. Fixes: QTBUG-86946 Change-Id: Id024a34a8b2b622fd9417fc0e52864b43c66cc01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use new QObjectPrivate connection mechanism in dynamic connectionsAndrei Golubev2021-01-211-2/+18
| | | | | | | | | | | Old API assumes sender == receiver, which results in wrong handling of connections when receiver is deleted: connection is not removed or notified elsehow as it's not really tied to a valid receiver Task-number: QTBUG-86368 Pick-to: 5.15 6.0 Change-Id: I0f3115f1b0f26cf353752ba2b8fd88e0f3bdd388 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Fix writing function to property through aliasFabian Kosmale2021-01-181-1/+18
| | | | | | | | | | | | | | We special case writing functions to properties, only allowing assigning them to var properties and QJSValue properties. This would however break when aliases are involved. This commit fixes the issue by resolving the alias, and then checking and writing to the resolved property. Fixes: QTBUG-90373 Pick-to: 5.15 6.0 Change-Id: Ia09ebe92feeaf8359c99ff9aeadc676b9fcfaa07 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use QMetaType instead of metatype-id, take 2Fabian Kosmale2020-12-031-7/+8
| | | | | | | | | This time, the ValueTypeFactory gets converted. As a consequence, many callers get touched again. Task-number: QTBUG-88766 Change-Id: I3a8b7d5cfeb7fac85daf1702febba205971d4256 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove the property cache from QQmlValueTypeWrapperLars Knoll2020-12-021-1/+1
| | | | | | | | | | | Instead operate directly on the meta object. We could maybe have an optimization, where we have a global map from id to QQmlPropertyData for each value type. Task-number: QTBUG-88765 Change-Id: I259a06ba116a536b56380c2636737c6c016665d9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove the pointer to the property cache in QObjectMethodFabian Kosmale2020-12-021-6/+2
| | | | | | | | | It's not being used anymore. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Task-number: QTBUG-88765 Change-Id: Ieab1cba6c664c65d123d8f1ffd6db5878010f965 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Unify overload resolution code and introduce a cacheFabian Kosmale2020-12-021-170/+68
| | | | | | | | | With this approach we can also avoid passing the property cache around. Original-patch-by: Lars Knoll <lars.knoll@qt.io> Task-number: QTBUG-82931 Change-Id: I88f770d5d9a31b2f5071ad457d9a830900130a85 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Use QMetaType instead of metatype-id in propertydataFabian Kosmale2020-11-261-29/+31
| | | | | | | | | | | | | | We don't want to convert back and forth between QMetaTypes and ids. This change is the first step towards using QMetaType directly everywhere. By reordering the members of QQmlPropertyData to avoid a gap caused by alignment, we can replace the typeid int with a QMetaType without requiring more space. There are still a few places left using metatype ids, notably the value type logic. Task-number: QTBUG-82931 Change-Id: Ic38f38d10c71ed20655877976c9cb5ee3cbe2d77 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Get rid of the QQmlStaticMetaObjectLars Knoll2020-11-261-5/+4
| | | | | | | | This can easily be folded into it's parent classes. Task-number: QTBUG-82931 Change-Id: I92e490b35c29aacdff3557d0b6318b1dd43e7bbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove hack to get the methodCount of a metaobjectLars Knoll2020-11-261-17/+4
| | | | | | | | Instead use the proper private API from Qt Core. Task-number: QTBUG-82931 Change-Id: Ia460350941f07ff749013fb29621460074d57a7d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Rewrite Qt object in actual C++Ulf Hermann2020-11-091-12/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quite obviously, the Qt object is a singleton, extended with a namespace, backed by a member of the JavaScript global object. Defining all the methods as JavaScript functions is unnecessary and duplicates the general type transformation code. Also, it makes it hard to use those same methods from a C++ context as we cannot properly set up the arguments outside the JS engine. Rewriting the Qt object reveals some deficiencies in the old implementation that we need to fix now: 1. The enums of the Qt type were listed as properties of the Qt object, which means you could iterate them with a for..in loop in in JavaScript. This is just wrong. Enums are not properties. This functionality is deleted and the test adapted to check for each enum value separately. The commit message for the change that introduced the iterability already mentioned that the author had failed to find any occurrence of this in the real world. 2. Parsing time objects from strings was done by parsing the string as a date/time and then picking the time from that. We still support that for now, but output a (categorized) warning. Parsing the time directly is preferred where possible. 3. Previously you could create (invalid) dates and times from various kinds of QML types, like int and color. This does not work anymore as we now validate the types before calling the functions. 4. Passing more arguments to a function than the function accepted was unconditionally ignored before. Now, a Q_CLASSINFO on the surrounding class can specify that the arguments should be checked, in which case a JavaScript error is thrown if too many arguments are passed. In order for this to work correctly we also have to ignore JS undefined values as trailing arguments for overload resolution. This way, if a method matching the defined arguments exists, it will be preferred over a method that matches the full argument count, but possibly cannot accept undefined as parameter. Consequently a number of error messages change, which is reflected in the qqmlqt test. [ChangeLog][QtQMl][Important Behavior Changes] You can not iterate the enumerations of the Qt object in JavaScript anymore. This does not work with any other enumeration type either. You can of course still access them by name, for example as Qt.LeftButton or similar. [ChangeLog][QtQMl][Important Behavior Changes] The time formatting functions of the Qt object in QML now allow you to pass an actual time string, rather than a date/time string as argument. Passing a date/time string results in a warning now. [ChangeLog][QtQml][Important Behavior Changes] Functions in the Qt object for formatting date and time will now throw a JavaScript error when presented with a value of an incompatible type, such as int or color. [ChangeLog][QtQml][Important Behavior Changes] The Qt.resolvedUrl() function now returns a URL rather than a string. This follows the documentation. [ChangeLog][QtQml][Important Behavior Changes] The GlobalColor enum of the Qt namespace is not exposed to QML anymore. It did not make any sense before as the enum values could not be used as colors. Change-Id: I7fc2f24377eb2fde8f63a1ffac5548d652de7b12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML engine: fix conversion scores for sequences in CallOverloadedFabian Kosmale2020-11-041-0/+7
| | | | | | | | | | | | A QV4Sequence can be converted back to its underlying container; we therefore should give the conversion of QV4Sequence to container a high score if metaTypeForSequence and the target metatype agree. This has a larger effect in Qt 6 than in Qt 5, as we now can have new sequence types for any (QMeta)Container. Fixes: QTBUG-87616 Change-Id: I2bf02ebadbf9b707719d09edaf14b112eb2caf4f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Handle QProperty inside bindingsFabian Kosmale2020-09-211-1/+1
| | | | | | | | | | | | | | | | | | | If we have a binding containing QProperties, and the binding target is an old style binding, still we have to trigger an update if any of the captured properties changes. We cannot reuse the QQmlJavaScriptExpressionGuards as those depend on Qt's signals, and a QProperty is not associated with a change signal in the general case. Therefore, we introduce a new list of QPropertyChangeHandler, which when triggered cause a reevaluation of the binding. As an optimization, we skip the whole capturing process for QQmlPropertyBinding, as that one already takes care of updating itself. Reverts 845bbb99a41a3e4f05c2b3d05d6db748c825dca0 (because skipping the capture is only possible when _both_ the bindee and the property in the binding are QProperty based.) Change-Id: Iafed2a41dcd708bcc33912ce810d803949379c63 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Don't capture bindable propertiesUlf Hermann2020-09-171-1/+1
| | | | | | | We don't need notify signals for those. Change-Id: If78329d1c9e98aee3fb9cd028963a881179ba02f Reviewed-by: Lars Knoll <lars.knoll@qt.io>