aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/qquickworkerscript.cpp
Commit message (Collapse)AuthorAgeFilesLines
* CRA review: mark workerscript subfolderFabian Kosmale2025-09-161-0/+1
| | | | | | | | | | | | | | - Mark the global heades as insignificant, they don't contain any logic. - Mark qv4serialize as critical: String data that might get passed to a worker script might come from an untrusted context, and thus the serialization process needs some basic care. - Evertything else gets the default significant marker to indicate that it has been reviewed. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-136209 Change-Id: Ib820d551f687cbd41f0306d39552e55e8642a2b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Allow remote JavaScript files in WorkerScriptUlf Hermann2025-06-171-39/+77
| | | | | | Fixes: QTBUG-19407 Change-Id: I482689396db82332e50c41e6404d58376f4dc118 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Hold QQmlTypeLoader in QV4::ExecutionEngineUlf Hermann2025-06-171-11/+19
| | | | | | | | | | | ... rather than QQmlEngine. This paves the way for having the type loader attached to ExecutionEngine rather than QQmlEngine. Also, reference the execution engine in the type loader, in turn. Task-number: QTBUG-19407 Change-Id: I04e571c5c6ac5bce5e82537cb96c6940c7186f3a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* WorkerScript: Properly reset entry in workers map on removalUlf Hermann2025-06-141-2/+4
| | | | | | | | | | | If we leave the QQuickWorkerScript pointer around, we can process another message on the worker thread afterwards which would still create the worker script engine for the now-dead QQuickWorkerScript. This crashes. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I731ed8f53dffee33dcff73851876944c55a4ce6c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* WorkerScript: Clean up event classes and enumsUlf Hermann2025-06-121-99/+67
| | | | | | | | | | We only need one enumeration, and all the methods of the different events can be inline. Then we can switch over the values of the one enum. Change-Id: I7691fb95fca57b6930de84fa71fc7e778edd879c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Dmitrii Akshintsev <dmitrii.akshintsev@qt.io>
* QtQml: Drop source URL from WorkerScriptUlf Hermann2025-06-061-2/+0
| | | | | | | Nobody is using it and it's a thread safety risk. Change-Id: Ifdf79cfbcb50542036509c9301917077c45a303f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Fix thread synchronization in QQuickWorkerScriptUlf Hermann2025-06-051-15/+17
| | | | | | | | | | We need to lock whenever we handle the map of workers or their owners. We don't need to lock for merely posting events. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: Ie4b499a5356665175e548917b6be2ee0bdc03ebe Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Move network access manager factory into type loaderUlf Hermann2025-01-081-15/+12
| | | | | | | | | | It's used from both, the type loader and the engine thread, and also from worker scripts. Add a comment to explain why it needs a separate mutex. Task-number: QTBUG-131721 Change-Id: I12ec2fe462349b3ad5f34262d3f43dfa78f0487f Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QtQml: Model native modules as compilation unitsUlf Hermann2024-12-061-6/+3
| | | | | | | | | | | | | | | | | | | | | | | QQmlTypeLoader::injectedScript() was unsafe and impossible to fix because it had to query the engine from the type loader thread in order to find out whether to load a script from an actual file. By removing the whole special-casing of native modules, we can make the script loading thread safe. A native module is now also a compilation unit, with a regular QV4::Module as value. This means we can remove a lot of code that deals with the native modules in the engine. The downside is that native modules are now a lot larger than before. However, given that they don't appear in any examples and hardly any bugs have been filed about native modules since their introduction, we can assume that they are not a very popular feature. The reduction in complexity and the removal of the native modules map in the engine is expected to outweigh the extra memory overhead for native modules. Task-number: QTBUG-131721 Pick-to: 6.8 Change-Id: Ia7388d7ba8d71637559a791d874257fba4646330 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Replace \instantiates with \nativetypePaul Wicking2024-08-201-1/+1
| | | | | | | | | | | Since the implementation of the `\nativetype`-command in QDoc, the `\instantiates`-command is deprecated. Replace the use of the deprecated command in favor of its replacement. Pick-to: 6.8 Task-number: QTBUG-128216 Change-Id: I23d9f66d3f6db2e5f827d7868497a432bb9b0626 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* QtQml: Use QHash/QMap's constFind() to avoid unnecessary detachesVladimir Belyavsky2024-04-221-4/+4
| | | | | | | | Use QHash/QMap's constFind() instead of non-const find() where applicable to avoid unnecessary detaches. Change-Id: I6b31af1d163d11deb229681ff7e2f6c9f8335d8c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Add a wrapper builtin for QQmlV4Function*Ulf Hermann2024-04-121-1/+1
| | | | | | | | | This way qmltyperegistrar can recognize it and refrain from warning about it. Task-number: QTBUG-101143 Change-Id: I598140e7e90dbd3e27a78c26eff3d46f0fd3e989 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Always link executable CU on creationUlf Hermann2024-01-101-1/+1
| | | | | | | | | | | | | | | We don't want floating unlinked executable CUs. They should always be tied to an engine, and the engine should not change. This gives us one definite point where to register them with the engine (to be done in subsequent change). Unfortunately, due to the refcounting, we need to remove the engine from any still-referenced CUs when the engine itself is destructed. We will be able to drop the refcounting and make the engine fully own its executable CUs once we can hold base CUs in most places. Change-Id: I9a53e83d5c4746c2b2bca896b51baa4fe7fee757 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* convert threading example to manual testsOliver Eftevaag2023-07-041-3/+0
| | | | | | | | | | | | The threading example used a LauncherList to combine two different but related examples into one. I've now separated both into a shared directory called 'threading' Pick-to: 6.6 Change-Id: Iee8898e61adcf69dc67157a1eff5f6ac019a39ca Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* WorkerScript: Create ExecutionEngines on demand when neededUlf Hermann2022-11-301-15/+40
| | | | | | | | | | | | | Creating an engine is rather expensive and as long as your script doesn't run, we don't need one. Furthermore, this allows us to create the engine in the same thread it will run in. Not only is this stylistically better, but it will also let the engine check its stack limits correctly on creation (once we do check stack limits). Task-number: QTBUG-108182 Task-number: QTBUG-106875 Change-Id: Id0003b333c576b3bb603d8b71a5070211c7475bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Make modules imported with registerModule() available in QMLUlf Hermann2022-09-021-4/+6
| | | | | | | | | So far, you could only use them from pure JavaScript programs. Also, fix re-exporting parts of native modules. Fixes: QTBUG-105901 Change-Id: I170017083284e6457b1aa0c6e606fd26227edae3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+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>
* Clean up JSCallData setupUlf Hermann2021-03-171-3/+3
| | | | | | | | | | | | | | | | | We either have pre-populated arguments and thisObject, then we can just use them and keep them const. Or, we want to allocate and populate the arguments and the thisObject. Then, do allocate them in a separate object, and transform that into JSCallData afterwards if necessary. Furthermore, avoid alloc(0) as that just returns the current stack top. Writing to it will clobber other data. Rather, just use nullptr and crash if it's written to. Also, remove the useless operator-> from JSCallData. That one just confuses the reader. Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do not resolve URLs when assigning them to a propertyUlf Hermann2020-06-221-4/+7
| | | | | | | | | | | | | | | We don't know in advance if a URL is part of the source code and should be relative to the current element, or if it is part of the application data and should not be touched. [ChangeLog][QtQml][Important Behavior Changes] URLs are not resolved or intercepted anymore when assigning them to a "url" property. Instead they are resolved and possibly intercepted when used to access an actual resource. Fixes: QTBUG-76879 Change-Id: Iaa2385aff2c13aa71a12e57385d9afb5dc60a073 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Model WorkerScript as an engine extensionUlf Hermann2020-05-201-47/+58
| | | | | | | | | | | This is a much better fit conceptually, and it avoids inheriting from ExecutionEngine. Coverity-Id: 218787 Pick-to: 5.15 Change-Id: I3c1f1249e5267a180c46269829d9f0aa910ecdd0 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Being careful, we can now save primitive values inline. We use the heap pointer of QV4::Value as either QString* or QV4::Value* for complex types. We cannot store persistent managed QV4::Value without the double indirection as those need to be allocated in a special place. The generic QVariant case is not supported anymore. The only place where it was actually needed were the stream operators for QJSValue. Those were fundamentally broken: * A managed QJSValue saved and loaded from a stream was converted to a QVariant-type QJSValue * QVariant-type QJSValues were not callable, could not be objects or arrays, or any of the special types. * Cyclic references were forcibly broken when saving to a data stream. In general the support for saving and loading of managed types to/from a data stream was so abysmally bad that we don't lose much by dropping it. [ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a QDataStream only primitive values or strings will be retained. Support for objects and arrays was incomplete and unreliable already before. It cannot work correctly as we don't necessarily have a JavaScript heap when loading a QJSValue from a stream. Therefore, we don't have a proper place to keep any managed values. Using QVariant to keep them instead is a bad idea because QVariant cannot represent everything a QJSValue can contain. Fixes: QTBUG-75174 Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove hard-coded notes for 'Corresponding handler' for QML signalsTopi Reinio2020-03-101-2/+0
| | | | | | | | QDoc will generate these notes automatically. Task-number: QTBUG-37355 Change-Id: I8ed058ecbbcc630ad0351f6ce167c3fa61936f6f Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-03-031-0/+4
|\ | | | | | | | | | | | | | | Conflicts: src/qmlmodels/qqmltableinstancemodel.cpp src/qmlmodels/qqmltableinstancemodel_p.h Change-Id: I89339b1cb41ba27fe30c79530859a1c2bfbecc69
| * Fix build with -no-feature-networkUlf Hermann2020-02-241-0/+4
| | | | | | | | | | | | Fixes: QTBUG-82418 Change-Id: Ibceeefed75941d963e6b79b44e9231d0d8053221 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | qmlworkerscript: Fix wrong type used in docsMaximilian Goldstein2020-01-231-1/+1
| | | | | | | | | | Change-Id: I6064b5339936fce22c3fc42fc4a6af72312e5415 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-091-0/+11
|\| | | | | | | | | | | | | | | | | Conflicts: src/particles/qquickitemparticle.cpp src/qmlmodels/qqmladaptormodel.cpp tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp Change-Id: Ibd8fbb91da6893a09f4ffe61ad0b95d8149bbc87
| * QV4::Engine: replace std::function with a function pointerFabian Kosmale2020-01-061-4/+4
| | | | | | | | | | | | | | Turns out, we actually do not need to capture anything Change-Id: I6194b45a1e8053be079d25a6d81212fa226fd3ea Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * QV4::ExecutionEngine: provide QNAM accessorFabian Kosmale2020-01-031-0/+11
| | | | | | | | | | | | | | | | | | | | | | In XMLHttpRequest, we need to get the QNetworkAccessManager from the engine. However, if the request originates from a WorkerScript, there exists no qmlEngine. We therefore add a new indirection to access the QNAM, and set it up accordinly in registerWorkerScript. Fixes: QTBUG-81055 Change-Id: I8915202b6d6b7139c8386304b3d1d7a22a82045e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | src/qmlworkerscript: Add ready property to WorkerScriptMaximilian Goldstein2019-12-061-0/+13
|/ | | | | | | | | | | Previously it was impossible to determine whether a WorkerScript has been fully initialized. This commit introduces a ready property that allows outside Components to determine whether it is safe to send signals. Fixes: QTBUG-80413 Change-Id: I2a1892b5e759e317de791e71d79fbb0cbd320dd3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* WorkerScript: Directly delete QQuickWorkerScriptEnginePrivateUlf Hermann2019-09-301-1/+1
| | | | | | | | | | | | QQuickWorkerScriptEnginePrivate lives in the worker thread. Therefore, once the thread has finished there is no way to send it a deferred delete event. The object and all its children would always leak. As there is no event loop running in the worker thread anymore and this is the dtor of QQuickWorkerScript, it's safe to assume that no one can access the private object anymore afterwards. Change-Id: I51f583ea47060d967403639196247882ff7d2905 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Re-add documentation for QtQml.WorkerScriptUlf Hermann2019-09-171-1/+1
| | | | | | | It was lost when moving the classes and the import URI was wrong. Change-Id: Ic01f5c327ac53e58874f54399dc0434a23bed7b8 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove last traces of QV8EngineUlf Hermann2019-05-081-66/+30
| | | | | Change-Id: I59f738402d51e39188bbbca2ef1fbc8a61612372 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move workerscript to its own moduleUlf Hermann2019-05-061-0/+673
Change-Id: I778cfe842ddf1c600a837d8f2061a338887eed95 Reviewed-by: Lars Knoll <lars.knoll@qt.io>