aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
Commit message (Collapse)AuthorAgeFilesLines
...
* QML_SINGLETON: Handle local create() functions with foreign typesMaximilian Goldstein2021-01-202-21/+34
| | | | | | | | Previously only the foreign type was searched for a create method. Now the wrapping type can also contain it. Change-Id: I05fb9e0c0a54c14530eb9adcae5a44df5c208be3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlComponentPrivate::setInitialProperties: Do not silently swallow exceptionsFabian Kosmale2021-01-181-2/+2
| | | | | | | Instead, log them with qmlWarning. Change-Id: Icde7397085841a84aca8a81c716d552c4cd4485a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Fix writing function to property through aliasFabian Kosmale2021-01-181-1/+18
| | | | | | | | | | | | | | We special case writing functions to properties, only allowing assigning them to var properties and QJSValue properties. This would however break when aliases are involved. This commit fixes the issue by resolving the alias, and then checking and writing to the resolved property. Fixes: QTBUG-90373 Pick-to: 5.15 6.0 Change-Id: Ia09ebe92feeaf8359c99ff9aeadc676b9fcfaa07 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Build fixes for GCC 11Ville Voutilainen2021-01-181-2/+2
| | | | | | Task-number: QTBUG-89977 Change-Id: I975a859d5252e2721475f86ced6c8dab06ae8c9c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove the qmake project filesFabian Kosmale2021-01-1520-766/+0
| | | | | | | | | Remove all qmake project files, except for examples which are used to test that qmake continues to work. Change-Id: Ic4abb72dc2dcd75df7a797c56056b6b3c5fe62ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move QtObject out of the QV4 namespaceUlf Hermann2021-01-151-21/+22
| | | | | | | | This way we don't have to specially prefix the foreign namespace. Change-Id: I0daa2fe3b8faa205c2c9dfb0f6b1984b2c8e7437 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlComponent: Avoid crash when setting initial properties in JS moduleFabian Kosmale2021-01-151-1/+2
| | | | | | | | | | In a JS module, we lack a qml context. Thus, we have to check whether qmlContext is null. In that case we use the engine's scriptContext('s ExecutionContext) instead. Fixes: QTBUG-90245 Change-Id: I337e9c7cade472f52fc81c93d1152ff59f8018a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* exposecppattributes.qdoc: Warn about aliasesMaximilian Goldstein2021-01-141-0/+23
| | | | | | | | | Using aliases in conjunction with Q_PROPERTY might cause some issues, so we should warn about it. Task-number: QTBUG-83950 Change-Id: I53db6848e3a7659e8b7ad93de70088cab6e53184 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Add a freeze() method to QQmlPropertyMapUlf Hermann2021-01-134-9/+39
| | | | | | | | | After freezing a QQmlPropertyMap you cannot add any more properties, but in turn the property access is cached, and therefore faster. Task-number: QTBUG-57792 Change-Id: I2c6d768039c3b59eb2411194e463ee0de55f8bed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlCleanupUlf Hermann2021-01-1312-238/+8
| | | | | | | | | | | | | | | | | The only place where it was still used is QQmlOpenMetaObjecType. The only effect of QQmlCleanup is that clear() is eventually called by the engine. In the case of QQmlOpenMetaObjectType the only effect of that was that the "engine" member was reset. However, the only place where that member was used was in setCached(), and in that place it was irrelevant. There is no reason why setCached() should be prohibited when there is no engine. We may be worried that the property cache assigned to the open metaobject might go away somehow if there is no engine, but the cleanup mechanism clearly demonstrates that checking for the engine on setCached() does not protect against this. Fixes: QTBUG-90004 Change-Id: I05445eaeb53a64c70de366090ea2ee4aecf2bad8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyMap: Add a method to insert multiple values at onceUlf Hermann2021-01-134-14/+94
| | | | | | | | | | | | This avoid re-building the metaobject for every property added. As rebuilding the metaobject is an effort linear in the number of properties, the runtime when adding multiple properties via singular insert() is quadratic in the number of properties. The plural insert() rebuilds the metaobject only once. Task-number: QTBUG-57792 Change-Id: I9513c4de047724e4141dab72aacfbdd840a3e465 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyMap: Check validity of keys only onceUlf Hermann2021-01-131-9/+2
| | | | | | | | | | The QQmlPropertyMap should guard the keys before it passes them on to QQmlOpenMetaObject, rather than getting called back through the virtual createProperty() method. Change-Id: Ie02ab02c4e27260222964c708c0f0917c8c6239d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Add a -i <qmltypes> option to qmlcachegenUlf Hermann2021-01-121-0/+5
| | | | | | | | | | | | | qmlcachegen needs to see the qmltypes file for the current project so that it can query it for C++ types exposed to QML. This is only relevant when generating C++ code, which qmlcachegen itself cannot do. However, in order to write a compatible drop-in, we need it. Also, hide related ignored options from --help in qmlcachegen. Change-Id: Id2f1b8b1750351c7de8dfe49e4065ef1b29423b7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListReference: Allow construction from a QVariantUlf Hermann2021-01-122-0/+37
| | | | | | | | | | | | Currently there is no public API to transform a QVariant holding a QQmlListProperty into a QQmlListReference. We cannot pass QQmlListProperty itself as that is templated. The metatype-based casting is somewhat evil, but not more so than what we already have in the other ctor. Change-Id: I2d56499b1fd188613bc71016cb00ec23081d3cea Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QJSManagedValue: Allow retrieving and instantiating JS metatypesUlf Hermann2021-01-122-1/+109
| | | | | | | | ... a.k.a InternalClass. This is a faster way of creating multiple similar objects, compared to a sequence of setProperty() calls. Change-Id: Iecc8c581e50b9062895dae9500ffe2482d88028e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make QQmlImport::removeDynamicPlugin() saferUlf Hermann2021-01-121-28/+24
| | | | | | | | | | | | | Consistently never unload plugins on macOS, also remove half-broken plugins from the map, and always unregister any types in them. Unloading plugins on macOS is ill-advised as it will actually unmap the memory, making string data (among other things) inaccessible. We've already done the same change to qmlClearEnginePlugins(). Change-Id: I8fa40db5c3cd83f12e6d85d0efc3b9679dd4381e Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSManagedValue: Allow array access to stringsUlf Hermann2021-01-121-0/+13
| | | | | | | | | If you access a string as an array you get a one-character string of the index you are asking for. Change-Id: Ie2ac3243c9e23f37b8904c54d824946646a596eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Cache static compilation unitsUlf Hermann2021-01-123-12/+61
| | | | | | | | | | | | If we load the same file multiple times, we can re-use the old mapping. In fact we may leak memory if we don't. The fact that we have to use a mutex here is somewhat regrettable, but I haven't found a better way of serializing access. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: Iaa44ac80faa5e95f30c05e950ab35083a8b0416b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* masm: Add error handling for failed mprotect()Ulf Hermann2021-01-124-4/+6
| | | | | | | | | | | | If we cannot mprotect() we have to abort the JIT compilation. Delete RepatchBuffer.h as it is unfixable in that regard. Luckily we don't use it. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: Ic5ddbdf51b471db4ddeaa75aab48b24c1f7ced56 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Remove QQmlCleanup from QQmlScriptDataUlf Hermann2021-01-122-26/+1
| | | | | | | | | | | | It prevents the compilation unit held by QQmlScriptData from being released on clearComponentCache(). The comment justifying the QQmlCleanup has been wrong since we moved away from V8. Task-number: QTBUG-89659 Pick-to: 5.15 Change-Id: I220561d90f707540e47c76d60a51468ee231ce9a Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Pass a more comprehensive context to AOT-compiled functionsUlf Hermann2021-01-114-8/+31
| | | | | | | | | | We need the compilation unit, and a way to retrieve JavaScript metatypes from it. Also, prepare for cases where we only have a QJSEngine, not a QQmlEngine, and pass the scope object as part of the AOT context. Change-Id: Ica81e92c99f3c9b6baffd04db1e0e91603fd2ac7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSManagedValue: Silence some static analysis warningsUlf Hermann2021-01-111-2/+7
| | | | | | | | The engine should really always be available if we have a d pointer. Change-Id: If620e69de07c6d365b45e714bae3ec0fb7eb86ef Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlengine: Fix crash when encountering bad singletonsMaximilian Goldstein2021-01-111-0/+6
| | | | | | | | | Previously errors occurring when parsing QML singletons would just be ignored resulting in a crash. The errors are now properly printed and the execution is aborted in time. Fixes: QTBUG-85932 Change-Id: I61cef5f97546ce2e0753bc46c548838a21b1f506 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid crash for deep aliasesMaximilian Goldstein2021-01-111-0/+4
| | | | | | | | | Aliases are seriously broken and need a larger overhaul. This patch at least prevents the application from crashing. Task-number: QTBUG-89822 Change-Id: Ib6acc5b6f621a902f7f5ce370043986486f3c0d0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Encode target name into foreign_types.txt fileUlf Hermann2021-01-111-1/+1
| | | | | | | | Otherwise you cannot have multiple targets in the same directory. Change-Id: Ibf50a4e0752273965e4570527085787cf8060710 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QJSManagedValue: Add JavaScript 'function' typeUlf Hermann2021-01-072-11/+13
| | | | | | | | | 'function' is a separate type in JavaScript and should be treated that way. Replace the isCallable() method with a new isFunction() to reflect that, and add an entry to the Type enum. Change-Id: I09cc28a9edf8aa0380eb9caeb738dfc298a02567 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Doc: Fix typos ECMA-26 and boolean value quotingNico Vertriest2021-01-071-3/+3
| | | | | | Pick-to: 6.0 Change-Id: I1bf34b68ecfa2d6eb8e687a0b12def5e7c96c318 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix EngineBase::globalObject being misalignedMaximilian Goldstein2021-01-061-1/+3
| | | | | | Fixes: QTBUG-85602 Change-Id: I7cdd83c16bec76c8f902c9136fa89decfc1cbd3d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Fix broken QDoc markupPaul Wicking2021-01-051-2/+2
| | | | | | | | | \code must be closed with \endcode. Pick-to: 6.0 5.15 Fixes: QTBUG-89738 Change-Id: I0cadb14b6726a6fdc6c3fb773155066d30490e74 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* CMake: Make error in defer qmldir file generation more verboseAlexey Edelev2021-01-041-0/+5
| | | | | | | | | | | When CMake version >=3.19 is used, qmldir file for qml module is generated using DEFER CMake call. If find_package of Qml component was not explicitly called error message is not really obvious. Add explicit fatal error for this case and point to possible solution. Fixes: QTBUG-89622 Change-Id: I82fee717478461762deb2d66a1bc347680b48d06 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Implement command for running qmllint on targetMaximilian Goldstein2021-01-041-2/+16
| | | | | | | | | Adds qt6_target_enable_qmllint which automatically picks up all QML files marked for processing by qmlcachegen which then can be checked using a ${TARGETNAME}_qmllint target. Change-Id: I1d228d3435e6ad2389e9885f55952231c69d38ec Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* definetypes.qdoc: Add note about include path prefixesMaximilian Goldstein2021-01-041-0/+1
| | | | | | | | | We do not allow for prefixes when using declarative QML registration. Task-number: QTBUG-87221 Change-Id: Ie1ce604390d49601a48217c71ba161f1b5f5e6e0 Reviewed-by: Erik Schilling <ablu.erikschilling@gmail.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSValue: Add a toPrimitive() methodUlf Hermann2020-12-192-0/+34
| | | | | | | We need a way to easily get a primitive from a QJSValue. Change-Id: I91a55d92ffa4ba6139b1e3f2e9308800b7047563 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSManagedValue: Throw an exception when trying to call a non-callableUlf Hermann2020-12-191-3/+18
| | | | | | | The JavaScript engine does this, so we should do the same here. Change-Id: I011a60bc2c013f19306c843da7a9c22dc80a39cb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSPrimitiveValue: Add a toVariant() method and ctor from QVariantUlf Hermann2020-12-181-0/+42
| | | | | | | | This is rather handy. Without it, we have to go through either QJSValue or QJSManagedValue, which causes much greater overhead. Change-Id: I40e2ecb6e2005f80c8f52b5e9a59028b3984eea4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a QJSManagedValueUlf Hermann2020-12-1813-65/+1374
| | | | | | | | | | | | | A QJSManagedValue is a view on a QJSValue which always knows the engine the value belongs to. This allows us to implement the JavaScript semantics of the various QJSValue methods in a much more rigorous way. [ChangeLog][QtQml] The new QJSManagedValue should be used instead of QJSValue for manipulating properties and prototypes of JavaScript values, as well as for calling JavaScript functions. Change-Id: I9d445ffcf68dfa72dba9bae0818e83c80665ad66 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow JavaScript primitive type transformations inline in C++Ulf Hermann2020-12-1815-59/+1099
| | | | | | | | | | We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Fix proxy iterationFabian Kosmale2020-12-171-2/+6
| | | | | | | | | | | If the target of a proxy was extensible, we did not set the iteratorTarget to its correct value, and thus the ForInIteratorObject would not be usable. Pick-to: 6.0 5.15 Fixes: QTBUG-86323 Change-Id: Id1924ac4087bab38c006b8eba92b619b79d36b7a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* JIT: When making memory writable, include the exception handlerUlf Hermann2020-12-173-6/+22
| | | | | | | | | | | | makeWritable() rounds the memory down to the next page boundary. Usually we include the exception handler this way, unless the offset from the page boundary is less than the exception handler size. Make it explicit that we do want the exception handler to be writable, too. Fixes: QTBUG-89513 Pick-to: 5.15 6.0 Change-Id: I2fb8fb0e1dcc3450b036924463dc1b40d2020c46 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-12-169-13/+13
| | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtDeclarative. As the two are synonymous, this patch should have no impact on users. Task-number: QTBUG-86829 Change-Id: I5bb418483a3b06619abb4ff62cf0290a7b3bcd4f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Automatically create qmllint targets for modulesMaximilian Goldstein2020-12-161-0/+18
| | | | | | | | Adds ${TARGET}_qmllint targets to every qt module using qmlfiles. You may specify additional import paths by adding them to QML2_IMPORT_PATH. Change-Id: Icb920756a26c49db5e8edb9c0f691b90af9d5311 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlfunctions.doc: Improve qmlRegisterSingleton documentationMaximilian Goldstein2020-12-151-4/+3
| | | | | | | | Reflect that qmlRegisterSingleton can't be used in conjunction with QML_SINGLETON. Change-Id: Ie7b2fd4f6fa5cb29806a212c284781799b796a32 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmltypeloader: Allow pluginless qmldir + declarative type registrationFabian Kosmale2020-12-151-1/+9
| | | | | | | | | | | | | | Assume an application which uses a QML singleton (so needs qmldir), and wants to use declarative type registration. This currently breaks because we find the qmldir, see that there is no plugin to load, and thus never search for registration functions. Requiring the creation of a plugin is rather pointless for an application which doesn't reuse the QML types; so instead enable this usecase to work. Note that qmldir + imperative registration did always work, as the imperative registration code did always run. Change-Id: Iac40020eb97d602d10eb8c4eecac5195ffeabe14 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* docs/QML_ELEMENT: Warn about possible namespace conflictsMaximilian Goldstein2020-12-151-0/+4
| | | | | Change-Id: I8fff0ba3e571273c203d4e566dcb604b75a835a8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlMetaType: Remove lists setFabian Kosmale2020-12-112-6/+6
| | | | | | | | | | The information can be found in the metatype. Task-number: QTBUG-88766 Change-Id: I6c460e3100057498b17d9ed74d2e85b609a6ab4c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlMetaType: Get rid of objectsFabian Kosmale2020-12-112-9/+6
| | | | | | | | | | | Use the information from the metatype instead. Task-number: QTBUG-88765 Task-number: QTBUG-88766 Change-Id: Ie0a748861388e8c36f5f607ccd5aba4d6049b930 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Clean up (QQmlEnginePrivate|QQmlMetaType)::toQObjectFabian Kosmale2020-12-112-9/+2
| | | | | | | | | | | | | | | All the necessary information is contained in the QVariant's metatype, so we can use that. This removes the need to acquire the data pointer lock. The method in QQmlEnginePrivate now simply forwards to QQmlMetaType; in a later commit, all usages of the forwarding functions from QQmlEnginePrivate will be replaced with the equivalents from QQmlMetaType, so that they can be removed from QQmlEnginePrivate. Task-number: QTBUG-88766 Change-Id: Iebcda9b18b4952fff2c7c1aeae210c677c6869b8 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Respect QML_DISABLE_DISK_CACHE also for caches built into the binaryUlf Hermann2020-12-104-8/+27
| | | | | | | | Previously it would only disable loading of separate cache files. Change-Id: Iae92fc03d2e5566ef7dc44a6730b788b7512fd3d Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support namespaced QML_ELEMENTMaximilian Goldstein2020-12-101-2/+9
| | | | | | | Fixes: QTBUG-87266 Change-Id: Iad8c7765b339c5498f541702bbf7df64164f5358 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QV4 Engine: Remove MSVC special casingFabian Kosmale2020-12-103-18/+2
| | | | | | | | | | This patch removes a workaround for old versions of MSVC; we should be able to rely on the standard library nowadays. Original-patch-by: Alexander Neumann Fixes: QTBUG-89203 Change-Id: I8047565000fc7e4e3b8ac28584ff4a479b648274 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>