aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
Commit message (Collapse)AuthorAgeFilesLines
...
* QQmlPropertyCache: use more efficient addProperty overloadFabian Kosmale2021-01-251-1/+2
| | | | | | | | | | As we already have the metatype of the property, we can use the more efficient QMetaObjectBuilder::addProperty method which avoids a name to metatype lookup. Task-number: QTBUG-88766 Change-Id: Iab8c22556cb15d35337f266e533cb0d907232421 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Don't register invalid metatypes in QQmlMetaTypeDataUlf Hermann2021-01-251-5/+0
| | | | | | | | If the original type's ID is not valid, then QQmlMetaTypePrivate's ID is also not valid. Change-Id: Ia727e7dc99b1954b4c6fa9b599e8edc0ef9b3212 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move qmlRegisterUncreatableMetaObject to qqml.cppUlf Hermann2021-01-252-34/+33
| | | | | | | | | There is no reason to keep it in qqmlengine.cpp as it is declared in qqml.h. Change-Id: I0a0261b943c4a3b4333d7161becbd68ad4f1b21e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlPropertyBinding: improve error reportingFabian Kosmale2021-01-253-7/+77
| | | | | | | | | | | | | | | | | | This change ensures that bindings created in QML between new-style properties contain information about which property caused the loop. To do this, we store additional information about the property involved to retrieve its name and position at a later point. We print the warning in case we detect a binding loop in evaluate, and also set the error reporting callback correctly, so that the condition can be reported when the loop is detected in another part of the binding evaluation. In addition, we do not only set the QPropertyBinding's error member when JS evaluation results in an error, but also print the warning with qmlWarning. Fixes: QTBUG-87733 Change-Id: Idb25237d1f57355ca31189e6bf2a918430b3a810 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QAnimationGroupJob: Don't call virtual functions from dtorUlf Hermann2021-01-222-23/+42
| | | | | | | | | | | | The subclasses are already dead at that point. We don't need to notify them anymore. Rather, refactor the code so that we can clean up QAnimationGroupJob itself without virtual calls. Task-number: QTBUG-90401 Pick-to: 5.12 5.15 6.0 Change-Id: I6917bf299ceb1383b9d29687e5bf53ae36803ecf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Export QML and Quick value typesUlf Hermann2021-01-221-8/+8
| | | | | | | They need to be accessible from C++. Change-Id: I60f2213bdbe6b8b64856e13f1e0cc798f8a51086 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSEngine: Add a function to throw a pre-generated error objectUlf Hermann2021-01-222-0/+15
| | | | | | | | | | | | | | | It makes little sense that you can construct an error object but not throw it. The test was definitely meant to actually throw the error object, not return it. [ChangeLog][QtQml] QJSEngine has gained an additional overload to the throwError() method, with the effect that calling throwError() with a character literal as argument is now ambiguous. You should explicitly construct a QString instead. Change-Id: I90c6c9edf10509daa142a86581d6a3f7ff45af2c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* fix no translation buildTim Jenssen2021-01-211-0/+2
| | | | | Change-Id: I5f4334e8b55511c33eab52262239d5d2da2329ba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use new QObjectPrivate connection mechanism in dynamic connectionsAndrei Golubev2021-01-211-2/+18
| | | | | | | | | | | Old API assumes sender == receiver, which results in wrong handling of connections when receiver is deleted: connection is not removed or notified elsehow as it's not really tied to a valid receiver Task-number: QTBUG-86368 Pick-to: 5.15 6.0 Change-Id: I0f3115f1b0f26cf353752ba2b8fd88e0f3bdd388 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Doc: Change section about writing a qmltypes fileUlf Hermann2021-01-201-102/+8
| | | | | | | | | | | You should not write qmltypes files manually. We only document their existence and that you should add them to manually written qmldir files now. Change-Id: I434398656179806c3e57724324aba38738384e1d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* 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>