aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add support for enum declarations in QMLMichael Brasser2017-07-131-0/+4
| | | | | | | | | | | | | | | | | Enums can be declared with the following syntax: enum MyEnum { Value1, Value2 } Grammar changes done by Simon Hausmann. [ChangeLog][QtQml] Enums can now be declared directly in QML. Task-number: QTBUG-14861 Change-Id: Ic6b6e032651d01ee2ecf9d5ce5734976cb3ad7ab Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix concurrent loading of the same qmldir from different scriptsAndy Shaw2017-05-021-17/+24
| | | | | | | | | | | | | | | | QQmlQmldirData keeps a pointer to a QQmlScript::Import, and an integer priority. Each Blob that is waiting on it was setting its own import and priority even though the QQmlQmldirData itself was shared. This resulted in whichever one began loading last succeeding to load, and the rest failing. This change instead stores the import and priority data per-dependent Blob Fix was originally done by Josh Faust <jfaust@suitabletech.com>. I added the test. Task-number: QTBUG-30469 Change-Id: Id3d15569a999a7c22eeb12b431e5daf1ddae51dc Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add missing header inclusionKimmo Ollila2017-03-281-0/+1
| | | | | Change-Id: I7c215db87552c63291e6c82d7b962ee17ec2f610 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9Simon Hausmann2017-03-251-7/+45
|\
| * Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-7/+45
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qqmltypecompiler_p.h src/qml/qml/qqmltypeloader.cpp src/qml/qml/qqmltypeloader_p.h Change-Id: I4894555ab7a0879b56bbda7a46d16d1c40c19e7c
| | * Fix QQmlTypeLoader::Blob::qmldirDataAvailable memory overwriteJosh Faust2017-03-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | An invalid iterator was being dereferenced. Task-number: QTBUG-59268 Change-Id: I58635667ab4591c06f1d7644243b83fd0172e74f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| | * Fix caching of QML singleton typesSimon Hausmann2017-03-131-2/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a QML file depends on a QML singleton, we failed to include it in the dependency hash. Thus changes to the QML singleton did not result in a re-creation of the caches of files that use it. The list of singletons comes from random-ordered hashes in the qml import handling. We provide an order to the direct dependencies by sorting by the singleton type names. Task-number: QTBUG-58486 Change-Id: Ie7e9d006f9bf3a60af1f819ee439c29bc234bd8a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| | * Clean up type dependency hashing for QML cachingSimon Hausmann2017-03-131-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of passing the engine parameter all the way through the data structure generator, along with the dependent type data structure that is unused otherwise, let's simply provide a function object for the dependency hashing. This is also in preparation for adding singleton types to the dependency hash. Task-number: QTBUG-58486 Change-Id: I5bb5e5c06b7b5c77195cec3da13141333cfea7a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Speed up source code readingSimon Hausmann2017-03-221-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since we always convert the source code of .qml/.js/qmldir files from utf-8 to utf-16, we always end up copying bytes around. That means instead of allocating memory on the C++ heap and copying bytes from kernel space to user space and then a few times through QIODevice buffers until we reach QString::fromUtf8, we might as well mmap() the file directly - if possible. Change-Id: I54c88d4d9f03f9967130d65a7b53cfec93734018 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Avoid an extra stat() on the source .qml file when loading cacheSimon Hausmann2017-03-221-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | For timestamp comparison it is not necessary to create another QFileInfo() object and call exists() and lastModified(), when we can pass that information through from the type loader. Change-Id: I225cd36e672f1f390bddb4e6ebfafa3fc1269795 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Avoid reading (not parsing) .qml files when using the cacheSimon Hausmann2017-03-211-31/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making SourceCodeData copyable we can delay the reading of the source file until we really need to. This also allows persisting the QFileInfo object and therefore having only one stat() call to check if the file exists, what its size is and what the last modification time is. Change-Id: Ic7e4d5f566d870f3b1fa8302227417fa813cb139 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Simplify internal source access APISimon Hausmann2017-03-211-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All call sites of QQmlDataBlob::Data immediately convert the data to UTf-8 - for .qml, .js and qmldir files. We can simplify the code by reflecting that in the API and that also opens up the possibility for future optimizations. This means that the bi-pointer has to go, but at the moment the Data object is stack-allocated anyway. Since the "Data" class always represents source code, it is now called SourceCodeData. Change-Id: Icd262ed1e35f9edd64945ba6c16d80f9917eae72 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Remove unused macroSimon Hausmann2017-03-171-4/+0
|/ / | | | | | | | | | | | | This duplicate of qOffsetOf is not used in this file. Change-Id: I8a5ddfe18202501605a06f65c952b58e557dbfac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix relocation related errors when loading AOT cachesSimon Hausmann2017-03-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original directory of the source file the cache was created from - when generating ahead of time - is unlikely going to be identical to the final location for example on a deployed device. Therefore when generating caches ahead of time, don't store the source path, don't attempt to verify it when loading and don't try to save the cache file at run-time again. We still need set the sourceFileIndex at load-time though, in order to make relative path url resolution work (for example source: "my.png" in an Image element). Change-Id: I3d6952f5d0a165cfa2cb400191a9f6ffe6be69f4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Re-do QML type compilation of ahead-of-time generated QML cache filesSimon Hausmann2017-01-311-0/+14
| | | | | | | | | | | | | | | | | | | | As we currently lack the ability to do type resolution at AOT cache generation time, we need to re-do the work after loading the cache file, making us essentially only re-use the code and avoiding the step of parsing. Change-Id: I12844692d4766345d8a313b59d21abf1f868e2d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Enable resolution of composite types in QQmlTypeNameCacheRobin Burchell2017-01-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We didn't have resolution of composite types previously, which is a prerequisite to do more exciting things with QML types in JavaScript (such as instanceof). By deferring the resolution to QQmlImports, we can avoid the need to fill the cache with types that may not be needed, while still finding types which are requested. In the future, we could consider removing the "special" handling for composite singletons as they should be found through QQmlImports now. If we do that, we may still want to cache the QUrl for the types, to avoid using QQmlImports too often directly, as it is a little slow itself. This change doesn't regress tst_compilation. Task-number: QTBUG-24799 Change-Id: I9ba2e4829ca49008fd180fb488c586475cf90674 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Un-nest QQmlTypeLoader::QmldirContentRobin Burchell2017-01-261-21/+21
| | | | | | | | | | | | | | | | | | This is mandatory to split some of QQmlImport's internal classes out into headers for reuse elsewhere, as we cannot forward-declare a nested class. Change-Id: I6524a372a89b37a22a99ed3eada76036e10e8660 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | qml: Rename importCache vars to typeNameCacheRobin Burchell2017-01-251-24/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This better reflects what it is, and especially removes some confusion in QQmlTypeCompiler which has a m_importCache member (of type QQmlImports), which lead to some strange-to-read things like this: m_importCache.populateCache(*importCache); Which is now: m_importCache.populateCache(*typeNameCache); Change-Id: I7590dd1ba71ca77a8d964250a0d517156b723f8e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QQmlTypeLoader: Deduplicate type resolution codeRobin Burchell2017-01-241-42/+8
| | | | | | | | | | Change-Id: I325a0c27f4a851d91876612c5eb2da08bd1fb75e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | qml: Remove last foreach, and mark QT_NO_FOREACHRobin Burchell2017-01-171-1/+1
| | | | | | | | | | | | | | Just src/imports/ to go... Change-Id: Ib4484676e24655cb950b3c4bb6495ff0e7f9700f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-2/+1
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
| * Start cleaning up the QmlContextWrapperLars Knoll2016-12-041-2/+1
| | | | | | | | | | | | | | | | | | The class should get merged with the QV4::QmlContext class. Simplify the cleanup by moving both classes into a common file. Change-Id: I0074da79701d5f41eb51681b70fcde85bfd45fc1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml: mark some methods as constAnton Kudryavtsev2016-10-241-1/+1
| | | | | | | | | | | | | | These methods do not modify objects. Change-Id: Iefe8effa97e6f6142308d61d57d08f9dc14a7709 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-221-0/+1
|\| | | | | | | Change-Id: I171c7dbb6a74fe743c2eec63e86e9c0bef7c7dfd
| * Fix excessive invalidation of QML disk cachesSimon Hausmann2016-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use an MD5 checksum over the meta-object data to verify that the types a QML file depends on haven't changed since the cache was generated. However when the dependent types are QML types, then the meta-object data contains dynamically generated type names such as QMLTYPE_1234, which is non-deterministic. To address this, we resort to the checksum over the meta-object data only for C++ types (if those change it's likely an incompatible change) and for QML types use the fact that all the information about the QML declared types comes from the QML file only, which means we can in that case simply use a checksum over the QV4::CompiledData memory chunk. In addition we need to ensure that the generated CompiledData memory chunk is deterministic by avoiding any uninitialized bytes (memset) and using a map instead of a hash for the mapping of object index to object id. Task-number: QTBUG-55926 Change-Id: I27c840b1960ad36b486198e504b70989c22a3972 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-181-30/+35
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4variantobject.cpp src/qml/types/qquickworkerscript.cpp src/quick/scenegraph/util/qsgdefaultpainternode_p.h tools/qmljs/qmljs.cpp Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
| * Fix written time stamp in QML cache files for QRC sourcesSimon Hausmann2016-10-141-2/+8
| | | | | | | | | | | | | | | | | | | | For loading and verification we compare against the time stamp of the executable, so we should do the same thing when generating the cache data. Task-number: QTBUG-55926 Change-Id: If5922e76b8ae86185f6eacb6aeeb5c3afbc1f8d5 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
| * Turn the no-network support into a configurable featureLars Knoll2016-10-101-22/+22
| | | | | | | | | | | | Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * QQmlTypeLoader: Clean up trimCache()Ulf Hermann2016-10-061-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Any type that: a, has exactly one reference (from the type cache) b, has finished loading, and is thus either in Error or Complete state c, either has no compiled data or again exactly one reference on the compiled data (from the type) is not needed anymore and can be trimmed. The previous logic would not trim types with errors that have received compiled data by loading from a file and it was generally harder to understand. Change-Id: Ieb9ce29599411ea5516742b874cbcf3dcab03bde Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml: add missing 'override'Anton Kudryavtsev2016-10-071-2/+2
| | | | | | | | | | | | | | ... and drop redundant 'virtual' Change-Id: Ib1f68c1ebd0468cb4a77eecc986bbf718f6bf789 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-011-2/+5
|\| | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4qobjectwrapper.cpp Change-Id: I1a125b2334532ec5de4af39c0d6628890f4d0587
| * Merge remote-tracking branch 'origin/5.7' into 5.8Liang Qi2016-09-211-2/+5
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmltypeloader.cpp Change-Id: I07647700fc86764c95a5ef95c568e700a70fe45f
| | * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-09-161-2/+4
| | |\ | | | | | | | | | | | | Change-Id: Ib45654e3e79087da4754377f0d78b70c44ed4695
| | | * Allow for garbage collection of types with errors in trimCache()Michael Brasser2016-08-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I821ea14f60871735bface4e2cf4e61fcb61b2784 Task-number: QTBUG-55567 Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| | | * QML: Only release types if they aren't referenced anymoreUlf Hermann2016-06-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just checking for references on m_compiledData is not enough. The actual component can also be referenced. Thus it won't be deleted on release(), but cannot be found in the type cache anymore. Task-number: QTBUG-53761 Change-Id: I8567af8e75a078598e4fed31e4717134e1332278 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | Qml: replace 'foreach' with 'range for'Anton Kudryavtsev2016-09-201-6/+9
|/ / / | | | | | | | | | | | | | | | | | | Not all, just instances with low risk. Change-Id: Ie6b4530f748e04ccb90e7ef23415a91d6c377417 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Make the unit mapping on Windows configurable with regards to executable mappingSimon Hausmann2016-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we generate byte code, then we can mmap without the executable flags, otherwise we need them. This should make things work out of the box on platforms where special rights are needed before executable mappings are allowed. Change-Id: I24e663f85d661bc51cd3bf2463547b1d1590ea32 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | | Fix import with qualifier of remote directory with qmldirArnaud Vrac2016-08-101-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not skip qmldir loading when using an import qualifier and the resolved uri is remote. This makes the import behavior the same in all cases. Task-number: QTBUG-55002 Change-Id: I99d68be02ddd062e387d36946e730df076e80a8d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Enable disk caching on WindowsSimon Hausmann2016-08-101-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to enable the disk cache we need to replace the QFile::map usage with direct win32 file API calls in order to create executable file mappings. The files opened with QFile lack GENERIC_EXECUTE in the open flags. The code remains disabled on WinRT for now. Change-Id: I7d12267755a9de0344ac087b2ff67140531d9df0 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
* | | Qml: optimize string usageAnton Kudryavtsev2016-08-091-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QStringBuilder more. Use QString::asprintf instead of arg()'s chain. Use += operator to reserve extra capacity for possible free following append/prepend/+= call. Change-Id: Ib65398b91566994339d2c4bbfaf94e49806b7471 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | | Centralized deferred cleanup handlingSimon Hausmann2016-08-091-13/+2
| | | | | | | | | | | | | | | | | | | | | Move the lambda cleanup code into a shared header file for re-use. Change-Id: Ib9fb7dce98200bcad2bb688740f9b6c2a1e4aae7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Qml: use const (and const APIs) moreAnton Kudryavtsev2016-08-091-2/+1
| | | | | | | | | | | | | | | | | | | | | For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I13e4d5b091877319984c1ddaed4da8dc59a7c0a3 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | | Enable QML/JS disk cache by defaultSimon Hausmann2016-08-051-9/+16
| | | | | | | | | | | | | | | | | | | | | Except on Windows, where there is still one bug to fix. Change-Id: I1a22f42859733eedd37596a3e8fc09680720ff10 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Fix QML engine in MSVC debug buildsSimon Hausmann2016-08-051-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In debug builds MSVC does not do return value optimization and therefore would call the destructor and thus callback on the temporary, a rather unwanted side-effect. Let's use a different approach that is guaranteed to avoid temporaries. Change-Id: I534258754331495db38cd7960b88bf4bec38ddba Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Disable disk caching when debugging JavaScriptSimon Hausmann2016-08-051-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | The debugging changes the code generation and is currently not suitable for caching. Change-Id: I40db58a5f24457cf3383d08a1de3a4168874056f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Use on-disk compilation unit if availableSimon Hausmann2016-08-041-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we succeeded in saving the compilation unit to disk, then attempt to use it right away. This replaces the C++ heap usage for the compilation unit data as well as the anonymous allocated executable memory with file-backed mmap'ed memory. That means the memory can be discarded when overall availability is low and paged in on-demand. Change-Id: Ide1b1e11752d861eb049a99a26ca12cec5e2502e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Fix interaction of files selectors with disk cachingSimon Hausmann2016-08-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Make sure to save the .qmlc/.jsc files to the location determined by the file selectors. Change-Id: If535bb1e4f0d20ac692b3d8e6d563f77cd00446b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Safeguard disk cache loading with checksum verificationSimon Hausmann2016-08-041-38/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When loading a QML component from the disk cache, compare the checksum of the dependent types against the checksum when the cache was created. Any change in the meta-object of a dependent type should trigger a re-creation discard of the cache and consequent re-creation (in the test-case). Unfortunately this also requires extending the existing hack in the unit test to deal with the low second precision on HFS+ in order to pass the tests. Change-Id: Ib8e899347680f7be676788388e9c23a09b0277e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Improve debug output handling of disk caching codeSimon Hausmann2016-08-021-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use categorized logging to make the debugging output of disk caching more selective and also not interfere with the output expected by unit tests. Change-Id: I0f42060326dfface54d4e74da5777ffb894f5937 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-1/+2
| | | | | | | | | | | | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>