aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QV4 garbage collection: Allocate white during gc runFabian Kosmale2024-03-051-5/+2
| | | | | | | | | | | | | Now that we properly employ the WriteBarrier, we no longer need to use black allocations. This reduces the amount of floating garbage, and avoids potential bugs with heap classes like QV4::MemberData where we rely on it being marked so that its constituents don't have to be protected during initialization – which would fail when we it is already black, as it wouldn't be pushed on the MarkStack afterwards. Fixes: QTBUG-121910 Change-Id: Ie5e0f9461fa5c0e4a293da3d3c978da73743e417 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Correct license for test filesLucie Gérard2024-02-271-1/+1
| | | | | | | | | | | | | | According to QUIP-18 [1], all test files should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I26d72e8de04d4c7c57b3b7838af5d033265de5ba Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Do not call signal handlers on half-deleted objectsUlf Hermann2024-01-171-0/+18
| | | | | | | | Pick-to: 6.7 6.6 Fixes: QTBUG-121022 Change-Id: Icdefd6bef4906700d88eca47c09d0abe54f1eec9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Prepare tests for upcoming incremental gcFabian Kosmale2023-11-221-40/+20
| | | | | | | | | | | | | | | | | | | | | | This commit: - Introduces helper functions gcDone and gc. gcDone simply returns true as the gc is currently not incremental. gc is a helper method which has been copied into various tests already, which runs the garbage collections and sends events to clean up objects scheduled for deletion. The new helpers are placed in qmlutils.cpp. - It adds a flag to gc which allows not sending the posted events. That allows using gc in more places, while highlighting the fact that we don't want to process events at this point. This will also help upcoming changes to the incremental gc, which by default will use the event loop to drive the gc processing - It moves some gc calls from QML to C++ – this again will help later to ensure that the gc actually has completed As a driveby, the logging rules early in tst_qv4mm are reset earlier. Task-number: QTBUG-119274 Change-Id: I75d6ffcb3aa459b020e8257155faa91c39653d43 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Detect slot object if explicitly providedFabian Kosmale2023-11-151-0/+112
| | | | | | | | | | | If explicitly context is given to function when connecting, it is used as the receiver. Then when the context is destroyed, the connection will also be cleared. Pick-to: 6.6 Fixes: QTBUG-29676 Change-Id: Iec9318132245094603f71e3e6279d65c8021cb7e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlProxyMetaObject: Forward objectDestroyed to parentTor Arne Vestbø2023-10-201-0/+25
| | | | | | | | The parent might have a different implementation of objectDestroyed than QDynamicMetaObjectData, for example not deleting the object. Change-Id: I7420ea577d9dc76bc13d11c54b6e0004205f13af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix regression on singletons where declared != actual typeFabian Kosmale2023-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | For singletons, we can't rely on the static meta-object of the registered type, as the create function used for a singleton might return an instance of a derived type instead. This could lead to crashes or method-overload resolution failures later on. Fix this by always querying the actual meta-object of the singleton, instead of relying on the meta-object of the registered class. Leave a comment about the fact that we still have an issue if you have a derived instance of the registered type when you additionally extend the type. However, that is pre-existing (given that it only affects QQmlType itself). Fixes: QTBUG-117891 Pick-to: 6.2 6.5 6.6 Change-Id: Ie12b4c886ace5cc58a5ded59fa48bc425ae58419 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace signal name manipulations with QQmlSignalNamesSami Shalayel2023-08-151-14/+1
| | | | | | | | | | | | | | | Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyBinding: Correctly link observers after undefined valued bindingFabian Kosmale2023-07-281-0/+17
| | | | | | | | | | | | | | | | | Calling both setObservers and prependObservers doesn't make sense: setObservers is for the case where we don't have a binding, but obviously we do have one here. Note that the test case still passes even without the fix - it will however cause a memory leak which can be detected by ASAN. The leak is fixed by this patch. Fixes: QTBUG-115251 Pick-to: 6.6 6.5 6.2 Change-Id: I4b420e05f49acf764da6a05af522390005276f49 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QML: When marking a QObjectWrapper, also mark its const counterpartUlf Hermann2023-07-261-0/+24
| | | | | | | | | | | | Otherwise the const wrapper will be swept while the object should still be alive (and vice versa). Amends commit d3b3fef5a878d7fd53de6a9f9fff196a273930e3. Pick-to: 6.6 6.5 Fixes: QTBUG-114596 Change-Id: Ib4d8e9f805a229a471ca72f5ff357e3a4c9999a5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Un-specialcase QStringList and QVariantList conversionUlf Hermann2023-06-301-1/+7
| | | | | | | | | | | | | | | | | | Those are just regular sequences these days. They can be written back. Drop some now-dead code and deduplicate the value type conversion code in the process. We should try the (more common) value type conversion before the sequence conversion, but after all the "simple" conversions. [ChangeLog][QtQml][Important Behavior Changes] Converting a QVariantList to a QJSValue via, for example QJSEngine::toScriptValue() does not produce a JavaScript array anymore, but rather a better suited sequence object that behaves almost like a JavaScript array. The only difference is that its QJSValue::isArray() will return false now. Fixes: QTBUG-113690 Change-Id: Ib176c34d59c45a6b5cff68d029c4b1b87d7aa192 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyBinding: Do re-attach observer after handling undefinedUlf Hermann2023-06-281-0/+12
| | | | | | | | | | | | As noted in the comments above, we need to restore the binding to its original state after resetting the property. This includes re-adding any observers. Pick-to: 6.2 6.5 6.6 Fixes: QTBUG-114874 Change-Id: I2113a59f1bed59753c77ca3e0b00fed4c0487584 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* ListProperty: Document faulty index-assignment on gadget list propertiesOlivier De Cannière2023-06-161-2/+24
| | | | | | Task-number: QTBUG-113690 Change-Id: I2816f55b501ee9192cedf5e4b108ac498cbcae35 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Fix overload resolution for QObject* typesUlf Hermann2023-06-091-0/+32
| | | | | | | | | Amazingly, QObject pointers were not supported at all so far. Pick-to: 6.5 6.6 Change-Id: I61b28705d3bebf9602bdeee05aadcb085f39b184 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Disable flaky test in tst_qqmlecmascriptUlf Hermann2023-06-051-5/+8
| | | | | | | | | | Since structured value types can be created from any object (even if none of the properties match), this test doesn't test anything anymore. The explanation is still valuable, so let's keep the code commented. Pick-to: 6.5 6.6 Change-Id: I890204811a522f025fb114f51e57c1dd4a951a57 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix reset support for value typesFabian Kosmale2023-05-121-0/+16
| | | | | | | | | | | | | | Our value type refactoring in 6.5 broke reset support for value types when that write happens through virtualPut. Fix that by checking whether the value we're assinging is undefined before attempting any conversion, and reset the gadget in that case (if it is actually resettable). Task-number: QTBUG-113473 Pick-to: 6.5 Change-Id: Ifaa2d045f718fc3cb2d5e75b3626b41175ac3a3b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* QQmlObjectCreator: Do not crash on read-only bindableUlf Hermann2023-01-051-0/+18
| | | | | | | | | | | If the binding was not actually set (because the bindable is readonly) then it's dead after the pop_front. We cannot examine it anymore, and we don't have to. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-109597 Change-Id: I3bf0ca501aa9ad45a64ad181b685ca6d9d325231 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlObjectCreator: play nice with grouped propertiesFabian Kosmale2022-12-151-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | If an object tries to set up a grouped property binding of the form complex.subprop: primitiveValue when complex is declared in a base element, and the setup of it is done in base, then we so far would get an error about complex being null. The reason for that is an optimization which only sets up bindings shortly before object creation concludes (to avoid spurious reevaluations during construction). Because setting primitive value "bindings" happens however without delay, we end up with the case of attempting to set up the value of a non-existent object. To fix this we check if there is a binding which might provide the object, evaluate it at that point, and to then re-read the outer property of the group. As a drive-by, add missing QT_{BEGIN,END}_NAMESPACE macro to qqmlanybinding_p.h. Otherwise, the namespace build (finally) fails to compile. Pick-to: 6.5 Fixes: QTBUG-108102 Change-Id: Ifdac1948100b369a49c0a5ecff75f881fd63540e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Route Qt::TimeSpec usage via QTimeZoneEdward Welbourne2022-12-111-20/+26
| | | | | | | | QTimeZone now packages Qt::TimeSpec details, unifying QDateTime APIs. Task-number: QTBUG-108199 Change-Id: I4a6bfaa213ec6db2fb357d20c7cd59e8c58ad103 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4qobjectwrapper: return false on failed argument conversionSami Shalayel2022-12-021-0/+77
| | | | | | | | | | | | | | | | It was possible to call c++-methods (either invokable or as slot) with wrong arguments, which caused a crash. The reason was that CallMethod(...) converted something to a QObject without checking if it was an actual QObject. The wrongly typed argument would end up reinterpret_cast'ed into another type for the call, which leads to segmentation fault when accessing the argument in the function. Added a test where an int tried to be reinterpret-cast'ed into a QFont. Pick-to: 6.4 6.2 Fixes: QTBUG-108994 Change-Id: I8c45c9124411ad3fd100faed0b03390843f7d034 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Introduce type based overload of Qt.createComponentFabian Kosmale2022-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Add type based createComponent overloads based on QQmlComponent::loadFromModule. They provide a way to instantiate a component by its type, specified by a URI and typename pair. This enables creating Components for inline component types and C++ only types. Support for directly passing the type is deferred to a later commit, as it needs some care to work together with the compiler. As the string based overload matches a mistaken call to the URL based createComponent with parent and mode swapped (due to anything being convertible to string), we add a check to detect this specific error case and give a helpful error message. [ChangeLog][QtQml] Qt.createComponent now supports creating a Component from its module and type name (passed as strings). Task-number: QTBUG-97156 Fixes: QTBUG-26278 Change-Id: I89e7430fe02d52f57230bfa1b0bfbcbfd0ead4b7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-82/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-16/+16
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Make ExecutionEngine::toVariant() staticUlf Hermann2022-09-201-1/+1
| | | | | | | | | Wherever we need an engine in there, we also have a managed value to get it from. This relieves us from the requirement to drag an engine around wherever we want to call toVariant(). Change-Id: Ib95d02b5fbf5eaa494214e337c9b700e97e5e0df Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix alias to inline component typeFabian Kosmale2022-09-081-0/+19
| | | | | | | | | | | | | | | | | | When we create an alias property, we resolve its targets metatype. In the case of inline components of the same file, that's however not possible via QQmlType, as the type will only be available once the outer type has been fully set up. Fix this by looking up the type in the ExecutableCompilationUnit, where the information is available while the type registraiton process is still ongoing. As a drive-by, also set the alias flag correctly when constructing the QMetaObject of a QML element. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106392 Change-Id: Ie8f55dd0894cc5c8d683dd3c685980878956d3ca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qml: Allow const and non-const QObjectWrappers to coexistUlf Hermann2022-09-071-5/+56
| | | | | | | | | | | | | We can access the same QObject in const and non-const contexts. Both should be possible. Store the const objectwrapper in m_multiplyWrappedObjects. That's somewhat slow, but const QObjects are rather rare. Pick-to: 6.4 Fixes: QTBUG-98479 Change-Id: I047afc121f5c29b955cd833e0a2c8299fc52b021 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Engine: Fix handling of attached objects in function callsFabian Kosmale2022-09-021-0/+20
| | | | | | | | | | | | | | | | When we use an attached object as an argument to a function call, we need to properly extract it from the QmlTypeWrapper. Before this change, we simpley left the argument pointer as null, which lead to subsequent crashes when it got dereferenced. Moreover, treat passing namespaces to functions expecting a QObject as a TypeError, by returning false from CallArgument::fromValue (used to crash for the same reason as with the attached object case). Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-106119 Change-Id: Ifa6a32e20a29935aff1f265eb0edd3e35ea1c11b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Integrate property binding evaluation fix from qtbaseFabian Kosmale2022-09-011-0/+23
| | | | | | | | | | | This is basically the same as QTBUG-105204, only with the QML engine being involved. Fixes: QTBUG-104982 Pick-to: 6.4 6.3 6.2 Change-Id: I5afaadedcd7af41198702a8f2331703b4f6ef2e7 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Mark InternalClass parents when running GCUlf Hermann2022-08-031-0/+11
| | | | | | | | | | | | | | | | We need to preserve them as they notify us about protoId related changes. In order to avoid wasting heap space in case many properties are added and removed from the same object, we put a mechanism in place to rebuild the InternalClass hierarchy if many redundant transitions are detected. Amends commit 69d76d59cec0dcff4c52eef24e779fbef14beeca. Pick-to: 5.15 6.2 6.3 6.4 Fixes: QTBUG-91687 Task-number: QTBUG-58559 Change-Id: I3238931b5919ed2b98059e0b7f928334284ce7bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix array-like methods on V4 sequencesUlf Hermann2022-07-191-6/+8
| | | | | | | | | | | | | We need to properly convert value type lists on assignment and we need to add the "length" property to the own properties. Furthermore, the V4 sequence methods were confused about integer type ranges. We teach them about qsizetype, properly range check everything, and drop the artificial limitation to INT_MAX. Pick-to: 6.4 Task-number: QTBUG-82443 Change-Id: Ie5af1130c9e78e412c171e6fa26a28a6a7a5d498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* UrlObject: Add colon after schemeLeticia Valladares2022-07-141-4/+56
| | | | | | | | | | | | | This change adds a colon after scheme in methods 'setProtocol' and 'setUrl' on its protocol line. Likewise, this includes a test called 'colonAfterProtocol' to check if colons were correctly added by using different schemes: ftp, http and https, or if colons were removed when setting the scheme (i.e. from protocol 'ftp:', 'ftp:http:' or 'ftp:::' to 'ftp'). Fixes: QTBUG-103746 Change-Id: I8f847bedd23e476e0ae7901a2f3f3963da3ca04d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML engine: Let string match QUrl during overload resolutionFabian Kosmale2022-07-121-0/+14
| | | | | | | | | | | | | | | If an overload set contains a function with a QUrl parameter, and we pass in a string, that would have resulted in the worst-possible score of 10 for that function. Given that URLs are often provided as strings in QML for convenience (instead of using e.g. Qt.url), that is arguably a bad idea. Starting from this commit, they'll get a score of 6: QJsonValue still wins (to minimize the risk of breaking existing overload sets), but we no longer claim that there is no match at all for such a parameter. Change-Id: Ic0faa0029c9d5f14aff143cbd7fd4859d9ac2b2a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-28/+3
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-291-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Generalize QQmlAbstractBinding::isValueTypeProxy()Ulf Hermann2022-04-251-1/+1
| | | | | | | | | Instead of a bool we can just return an enum of the actual kind. This way all the checks become more readable. Furthermore, we can eliminate a dynamic_cast without sacrificing readability. Change-Id: I8a38687f9b796cd47196a6ab0385624c737e4435 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4 Date: Support another nonstandard date format QDateTime has droppedUlf Hermann2022-02-031-0/+3
| | | | | | | | | | | Amends commit 43eaa77e8ed03153335c0002dcc8b660c39a0beb. Fixes: QTBUG-100377 Pick-to: 6.2 6.3 Change-Id: I01028bd991b8a64bd9dcad31ce90536d83dad0a1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Rename "Basic Types" to "Value Types"Ulf Hermann2022-01-211-4/+4
| | | | | | | | | | Internally they've been called "value types" all along. Now that we are adding the ability to define your own value types the "basic" name is not really fitting anymore. Value types can be quite complex. Change-Id: I5fb4abec1dd2f0bbf7fb7f08b02db0882490e983 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmltypecompiler: Be conservative in enum optimizationFabian Kosmale2021-11-261-0/+1
| | | | | | | | | | | | | | | | | | QQmlEnumTypeResolver constains logic to find enumerations in bindings and turn those bindings into simple integer bindings. However, that logic got confused when we had a complex expression (as in, not only an identifier but any compound expression). Instead of trying to create a mini-expression parser, we opt to be more conservative in the analysis and reject anything that does not look like one or more identifiers separated by dots. The use case of optimizing simple arithmetic operations involving enums in bindings is left to qmlsc. Pick-to: 6.2 Fixes: QTBUG-98311 Change-Id: I6f8c3fa2a2712dabdea035e2447d52c415ebfc3f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QML/JS: Reject yield expression not directly in generator functionsFabian Kosmale2021-11-181-0/+14
| | | | | | | | | | | If an inner function contains a yield expression, we need to reject the program even if that function is inside of a generator function. Fixes: QTBUG-98356 Pick-to: 6.2 5.15 Change-Id: I2e820a1ca5f0da4080e313fd9809aa8bfdc1b681 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Handle function as default arguments in toplevel functionsFabian Kosmale2021-11-101-0/+11
| | | | | | | | | | | | | | | | | | | | | Top level functions, that is, those directly defined in a QML component as opposed to those defined inside another function or class, are not visited directly by the ScanFunction visitor. Instead, they are manually considered in generateJSCodeForFunctionsAndBindings, and the visitor is then run on their body. This worked mostly fine, with one notable exception: In case there is a function expression used as the default value of a function parameter, that function would have never been visited. This would lead to subsequent asserts/crashes in the codegen, as the function was not properly set up. We fix this by manually visiting the function's formals in addition to the body. Pick-to: 6.2 5.15 Fixes: QTBUG-98032 Change-Id: I5cb4caae39ab45f01a0dfa1555099d7d4b796a19 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow ImmediatePropertyNames in addition to DeferredPropertyNamesUlf Hermann2021-10-281-0/+56
| | | | | | | | | | | | | | If given, all properties but the ones mentioned in ImmediatePropertyNames are deferred. Also add some warnings related to DeferredPropertyNames being ignored in some cases. Finally, scanObject() can return false now. Therefore adapt its caller to take that into account. Task-number: QTBUG-95117 Change-Id: I1e696228de7ad3b495bf7791fdb014768aff4c96 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QV4::QObjectWrapper: Improve overload resolutionUlf Hermann2021-10-211-0/+41
| | | | | | | | 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>
* Fix autotest private API part compilation for INTEGRITYTatiana Borisova2021-10-111-0/+4
| | | | | | | - process should be used with config check Change-Id: Ie35df508cacb16078face96ef1834a895614a870 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlObjectCreator: Correctly remove overwritten bindingsFabian Kosmale2021-10-051-0/+10
| | | | | | | | | | | | | | | | | | | | | | | For QProperty bindings, we would not explicitly remove bindings that were added and later overwritten. For "complex" bindings, that would cause some unnecessary binding evaluation during object creation. Worse, in the case of a literal binding overwriting a complex binding, we would acutally end up with the complex binding still being there, because the literal binding would result in an immediate write of the value, whereas the binding was only installed at a later point. We fix this by removing the binding from the list of to-be-installed bindings when it gets overwritten. We also now take the IsPropertyObserver flag into consideration when checking whether existing bindings should be removed: IsPropertyObserver is basically the same as IsSignalHandlerExpression, but for QProperty bindings instead of "old-style" bindings. Pick-to: 6.2 Fixes: QTBUG-96668 Change-Id: I2ef00d5b62af4f6fcc71960c38e1f0568b3b9c40 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix scoping of JavaScript function namesUlf Hermann2021-09-291-0/+76
| | | | | | | | | | | | | | | | | | | Function declarations add their name to the outer scope, but not the inner scope. Function expressions add their name to the inner scope, unless the name is actually picked from the outer scope rather than given after the function token. We don't add the name to any scope in the case of functions declared in QML elements because the QML element will receive the function as appropriately named, and typed, property. It is always better to use that one than to use a JavaScript local. This causes some additional ecmascript tests to pass. Pick-to: 6.2 Fixes: QTBUG-96625 Change-Id: I0b8ee98917d102a99fb6b9bd918037c71867a4a5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-131-2/+10
| | | | | | | | | | | | | | | | | | | | Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qqmlecmascript: Test that deferred names gets overwrittenMaximilian Goldstein2021-08-311-0/+12
| | | | | Change-Id: I32d7ba2230dbd98f918e6e55abbe6b3fd43028d2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_qqmlecmascript: Check that parent can defer child class propertiesFabian Kosmale2021-08-261-0/+15
| | | | | | | | | | | It is arguably a bad idea to defer properties which might get defined in child classes, but checking it in the engine would be expensive: We cannot simply check that the property exist, as we might want to defer attached properties. So for now, we add a test to document and verify the behavior. Change-Id: I264b136638c4ecddfa52b6687797cb981d9b531e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_qqmlecmascript: Test that it is possible to defer parent propertiesFabian Kosmale2021-08-251-0/+14
| | | | | | | | | | | This test is meant to narrow down the semantics of the currently underspecified deferred properties. Task-number: QTBUG-95117 Change-Id: Iee6b9d4caea1a248cf5c2d6773e12a314c01bae7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>