aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
Commit message (Collapse)AuthorAgeFilesLines
* QQmlComponent::loadFromModule: Improve error handlingFabian Kosmale2024-04-171-0/+8
| | | | | | | | | | | | | | | | | | | | | Most importantly, fix the (attempted) loading of a non-existent inline component: As soon as we have the compilation unit, we can simply check whether the inline component exists via its name. This avoids an assert down the line in beginCreate which assumes that at this point the inlineComponentName has been properly vetted. This also allows us to create a better error message, and to catch the easy mistake of passing a file name instead of a type name to createComponent. Moreover, ensure that we do not claim that the inline component is ready when only the outer component has been loaded – a direct connection to the changed signals followed by a call to create would otherwise yield surprising results. Fixes: QTBUG-124225 Pick-to: 6.7 Change-Id: I6b1860f594a3060653e732b9570cc3bbff0c34a9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Correct license for test filesLucie Gérard2024-03-221-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 Task-number: QTBUG-121787 Pick-to: 6.7 6.7.0 Change-Id: Ib686439e6a61fd3169948dd8a2b51f8fe1ca21b1 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Make loadFromModule compatible with QQmlParserStatusFabian Kosmale2024-03-143-1/+56
| | | | | | | | | | | | ...as well as the private finalizer hook. Given that QQmlComponent::loadFromModule creates the object through the QML engine, we should support the lifecycle methods, even if we sidestep the usual creation process through the QQmlObjectCreator. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-122076 Change-Id: I2dfe5dd607414df123519d9fccd4178cc5e4cde7 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: Use a multihash to store executable CUsUlf Hermann2024-01-251-0/+36
| | | | | | | | | | | | | | | You can produce multiple CUs for the same URL with createQmlObject() and friends. They need to be marked during garbage collection and therefore the engine needs to keep track of them. With the multihash there can be a lot of CUs of the same URL. Searching through them can take a lot of time. However, there is no point in searching for an existing executable CU if we've just freshly compiled the base CU. So, in those cases, insert directly instead. Fixes: QTBUG-121436 Change-Id: I804dbc74d2ade118f6680a7fbde3f234699ccbc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Make base CU a member of ExecutableCompilationUnitUlf Hermann2024-01-101-1/+1
| | | | | | | | | | | | We want to re-use the base compilation unit across engines. For that to work it cannot be a slice of the engine-specific ExecutableCompilationUnit. Since CompiledData::CompilationUnit is refcounted on its own now, make it unmovable. Change-Id: I8418c9754d7a07e5210c1e7a7fc69355e1d57807 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Prepare tests for upcoming incremental gcFabian Kosmale2023-11-221-7/+0
| | | | | | | | | | | | | | | | | | | | | | 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>
* Add binding order regression test for QQmlObjectCreatorTor Arne Vestbø2023-10-191-0/+28
| | | | | | | | Task-number: QTBUG-98789 Patch-by: Andrei Golubev <andrei.golubev@qt.io> Change-Id: I7516bef7bd88148de5d07e688bd690de1bb8e3c0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Defer automatic Window transient parent until component completionTor Arne Vestbø2023-10-182-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A Qt Quick Window without an explicitly set transient parent will automatically get a transient parent based on its object parent, for example if it's added as a child another Window or Item in a QML document, or if a parent is passed to Qt.createComponent or Qt.createQmlObject. The logic to handle this was spread out through the various places that Window objects were added to a QML document or created, making it hard to maintain or extend this logic. The logic is now centralized in a single updateTransientParent() function in QQuickWindowQmlImpl, that's triggered on component completion, and whenever the conditions for the automatic transient parent change after that. This allows us to extend the logic to not apply automatic transient parent when we add support for real (non transient) child windows later. The machinery relies on new optional behavior in QObject to send ParentChange events whenever the parent of an object changes. Another issue with the previous approach was that it was doing synchronous QWindow::setTransientParent() calls whenever one of the conditions were met, which in some cases resulted in overriding the explicit transientParent set declaratively by the user. This was an issue because setting the transient parent to null was the documented way to opt out of one of the implicit behaviors of a Window with a transient parent, namely that it defers its visibility until the transient parent has been made visible. As we now defer the transient parent magic until the component has been completed, we know whether the user has set the property explicitly, and can bail out of the magic if so. As the deferred visibility of a Window was closely tied to the transient parent logic, this logic has been refactored as well, attempting to keep the two machineries as decoupled as possible. As part of this refactoring the logic to warn the user if conflicting visibility properties is detected has been factored into a separate function. The tst_qquickwindow::attachedProperty() needs a tweak, as it was was relying on the secondary window not being transient, which was the case prior to this patch because we failed to catch the case of Window properties in our auto-transient-parent machinery: Rectangle { property Window someWindow: Window {} // someWindow is now transient to the // rectangle's window. } Now that we correctly handle this case, the check for qWaitForWindowActive() was not sufficient to ensure the Window.active property was true, as transient child windows are active if their transient parent is active, and we would not end up spinning the event loop at all, which is required for the binding to update. To solve this we now explicitly mark the test window as not having a transient parent. [ChangeLog][Qt Quick] Declaring Windows via dedicated properties of another Window or Item will result in an automatic transient parent relationship to the parent Window or Item, just like declaring it as part of the default data property. Task-number: QTBUG-116188 Change-Id: Ia1138391d57b64838cebea4bc0a97fbfdf022772 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qqmlcomponent: Clean up memory managementAmanda Hamblin-Trué2023-08-011-12/+6
| | | | | | Task-number: QTBUG-115222 Change-Id: I1472bc38f261ec357b7a3c2d36116b76fca07867 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Do convert objects with prototypes to QVariantMapUlf Hermann2023-07-272-3/+21
| | | | | | | | | | | | | | | | While we shouldn't convert to QVariantMap if only QVariant is requested, we should convert if QVariantMap is explicitly requested. QVariant can hold QJSValue which is a better fit for objects with properties. QVariantMap cannot hold QJSValue. A best effort conversion is still better than an empty map. Amends commit 47678c682f168eb6d5020383ea75fe1700e8c4f6. Pick-to: 6.6 6.5 Fixes: QTBUG-115523 Change-Id: Iaa96809ee411dc0db95311c641c4e3f1f51a6026 Reviewed-by: Amanda Hamblin-Trué <amanda.hamblin-true@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove redundant warningAmanda Hamblin-Trué2023-07-051-1/+1
| | | | | | | | | | | | | | | We already have a generic warning for assigning null to properties that don't support it, so we warn twice. Removed redundant warning so that we only warn once. This partially reverts commit 16aff415a44f5f10c5ac95da72559839305c8ae5. [ChangeLog][QtQml][Important Behavior Changes] Assigning null to a property of incompatible type is now an error instead of a warning. Fixes: QTBUG-102980 Change-Id: I739913ab64628376727b751512717eb4bf7ea5f4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Make qml tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the follow script: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: Ia68c9d263e7454f0c4a26c29b10f1c535d08e2f6 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
* QQmlComponent: Remove pending QProperty bindings in old createObject()Ulf Hermann2023-05-122-1/+22
| | | | | | | | | | | | | When calling the QQmlV4Function overload of createObject() we end up in a different code path. The problem is the same, though. Amends commit ef6e9f6b75848dfdacdd98cf9e7530f651b3dfca. Pick-to: 6.5 Task-number: QTBUG-99363 Change-Id: I6341243b75d9db1e0fcb80d8d73dab6932d85fd2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Value types: Prefer assigning bindings instead of convertingFabian Kosmale2023-05-092-1/+19
| | | | | | | | | | | | When we're assigning a QJSValue to a value type property, we must first check whether it is a binding created by Qt.binding. In that case, we should directly set that binding up. Going through the conversion code path might not necessarily fail, but might instead yield nonsense. Pick-to: 6.5 Fixes: QTBUG-113472 Change-Id: If91e0843f0caf36c96b4c811b9ce8076adfc984f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Don't try to convert objects with prototypes to QVariantUlf Hermann2023-05-093-0/+27
| | | | | | | | | This is likely to lose some properties. Pick-to: 6.5 Fixes: QTBUG-106266 Change-Id: Ib5a2567d61635a5cf7b3abee7cfef0c073d59e63 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlComponent: Remove pending bindings when setting propertiesUlf Hermann2023-05-062-0/+32
| | | | | | | | Pick-to: 6.2 6.5 Fixes: QTBUG-99363 Change-Id: I2c731ec0b8c5947192accdeb5ef52903d9c7cd90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Check CU for null on isBound()Ulf Hermann2023-03-171-0/+14
| | | | | | | | | | | If the component has an error or was clear()'d its CU will be null. Since isBound() is a public method, it should take that into account rather than just crash. Pick-to: 6.5 Change-Id: I4a3e7417da3c87f6ce7dbb615f984815bc2b0b0b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
* Replace AUTO_RESOURCE_PREFIX with Qt CMake Policy in examples, testsAmir Masoud Abdol2023-02-211-1/+2
| | | | | | | | | | | | | | | | Every instance of AUTO_RESOURCE_PREFIX has been replaced by either qt_standard_project_setup(REQUIRES 6.5) or with qt_policy(SET QTP0001 NEW), mainly in tests. In addition, I added a warning message for the case where AUTO_RESOURCE_PREFIX is used. Pick-to: 6.5 Task-number: QTBUG-96233 Change-Id: I323a15e9d0bb5fe6ba649365314af9fc2ad67bda Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
* loadFromModule: Properly handle QML only modulesFabian Kosmale2023-02-024-0/+16
| | | | | | | | | | | | | | | QQmlMetaType::typeModule only returns a sensible result for modules with some C++ integration. That is not the case for a pure QML module (qmldir put into an import path). Detect the missing module case by instead checking whether addImport failed to handle the module (either returning false, or returning true but with unresolved imports). Fixes: QTBUG-110882 Pick-to: 6.5 Change-Id: I7b25e225e1a34ec91f7ce4d9f4a182a24168ba47 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-271-1/+0
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Retire the qt_parse_all_argumentsAmir Masoud Abdol2023-01-201-2/+2
| | | | | | Task-number: QTBUG-99238 Change-Id: Ia11c9cbd7c06347319ab3674ec0cd8da0214747e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QQmlComponent: Do not load qrc file paths as file:// URLsUlf Hermann2022-12-153-1/+23
| | | | | | | | | Otherwise we hit a strange code path that omits the AOT compiled functions. Pick-to: 6.5 Change-Id: I2ecc4387f8d5e8025aa8f8b32f1ee22e2edc66ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix two "could be override" warnings in tst_qqmlcomponent.cppEdward Welbourne2022-12-071-2/+2
| | | | | Change-Id: I05f991d27f6895805306ed610f0936965e7854e1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlComponent/QQmlIncubator: Support C++ based typesFabian Kosmale2022-11-231-0/+24
| | | | | | | | | | | | | | | | QQmlComponent has a create overload which takes an Incubator. While there is not really any work that could be done in an asynchronous with a C++ based types (there are no sub-QML components, and there are no bindings to set up), we still have to accommodate them in that overload (otherwise we'd crash due to the missing compilation unit). Add support in QQmlIncubator for this case, and call the newly introduce function in QQmlComponent::create. Task-number: QTBUG-97156 Change-Id: I64e3c6958117920dca214eee633424de94b492db Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponent::loadFromModule: Support inline componentsFabian Kosmale2022-11-103-1/+18
| | | | | | | | | | | | | | | | | | | | | | | QQmlComponent already has support to load sub-objects in a QML file (which is necessarry for the QtQml Component type). We repurpose the same code path to load inline components. However, we need to remember that we are dealing with an inline component (instead of a Component), as the QmlObjectCreator requires a specific flag to correctly instantiate the inline component in that case. Everything else is however handled by calling QQmlComponent::load with the URL of the outer type. Except for one additional gotcha: The QQmlType of the inline component might only contain a placeholder id if the outer component has not been loaded so far (as we cannot possibly know the object's id inside the file without compiling it). To get the correct id, we force synchronous loading if we detect that we've gotten a placeholder type (id <= -2). In the future, we might want to remember either the URL or the QQmlType to avoid forcing a synchronous load. Then we could set "start" to the correct object id in beginCreate. Change-Id: I20209e9389d0a64d2a07c2fb1bc9cbc430668040 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponent::loadFomModule: handle required propertiesFabian Kosmale2022-11-101-1/+0
| | | | | | | | | | | | | | Add support for handling required properties in types created via QQmlComponent::loadFomModule which are backed only by C++. We check all properties in the QQmlPropertyCache for their requiredness; we could also attempt this via the QMetaObject, but the assumption here is that for a QML object we want the property cache anyway in the near future. Reducing the size of the ConstructionState which now stores the RequiredProperties is left as an exercise for another commit. Change-Id: I2e6f67f809ac2cbddbe2b28614ed98cee066fc61 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Long live QQmlComponent::loadFromModule!Fabian Kosmale2022-11-103-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | loadFromModule is conceptually similar to loadUrl, except that it does load the Component from a QML module URI and a typename instead of an URL. One big difference is that it allows loading types registered in C++, which is not possible via URLs, as those types do not have any. The implementation piggy-backs on the existing functionality of the QQmlTypeLoader: We first add the URI as an import. Then we resolve the QQmlTypeModule matching the URI. For a C++ registered type, we can already find the existing QQmlType there. As we don't store the QQmlTypes for composite types theree, we might however not find the type, even if it exists. To handle that case, we then use QQmlImports::resolveType. This is not too costly, as import and module resolution get cached. For composite types, we then retrieve their URL, and simply fall back to loadUrl. This could be optimized, but is done in the simplest way for now. For C++ registered types, we store the QQmlType in the component instead. Doing that allows us to use QQmlType::createWithQQmlData in QQmlComponent::beginCreate. Compared to loadFromUrl there are a few additional failure modes: attempting to load singletons, querying non-existing modules, or asking for non-existing types in a module. Those all result in component entering an error state. The API ignores revisioning – it is questionable whether we want to support it, or if we can live with only resolving to the latest version. Adding support for it at a later point would be easy; one would simply need to pass a QTypeRevision through the various APIs. There are two remaining tasks after this patch: We do not validate required properties for C++ types with this approach, and we cannot load inline components. Both will ba addressed in follow up patches. Task-number: QTBUG-97156 Change-Id: If3ed74a499f49c668524d917089a0c237c4ddaf8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-4/+4
| | | | | | | | | | | | | | | | | | | | 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>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-071-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-281-1/+1
| | | | | Change-Id: I1cd769f85d5f82c43639d6787d98e536619249e6 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-081-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Do not store instantiation errors in QQmlComponentAndrei Golubev2022-06-302-1/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QQmlComponent::createWithInitialProperties() allows to pass non-existent properties to create the object with. In this case, we still return a valid pointer (pre-existing), however, the state of the component is affected: there are errors internally that fail repeated calls even with valid properties specified. Fix this, aligning to the behavior of QQmlComponent::createObject() which is a QML counterpart of the same function (to a degree) Additionally, make required properties warnings also not break the component state: if a required property is not set, we return nullptr instead of object. The error state is affected but it gets cleaned on the next creation call, allowing one to set the missing required properties Unify the logic (with slight deviations) between create() (the non-incubator-accepting version), createWithInitialProperties() and createObject() as all they all should do roughly equivalent things [ChangeLog][QQmlComponent][Important Behavior Changes] Setting properties via createWithInitialProperties() and setInitialProperties() no longer affects the QQmlComponent's error state unless there are unset required properties. A warning is issued when a property could not be set. Fixes: QTBUG-101439 Change-Id: I814c00bc3715d7a54004c3fcd0af6ee6d50b0726 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Show QJSValue::toMap() is a valid input for createWithInitialPropertiesAndrei Golubev2022-06-151-0/+26
| | | | | | | | | | Add a tst_qqmlcomponent test dealing with QJSEngine originated dictionary converted into a QVariantMap. QQmlComponent should be able to correctly handle such cases Task-number: QTBUG-101440 Change-Id: I1550dbf28a1ae1eee5473914515f1bf46f8d788a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | 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>
* QML: Add an option to bind components to filesUlf Hermann2022-05-234-0/+76
| | | | | | | | | | | | | | | If a component is bound to a file context, we can be sure that the IDs present in the same file will be accessible to bindings and functions inside the component. We will need this to allow such bindings to be compiled to C++. [ChangeLog][QtQml] You can now bind components to a file scope. This way you can make sure IDs in the file are accessible to the components. Task-number: QTBUG-101012 Task-number: QTBUG-102806 Change-Id: I290a61752b4b02e13f0bb0213ba3f871bdb95260 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-291-12/+14
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Android: various test fixesAssam Boudjelthia2022-03-021-1/+2
| | | | | | | | | | 2nd round of test failures fixes for Android. Mostly resource bundling related issues still. Pick-to: 6.2 6.3 Task-number: QTBUG-97056 Change-Id: I2fac0710a7b5528fcef4480babd0cbf749e488b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow custom named value types in QMLUlf Hermann2022-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | You can now add your own, lower-case named, value types to your own module, and use them in QML. Previously the names had been ignored, but now you can actually declare properties using the value types. The QtQuick value types are now handled exactly this way, and their special casing at compile time is removed. [ChangeLog][QML][Important Behavior Changes] You can now add your own value types to QML modules. This works exactly like the registration of object types, just with Q_GADGET instead of QObject/Q_OBJECT. In turn, the QtQuick value types are only available from QtQuick now. Previously you could declare unusable properties of QtQuick value types when only importing QtQml. This is not possible anymore. Task-number: QTBUG-82443 Change-Id: I5b2e867141244531cb13d789678fb7e06a6e41e7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qmltc: Support Component rootsAndrei Golubev2021-12-272-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | It is a very special case that doesn't undergo a normal compilation but instead just uses QQmlObjectCreator::createComponent() logic. As QQmlObjectCreator::createComponent() returns a new QQmlComponent, we can't use it within the qmltc-generated type's ctor. Instead, just fake the same flow by incorporating the code into the qmltc type setting As a drive-by, fix the code to work correctly with Component roots. This should now pretty much cover all the mystical logic of QQmlComponentAndAliasResolver and, with tests, we can safely simplify the qmltc code generator bits later without introducing bugs Enhance tst_qqmlcomponent::componentTypes test to highlight that property Component p: ComponentDerivedType {} is not marked with QV4::CompiledData::Object::IsComponent flag at all and thus considered to be an ordinary object binding, unlike property Component p: NotComponentDerivedType {} Pick-to: 6.3 Change-Id: I4ec41952d15f9659d316e44dab4050aa4908327c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* qqmlcomponent: Test interesting Component-based typesAndrei Golubev2021-12-233-0/+71
| | | | | | | | | | | 1) we do not allow "empty" Component objects 2) explicit components leak ids when used in implicit component setting (unlike non-components) As of now, just "document" this behavior by adding an extra test Change-Id: I42346217c2d6aed661c2e58d4c01a580c89a1fae Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Test that a signal is created for QML property when using QQmlComponentAndrei Golubev2021-11-161-0/+18
| | | | | | | | | | This is the current behavior and it does not seem to be tested Whoever decides to change the behavior should likely also update this test then. For now, let's use it as a reference Change-Id: Id6952238cae7548fba1f2d907f681ffb8f1e99c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Provide a non-QQmlV4Function version of Component::createObject()Ulf Hermann2021-10-213-0/+63
| | | | | | | | | | | | | | It actually just takes a parent object and a list of parameters, both optional. We don't need varargs for that. It now warns if you pass more parameters, but that is a good thing. As the QQmlV4Function variant accepts a number of questionable values in addition to QObject* and QVariantMap, we need to retain it. Change-Id: Id39c07b890e4d2964ddb2cc498f56f2fe483e887 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Improve type conversions from/to QJSValueUlf Hermann2021-10-201-0/+39
| | | | | | | | | 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>
* Fix required properties detection in QQmlObjectCreatorAndrei Golubev2021-09-227-24/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the type comes from QML (either because it's invalid - defined in another document/compilation unit OR because it's an inline component), it means that our instance has a QML-originated base class. That class might have bindings on required properties (making them initialized). If those properties come from some more-distant C++ base type, they'll be in the propertyCache of currently processed type (in one of the parent caches), but we must not include them into the sharedState->requiredProperties as we lack the bindings from the QML-originated base class (so we may accidentally see uninitialized required properties that were actually initialized, just in a parent QML document). So: only consider own properties in such case, leaving the handling of parent-and-own properties to the first QML-defined type that has an immediate C++ base class - since we use sharedState to collect required properties, this'll work fine across different (sub)creators The only problematic case is when attached and group properties are involved. We need to decide what to do with them (maybe just leave the old logic for simplicity) While fixing the behavior, also update places that used propertyCount() implementation without using the function itself Pick-to: 6.2 Fixes: QTBUG-96200 Task-number: QTBUG-96544 Change-Id: I28f45037790faddaa1b2f07e78544839f60563c7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* tst_qqmlcomponent: add more tests for required propertiesAndrei Golubev2021-09-2222-3/+257
| | | | | | | Pick-to: 6.2 Task-number: QTBUG-96200 Change-Id: I4813c6c91195fade36ce6df7ebd0f691f5cacda8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Consolidate test helpers into private librariesMitch Curtis2021-09-132-7/+4
| | | | | | | | | | | | | | | | | | | | 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>
* Add some more verbose output to tst_qqmlcomponentUlf Hermann2021-07-021-3/+5
| | | | | Change-Id: Ibef76a641c50697c60842934c8bead5a5b04e2f7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlComponentPrivate::setInitialProperty: improve error messageFabian Kosmale2021-04-271-1/+1
| | | | | | | | | We can discern between the case where the property does not exist at all, and the case where we cannot set it. Pick-to: 6.0 6.1 5.15 Change-Id: Ia2e8f4cc077a00b90d720db01bff1542a812dea0 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Mark overrides in tests, fix compiler warningsVolker Hilsheimer2021-04-011-1/+1
| | | | | | Change-Id: If753558d911e50a73e351a93eed2e4df3e6592c7 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>