aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
Commit message (Collapse)AuthorAgeFilesLines
* QtQml: Properly null-check module exports when iteratingUlf Hermann41 hours1-2/+2
| | | | | | | | | | | | | We construct the iterator from the exports of the module in all current code paths. Therefore, this case can't happen in the current code. Still, the fact that we have a branch that throws a reference error there tells us that it's intended to work on other collections of names, too. Let's complete the check and also check for nullptr since resolveExport can indeed return that. Coverity-Id: 486706 Change-Id: Ieaf3996e76265e9e6ef59c2168699e47e41e8ff5 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* JSRuntime: Add const correctnessOlivier De Cannière41 hours2-5/+5
| | | | | | Change-Id: I2fc82de562909ab2e0eecfbbe1e2e53953a33756 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Optimize retrieval of string from ValueUlf Hermann41 hours1-2/+2
| | | | | | | | stringValue() already checks isString(). We don't have to do it twice. Coverity-Id: 486710 Change-Id: I074228f9a120c3bbfe6d4a65f05fe11322fbd07b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: std::move strings rather than copying themUlf Hermann41 hours1-2/+2
| | | | | | | | Coverity-Id: 486699 Coverity-Id: 486697 Coverity-Id: 486715 Change-Id: Icdd15ff578f8be55fe9db3ffc38e893f667edc40 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Drop dead codeUlf Hermann41 hours1-2/+0
| | | | | | | | | The propertyList is an array allocated on the JavaScript stack. None of it can be null. Coverity-Id: 486709 Change-Id: I3178181aa89bfff86fb5aa469660a912b4f1691c Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Document QQmlComponent error handling in detailed descriptionMitch Curtis2 days1-0/+9
| | | | | | | | | | | | | | QQmlComponent has two stages where it can produce errors that weren't accounted for in the first example (which is what most users will see first): in its constructor and in create(). Add error handling for these so that users aren't confused when their QML silently fails to load or they get crashes trying to access non-existent objects returned by create(). Pick-to: 6.5 6.8 6.9 6.10 Change-Id: I42d0222a997b3cac01cd191bb076513642f5716d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Deduplicate enum handling in QtObject and clean up APIOlivier De Cannière3 days6-76/+146
| | | | | | | | | | | | | QJSValue is slow and can be avoided. Use more specific types. Also, switch to an exception based error handling instead of returning undefined. Amends 5e312953f6c41f244344bbd05a41f205a8d3f86d, found in API review Pick-to: 6.10 Change-Id: Ie7c304a0dd76c8096e7c1f9b7cc3cfe7471649da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Harden namespacingTim Blechmann6 days9-16/+39
| | | | | | | | | | | | | | | When using namespaced Qt, we need to prevent symbol clashes with symbols of the same name. * namespace some publicly visible classes * hide classes in implementation in an anonymous namespace * rename read/write to readValue/writeValue to avoid name clash with c functions. Task-number: QTBUG-138543 Pick-to: 6.10 Change-Id: Ica77462c1f81f1e01cc60477e5b56ecfe3c1abb4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Improve error message for invalid import qualifierDheerendra Purohit6 days1-1/+1
| | | | | | | | | | | | Previously, the error message for an invalid import qualifier did not show the qualifier name or explain what was wrong. This change adds the qualifier name to the message and says it must start with an uppercase letter. Pick-to: 6.10 Fixes: QTBUG-133313 Change-Id: I0bd4bb143f7b4cdc3b26cae73ab42a4fb05977b1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix invalid access to enginePriv in QQmlIncubatorPrivate::clear()Dheerendra Purohit6 days1-0/+2
| | | | | | | | | Add null check to avoid accessing enginePriv after it is set to nullptr. Pick-to: 6.10 6.9 6.8 6.5 Fixes: QTBUG-138927 Change-Id: I180828066a100465694337c4378139cfd9e4ab06 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* qt_add_qml_module: Support enabling lint target for examplesFabian Kosmale6 days1-1/+12
| | | | | | | | | | | | | | | If QT_LINT_EXAMPLES is set, any target defined below the "examples" folder will add its lint target to the ALL target. Together with a change in CI to actually pass that define down, we can enforce absence of qmllint warning by combining it with a .qmllint.ini file setting max warnings to 0. Pick-to: 6.10 Task-number: QTBUG-108448 Change-Id: I0f4fd1d18221e503d93e3f435bbc47292857ec20 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Deduplicate import finalizationUlf Hermann7 days2-65/+88
| | | | | | | | | We can re-use the same code for file and directory imports. And we can avoid copying a QString this way. Coverity-Id: 486646 Change-Id: Id95226674e382a722527ba3ff6205682ffe1075a Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Assert on currentStackFrame in direct eval callUlf Hermann7 days1-2/+12
| | | | | | | | | | | If we're called directly from a CallPossiblyDirectEval instruction, that instruction must live in a function which must have created a stack frame. Coverity-Id: 486651 Change-Id: I8136f40a8b6058ad499a7fdaaed99bf85485b11c Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix incorrect usage of \generatelistTopi Reinio7 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | The \generatelist command takes an optional argument that affect how the members are listed, for example, `classesbymodule` which creates an annotated list of the classes in a named C++ module. `groupsbymodule` is not recognized or documented. QDoc falls back to generating a list of all members of a group in this case. While the end result is correct, this relies on an undocumented feature that is likely to change and break. Replace these instances with an explicit \annotatedlist command that produces the same output. Pick-to: 6.10 Task-number: QTBUG-138901 Change-Id: Icebe063937cdf1e2ef034b723cce646cd6c96bbe Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Mention all_qmllint in the doc for qmllintOlivier De Cannière8 days1-4/+9
| | | | | | | | | This should help bring more awareness to it for people who already know qmllint. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I60e6c6cd1bcab349587904bce08f66af5aef3d95 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Allow eval() in global contextUlf Hermann9 days1-9/+9
| | | | | | | | | | We don't have to crash if we can't determine a function to query for strictness or if there is no explicit "this" object. Pick-to: 6.10 6.9 6.8 6.5 Fixes: QTBUG-136688 Change-Id: I541f2d906e10a7512d8364a9286885bd6afa4423 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Avoid unnecessary string copyingUlf Hermann9 days3-3/+4
| | | | | | | | We only need to retrieve the qmldir type namespace if it's not empty. Coverity-Id: 482854 Change-Id: I833e1dd1e100442cf2351944203dce18a4fb9f2b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Avoid unnecessary copyUlf Hermann9 days1-6/+4
| | | | | | | | If the qmldir file has no redirection, we don't need to copy any URLs. Coverity-Id: 482855 Change-Id: I8249ffe65b8b62401e8e0593fafa794d5ce862db Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Doc: Create a Getting Started section for the Qt Quick moduleAlexei Cazacov13 days4-0/+628
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit moves the "Building UIs with Qt Quick" tree section to the Qt Quick module as a getting started subtree. Changes: qtquick-debugging.html - moved to concepts/Debugging qtquick-deployment.html - moved to concepts/Deployment qtquick-performance.html - moved to concepts/Performance qml-codingconventions.html - moved to guidelines/Coding Conventions scalability.html - moved to guidelines/Scalability qtquick-qml-runtime.html - moved to the qml module "Use Case" topics moved to Getting Started: Visual Elements In QML -> Visual types Positioners and Layouts In QML -> Positioners and layouts Responding To User Input in QML -> Handling user input Displaying Text In QML -> Displaying text Animations In QML -> Animations Style And Theme Support -> was deleted (it had almost zero useful info) Integrating JavaScript in QML -> Integrating JavaScript in QML Task-number: QTBUG-134130 Pick-to: 6.10 6.9 Change-Id: I14c8e4abadc587fbba788b7ce479c3a8364d0a42 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* qmllint: Introduce UserContextPropertiesSami Shalayel13 days2-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow the user to specify context property names in .contextProperties.ini files so that they can disable all warnings or only the unqualified warning on their defined context properties by name. I remember some use cases where checking the .qmllint.ini into a users project repository is unwanted, so use a new setting file for the context properties that does not mess with global/system-wide .qmllint.ini files when checked into the repository. Create a new class called UserContextPropertiesSettings that is in charge of loading user context properties setting files, and use it inside of QQmlJSLinter. Introduce a ContextPropertyInfo class that contains both the heuristic information and the user-provided information. ContextPropertyInfo is used to pass the ContextProperty information down the type propagator. Also add some documentation for the new settings file. Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: Icd700154dc89219f115fa3187c037d65451d0059 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtObject: Give uiLanguage a signal in addition to BINDABLEFabian Kosmale2025-07-302-1/+6
| | | | | | | | | | | | | | | | | The consensus at contributor summit [1] was that we want to phase out the BINDABLE integration over time. That means that we shouldn't have properties which are BINDABLE but non-NOTIFY-able in Qt itself exposed to QML. Adjust QtObject::uiLanguage accordingly. No revision marker is needed as the global Qt object only exists as a singleton (and is ina private header). [1] https://wiki.qt.io/QtCS25_-_QProperty_and_QBindable Fixes: QTBUG-138749 Pick-to: 6.10 Change-Id: Ice54f844c87864a325e667d2536c39af821ce7b9 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Doc: Remove link to deprecated method QQmlEngine::importPluginKai Köhne2025-07-281-1/+1
| | | | | | | | The method got deprecated in Qt 6.4. Pick-to: 6.5 6.8 6.9 6.10 Change-Id: I8cd380f65b4cd800bbc028b3fbe1aefd98881269 Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* QQmlPropertyCacheCreator: let PropertyCache handle override instead of ↵Dmitrii Akshintsev2025-07-286-26/+24
| | | | | | | | | | | | | | | | | | | Resolver (2/2) Existing handling of `final` using Resolver seems to be redundant unless there are some corner cases, not covered by our tests. For maintainability purposes it's arguably better to keep handling of override logic in one place and inside PropertyCache, which is intended to be responsible for it (see handleOverride). Therefore adjusting PropertyCache::appendAlias to propagate OverrideResult to the upstream calls and use it in QQmlPropertyCacheAliasCreator<>::appendAliasToPropertyCache to throw an error in cases of invalid property override. Change-Id: I7cabd42197b0829dd7fc2965868c5e5287169a40 Task-number: QTBUG-98320 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCacheCreator: let PropertyCache handle override instead of ResolverDmitrii Akshintsev2025-07-284-43/+36
| | | | | | | | | | | | | | | | | Existing handling of `final` using Resolver seems to be redundant unless there are some corner cases, not covered by our tests. For maintainability purposes it's arguably better to keep handling of override logic in one place and inside PropertyCache, which is intended to be responsible for it (see handleOverride). Therefore adjusting PropertyCache::appendProperty to propagate OverrideResult to the upstream calls and use it in PropertyCacheCreator<>::tryDeriveCacheFrom to throw an error in cases of invalid property override. Change-Id: Iec8da8d5bd2979a4639c27d916b9444b37ad0b7a Task-number: QTBUG-98320 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCacheCreator: add tryDeriveCacheFrom(objIR, baseTypePropCache)Dmitrii Akshintsev2025-07-281-234/+259
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit aims to break monolithic logic of property cache creation into smaller isolated chunks by extracting and exposing a method responsible for creation of cache based on the object's IR and propertyCache of base type. Currently there is a lot of coupled logic happening behind the buildMetaObjectsIncrementally, which is extremely hard to understand and especially hard to test in isolation. It requires a lot of pre-setup of different components to make things work. Within the scope of QTBUG-98320, however, all what's needed to be verified is that given objectIR and property cache of Base Type we create/derive a correct property cache for this object. a.k.a. (objectIR, BaseTypePropertyCache) -> objectPropertyCache The logic in `createMetaObject`, which is a protected method is overly complicated by itself and depends on the state of the PropertyCacheCreator, which is changing during buildMetaObjectsIncrementally. However this "derivation" can be easily extracted and isolated, hence better tested. Some tests will follow in the further commits. Task-number: QTBUG-98320 Change-Id: I332591b0f210efb95d5c096cc75e77d837d9ab94 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Quick: Correctly expose more types to QMLFabian Kosmale2025-07-281-1/+1
| | | | | | | | | | | | | | | | | | | | | In order for QML tooling (and in some cases, the runtime [1]) to work correctly, meta-methods need to use the fully qualified type. Moreover, we need to make sure that types which are referenced are exposet to QML, even if only as anonymous types. Switching signals and slots to fully qualified types risks breaking old style connects, so this is only applied to private headers. This reduces the warnings reported by the Quick_qmllint_module target quite a bit. [1] The runtime often has the meta-type available, which is generally enough. Tooling however will not be able to identify the type and provide e.g. proper auto-completion. Pick-to: 6.10 Change-Id: I706c25d8fdeb79ca3d2488ce1d2e66f79818cfbb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Fix code to assign lists to list propertiesUlf Hermann2025-07-281-7/+65
| | | | | | | | | | | | We need to figure out if the input is also a list, iterate that if necessary, and deal with the various QVariant cases. Amends commit b0fc028cb5a5dfa9e95640a32e9b38ca6df0734d. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-136566 Change-Id: Iab7c2d18b7049eecd0327cbdb7e7c7592b2d2ad3 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Fix typo: rename uneccessary to unnecessaryTian Shilin2025-07-241-1/+1
| | | | | | | | | The function name had a spelling error. This change improves code readability and follows Qt naming conventions. Fixes: QTBUG-138663 Change-Id: I6965c85e541b4d641a4fae938fc0ddd43e9411be Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* CMake: More fixes for QT_CMAKE_EXPORT_NAMESPACE not being availableAlexandru Croitor2025-07-221-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _qt_internal_write_qmldir_part function is deferred to be called in the root CMAKE_BINARY_DIR, where QT_CMAKE_EXPORT_NAMESPACE is not defined if find_package(Qt6) is not called in the root of the project. Make sure to pass the value of QT_CMAKE_EXPORT_NAMESPACE to the function explicitly, from a scope where it is available. This avoids errors like: CMake Error at Qt6QmlMacros.cmake:155 (add_custom_command): Error evaluating generator expression: $<TARGET_FILE:::qmltyperegistrar> No target "::qmltyperegistrar" As a drive by, do the same for _qt_internal_deferred_aotstats_setup and use that variable, instead of the hardcoded Qt6:: prefix. Add test. Amends b47555feff56afa678c4cd91b64b2c77b61b1253 Amends f2889262c86f31d85f2e72edd11792527348b39e Pick-to: 6.8 6.9 6.10 Fixes: QTBUG-138559 Change-Id: I9ecf2149737f3522fa61b7188403c8470b5a15d3 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Expose XMLHttpRequest to qmltypesFabian Kosmale2025-07-222-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In QML, one can use XMLHttpRequest. Not so with a plain JS engine. The reason for that lies in the fact that a JS engine did not have any network access, because all network functionality was in the type loader, and the type loader was coupled to the QV4::Engine. This has changed in d2bc4a4330254c0c68a0ade51b59a71c4b67b470, but we stil don't expose XMLHttpRequest to a plain QJSEngine. Nevertheless, it conceptually lives in the global object, and we need to collect information about it to enable code completion and linting. Consequently, expose a function in QV4::Engine, which allows us to manually trigger the registration, and call it in qmljsrootgen. Going forward, we should arguably have a QJSEngine::Extension for XMLHttpReuqest, after which we could remove the hack. Note that as before, qmljsrootgen prints a few warnings, because we call functions in contexts in which they must not be called. As before, we ignore this for now. As a side-effect, this adds a few more entries to the qmltypes file for new entries on the global Qt object. Task-number: QTBUG-137075 Pick-to: 6.10 Change-Id: I21e9d62bf075e8d4356db8f357502feb927717e7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmlAttachedPropertiesObject: rename create parameter to createIfMissingMitch Curtis2025-07-222-8/+9
| | | | | | | It will only be created if it doesn't exist. Change-Id: Ide1e6301dd5a67591cb1bd0dc9d19cbfeaaeaa9b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Document that qmlAttachedPropertiesObject only creates object if it's missingMitch Curtis2025-07-221-4/+4
| | | | | | | Pick-to: 6.5 6.8 6.9 6.10 Change-Id: I1cd7e68182ce97576aba91a5ac95439faf35491b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlEngine: use the QMetaCallEvent small-arguments-in-place optimizationAurélien Brooke2025-07-211-13/+12
| | | | | | | Following qtbase f6211c079fa000c0d46b7912341f014669fa628a. Change-Id: I87ea2f5c2aab9cbc2b7f26d0761921d430239cc8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* cmake/qt_add_qml_module: Fix QtQuick auto dependency setupFabian Kosmale2025-07-141-15/+12
| | | | | | | | | | | | | | | | We need to actually defer the code which attempts to detect whether we are linking against QtQuick to the point where we write-out the file, as the user is not unlikely to use target_link_libraries _after_ qt_add_qml_module. Amends 065b784cab3ff8e8a1dd1f5a304c6b8c3f222d79. To test that this works, we run the all_qmllint target of on an example project. We need to add a .qmllint.ini file to let qmllint fail the build if there are any warnings. Pick-to: 6.10 6.9 6.8 Change-Id: I7e00583b3a5b38549db2be13b1a8817b8489496d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Rename QV4::Value::undefindedLuca Di Sera2025-07-142-2/+2
| | | | | | | | | | | | | | | The method provides an easier construction of a QV4::Value representing the Undefined value and was thus intended to be called "undefined", as it can be inferred from the introducing patch at ac2d9bf0f2c32bdd6a64b8421c414a28369cbe2e. The current name is thus almost certainly an uncaught typo and is now renamed to the more descriptive and originally intended "undefined". The only usage site of the method was modified to use the new name. Change-Id: Ic00d910960d281c84550af3ab5ccaab52283daca Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove QQml_isFileCaseCorrect()Ulf Hermann2025-07-117-161/+27
| | | | | | | | | | | | | | | QQmlTypeLoader::fileExists() can do the same job, on all platforms, and more efficiently. Drop the file name case check when loading plugins. Plugin paths are platform-specific and controlled by the build system. There is no sane way to confuse the casing. Also, the build system apparently creates case-mismatched plugins on android, and that works fine so far because QQml_isFileCaseCorrect() was a no-op on android. Fixes: QTBUG-134652 Change-Id: I46059be7998ff8402b400b3e2a5385065275e38d Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* JIT: Always zero out the accumulator when an exception is thrownLuca Di Sera2025-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently when a JITtted function throws an exception, on exiting, the accumulator is not zeroed-out if we don't have an exception handler and is zeroed out when we do have an exception handler. In the case where an exception handler is missing, this means that if the caller is making use of the result of the function call, it might be dealing with garbage memory. Many times this isn't an issue as the result of the call would correctly be ignored in the face of handling the presence of an exception. Nonetheless, not directly using the result is not necessarily enough to avoid issues with the possible garbage. In particular, if the result of the call is put on the JS stack and handling the exception allocates, the GC might be run as part of the allocation and read the elements on the JS stack, one of which would be the garbage memory that was returned. One case where this can happen in the current code-base is during the evaluation of a non-signal `QQmlJavaScriptExpression`, which does put the result of a call on the JS stack while later handling an exception in a possibly allocating way, with the garbage result still on the JS stack. Furthermore, the interpreter currently isn't affected by the same issue, as the interpreter always zeroes out when unwinding without running an handler. This adds the additional problem of the behavior differing between the an interpreted function and its JITted version in the face of an exception when the result of the call is voluntarily or not inspected. To avoid the issue, the code generated by the baseline JIT was modified to always zero out the accumulator before exiting a function call after an exception, independently of the presence of an exception handler. This further aligns the behavior of a JITted function to that of the interpreter when no handler is present. A test was added to `tst_qqmlecmascript` that exemplifies the issue by passing by `QQmlJavaScriptExpression::evaluate` with a JITted throwing function. Fixes: QTBUG-138242 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I969dc790f8a274364ae124afaeae8e2381fc82ae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlTypeLoader: Remove pointless check from absoluteFilePath()Ulf Hermann2025-07-111-8/+3
| | | | | | | | A path that starts with '/:' is a pretty obscure thing and there is no reason to special case it here. Change-Id: I06cac90de9dfe202f9fbbe196183e9e89062de86 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Fix some arguments to importsUlf Hermann2025-07-114-19/+15
| | | | | | | | The precedence is always quint8 and addImportToNamespace doesn't need the errors list. Change-Id: Ieb0a703cf4e2b5fe64fe954b6ddbdfcf35fb4ddd Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Look for existing imports even without redirectionUlf Hermann2025-07-111-13/+26
| | | | | | | | | | | It makes no sense to prohibit multiple imports of the same QML module with the same version. We can just re-order the imports according to prcedence when we detect this. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-138391 Change-Id: I5ad94e1181f6a2beb278e421c1bbf06678fd863b Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Replace btoa() and atob() with better implementationsUlf Hermann2025-07-112-4/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current btoa() and atob() perform UTF-8 conversion of the data and therefore produce different outputs than the relevant Web APIs. That's not helpful for a format which was explicitly invented for data exchange. However, since they are compatible with each other, we cannot simply change their behavior. The actual problem stems from the fact that those functions take strings as their inputs. Strings in JavaScript as well as Qt hold 16-bit data, while base64 can only process 8-bit data. This makes it necessary to deal with invalid characters in the first place. Add additional overloads that take QByteArray. At least for btoa() we don't need to check the input for compliance this way. However, since it's difficult to obtain a QByteArray for random data in JavaScript, also add overloads that take a few more common array-likes and convert them. These overloads actually check the data for compliance and throw the "Invalid character" excpetion if it's found to be non-compliant. In turn, deprecate the broken implementations and print a warning when they are used. [ChangeLog][QtQml] The Qt.btoa() and Qt.atob() methods were subtly broken and produced different output than the common Web APIs. They have been deprecated in favor of overloads that take array-likes. Array-likes, especially ArrayBuffer, are a better fit for expressing raw data than strings. Fixes: QTBUG-135329 Change-Id: I4d48c84b3a87cb615f78aa1a8c1eddfedcd306f9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Fix leftovers from V8Ulf Hermann2025-07-115-11/+11
| | | | | | | Some comments and header guards still had V8 in them. Change-Id: I71e888fb72916fcd948a293d9fd50fb54a9499c3 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* doc: qmllint: update settings fileSami Shalayel2025-07-111-7/+66
| | | | | | | | | The settings file in the docs looks quite old: replace it with a fresh version obtained by "qmllint --write-defaults". Pick-to: 6.10 Change-Id: I46b12f6b5164ea1880fb63b5408b4b3494eb2d93 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Include hidden files in dir listingsUlf Hermann2025-07-101-2/+7
| | | | | | | | | | | Hidden files can be used in QML. Previously, with QFileInfo, we did detect them and we should continue to do so. Amends commit 2bd3a62fd0397473d722838c4b3a2982f4ea9497 Task-number: QTBUG-134652 Change-Id: Icfc4f37fe72428dda43bfa82803f223f77c94f77 Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* QQmlTypeLoader: Also populate directory cache on directoryExistsUlf Hermann2025-07-092-28/+56
| | | | | | | | | | | | | | | | | | | | | | | | Previously, QQmlTypeLoader had different cache entries for directoryExists() and fileExist() in the same cache. The ones for fileExists() had an extra slash appended to their path. This was entirely pointless because a path is a path and if it exists, we can use it for file lookup. Furthermore, it was wasteful because it halved the capacity of the directory cache while adding duplicate keys. However, it did mask one bug: The entries for directories could stay unpopulated without disturbing the ones for files. The masking was not complete, though. When inserting a directory entry that ended in a double slash, one of the slashes was removed, leaving the entry in the form expected for files. Now we always remove all trailing slashes, and always populate the cache when an entry is first inserted. Task-number: QTBUG-134652 Change-Id: I333c81655d6f6dfff1e46dae8eef3c46a33d97ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Reduce access to uninitialized scoped allocationsLuca Di Sera2025-07-0820-136/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Scope` provides a mean of performing uninitialized scoped allocations on the JS stack. This can generally be unsafe as this form of allocation temporarily leaves an element representing garbage memory on the JS stack, which could be accessed by other parts of the program. Indeed, a set of bugs related to this kind of behavior was recently solved. Hence, to reduce the surface of those kind of bugs, the usages of uninitialized scoped allocations were reduced to a minimum. The solution to the recent set of bugs related to uninitialized scoped allocations introduced a series of `construct` methods that ensure that the uninitialized allocation and the initialization of the allocated elements are performed as a single step of computation, reducing the surface for incorrect usages of those kind of allocations. The solution was expanded by the introduction of new `construct` methods that cover initialization from other types and some different means of initialization that were used around the code-base to work with uninitialized scoped allocations. Similarly, the various allocation methods in `Scope` were subsumed by the new `construct` methods, with the only remaining means of allocation being the uninitialized one that is used as a building block for the `construct` methods. In particular, `Scope` provided three forms of allocation under the various `alloc` methods. The aforementioned uninitialized allocation and an allocation that performed initialization to either the Undefined or the Empty value. The latter two forms of allocation were converted to forms of `construct`. Since they directly map to the same concept of allocation plus initialization, the conversion avoids having two names for the same concept. More specifically, the form of allocation that initialized to the Undefined value was converted to the new `constructUndefined` which keeps the same behavior. The different naming from the basic `construct` methods is justified by the different interface, which doesn't require choosing a initial value, and the different implementation which is built on the more general `construct` methods rather than the lower level allocation routines. The form of allocation that initialized to the Empty value was removed as it was found to be unused in the code-base. The converted allocation methods generally provides the same interface and behavior with the exception of always requiring the user to specify the amount of allocate objects. This is a change compared to the previous interface which allowed a zero-argument version that allocated a single element. The writer of the patch considered the additional terseness inconsequential compared to the required additional code so that the possibility was not preserved. The code related to the converted allocation forms was removed as a consequence of the conversion. The remaining uninitialized allocation form was made private, to avoid general usage outside of `Scope`, and favoring usages of the substitute `construct` methods. A comment that was related to usages of uninitialized scoped allocations was moved to the lower level `jsAlloca`, which forms the basis for those allocations and creates the abovementioned issues, where it was expanded upon. Usages of the non-uninitialized allocation forms around the code-base were modified to use the new `constructUndefined` method. Most usages of the uninitialized allocation form were modified to use the new `construct` methods that were added to replace them. Exceptions were made for those cases where the initialization routine is either very complex or depends on details that shouldn't belong to `Scope` such that they cannot be trivially encapsulated in a `construct` method. Instead, the relevant function or object was friended by `Scope` to allow accesses to the now private form of allocation. Those usages were previously checked and are supposed to be safe but should be scrutinized if they are modified or the code around them is modified. One of the friended functions, `callDatafromJs`, previously offered a default argument that was not made use of in the code-base. The default value for the argument was removed to simplify friending the function, considering the difficulty the language has with friended function with default arguments and considering that it would have required the default value to be moved out of the function definition into a forward declaration in the unrelated header that defines `Scope`. It is expected that the changes will reduce the surface of usage of uninitialized scoped allocations in favor of a slightly safer approach, make the issue that those usages can produce more apparent and generally centralize the usages as much as possible to make them easier to evaluate and keep track of. Change-Id: I351329f2c139201e0728791df6da297698170f55 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Doc: qt_add_qml_module misses information about find_packageAlexei Cazacov2025-07-084-0/+8
| | | | | | | | | | This commit adds a note that calling `find_package` is required for using Qt-specific CMake commands. Fixes: QTBUG-138357 Pick-to: 6.10 6.9 Change-Id: I803208184dc02be799dc8e7fa0d0dce96375e42a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* qmllint doc: Add assignment-in-conditionFabian Kosmale2025-07-081-0/+63
| | | | | | | | | Task-number: QTBUG-127037 Pick-to: 6.10 Change-Id: Ibafc358bfec707799d947634d3dda331643c4cdd Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qqmllsutils: limit recursion in findFilePathsFromFileNamesSami Shalayel2025-07-081-0/+10
| | | | | | | | | | | Limit the file recursion in findFilePathsFromFileNames, and allow users to modify the limit via environment variables. Implement the code inside a static findFilePathsFromFileNamesImpl method that will be reused later when searching for a C++ header for go-to-definition. Task-number: QTBUG-128393 Change-Id: Ic5ba5929329434e079c70bdee9c2c2d343d381d5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltyperegistrar: Manually register names for Q_ENUMSUlf Hermann2025-07-071-0/+16
| | | | | | | | | | | | Flags declared with Q_FLAGS lack the methods for properly extracting the typedef'd name. We need to manually register the typedef. Amends commit 8bf5aae19b77b618f3f7a55a59e87c8a319475a8. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-138174 Change-Id: I7c373f4d810a0c9a5590f39cc629015662a69ed4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>