aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash when calling QQmlEngine::clearComponentCache()Simon Hausmann2018-04-101-2/+7
| | | | | | | | | | | | | | | | | We must protect various resources in the type loader with our existing lock. The QQmlTypeLoaderQmldirContent is now value based, so that we can release the lock on the shared cache early. Copying it involves adjusting the refcount of the QHash and QString instances in the QQmlDirParser. The safety of this was verified with a TSAN build and the example supplied in the task. It crashed reliably with TASN errors first and with this patch it runs without errors. Task-number: QTBUG-41465 Change-Id: I616843c4b8bdfd65d1277d4faa8cb884d8e77df8 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit a3ad52526f79c1528f170c8affe5af00b68ca61d)
* Use potentially intercepted URL as ID for compilation unitsUlf Hermann2017-12-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | We generally have to pass a URL and a file name everywhere because the logical URL might be something else than the actual file being loaded. For example a QQmlFileSelector might modify the URL to be loaded for a specific file. This resulting URL, however, should not be used to resolve further URLs defined in the file loaded that way. As we need to access QQmlTypeLoader::m_url as string more often now, cache it and avoid frequent translations between QUrl and QString. Furthermore, QQmlDataBlob's URLs are changed to follow the same semantics. The finalUrl is the one that should be used to resolve further URLs, the url is the one used to load the content, and subject to any redirects or interceptions. This changes the semantics of URL redirects. Previously a redirected URL was used as the base URL for furher URL resolution. This doesn't work because redirection occurs after interception and interception should not influence the resolution of further URLs. We now use the original URL as base URL for resolution of further URLs and rely on the server to redirect those, too. Task-number: QTBUG-61209 Change-Id: I93822f820bed2515995de3cb118099218b510ca4 Reviewed-by: Michael Brasser <michael.brasser@live.com>
* Prevent the QML engine from registering circular dependenciesErik Verbruggen2017-11-061-0/+1
| | | | | | | | Change-Id: Ic4fd2bde745e7dfaf0909e8cc575441bb04cefa3 Task-number: QTBUG-64017 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Marco Martin <mart@kde.org> Reviewed-by: Bhushan Shah <bshah@kde.org>
* Tell QQmlImportInstance::resolveType what kind of type we wantUlf Hermann2017-10-191-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | In QQmlTypeData::resolveTypes() we know if we're looking at a reference to a composite singleton type, or some other type reference. When we call resolveType() we expect the correct type to be returned, not only based on URL, but also based on its singleton property. QQmlTypeData::resolveType() eventually invokes QQmlImportInstance::resolveType() which will call fetchOrCreateTypeForUrl(), passing a parameter on whether the result should be a composite singleton. When operating on a qmldir component the component itself encodes this. When fetching a type from a local file without qmldir, we currently assume that it isn't a singleton, no matter QQmlTypeData::resolveTypes() has determined. This means that actual singletons loaded this way later get refused by the sanity check. In order to fix this, pass the information about the expected singleton property on to QQmlImportInstance. This is done using QQmlType::RegistrationType, which gets another entry for "any type". If the expected type is CompositeSingletonType QQmlTypeData::resolveType() will not create a non-singleton type. If it is any specific other type, it will not create a composite singleton. And if it is AnyRegistrationType, it will behave as it previously did. Change-Id: I6b7e082b63582e0aed946bb3d19077b94c7a45f7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlTypeLoader: The profiler is a quintptr(0) if QT_NO_QML_DEBUGGINGUlf Hermann2017-09-271-2/+2
| | | | | | | | | | This follows the pattern established in other places. Task-number: QTBUG-63392 Change-Id: I11cd66d5552f751804dd0a9460b26bda546c1726 Reviewed-by: Mikko Gronoff <mikko.gronoff@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
* Qml Tooling: Replace bare pointers with QScopedPointerUlf Hermann2017-09-061-4/+4
| | | | | | | This way we don't have to manually initialize and delete them. Change-Id: I0104c744dba380e957271d0924498e3643856e9e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QmlProfiler: Avoid race conditions in QQmlTypeLoaderUlf Hermann2017-09-051-0/+15
| | | | | | | | | | | | | We have to make sure all profiler calls to one adapter are done from the same thread. It turns out that all the calls from QQmlTypeLoader are done from the type loader thread. By using a separate adapter for that, we avoid any extra locking. Task-number: QTBUG-62987 Change-Id: I5cffcc30b84dd4154daa0c56312a1141ce2033e1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Reduce memory consumption of stat() cache in QML type loaderSimon Hausmann2017-08-021-2/+2
| | | | | | | | | | | The m_importDirCache caches the result of QDir/File::exists across paths. By changing the data structure to a QCache we impose a limit on the size of the entries and thus the memory consumption for long running programs that access many qml files. Task-number: QTBUG-61536 Change-Id: I20c4dc77260fe353c13da570b7e1bbd3f47d4b79 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QQmlType by valueLars Knoll2017-08-021-2/+2
| | | | | | | | | | | QQmlType is now refcounted, and we need to use it by value, to control it's lifetime properly. This is required, so we can clean up the QQmlMetaTypeData cache on engine destruction and with trimComponentCache() Task-number: QTBUG-61536 Change-Id: If86391c86ea20a646ded7c9925d8f743f628fb91 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix concurrent loading of the same qmldir from different scriptsAndy Shaw2017-05-021-6/+6
| | | | | | | | | | | | | | | | 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>
* Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9Simon Hausmann2017-03-251-1/+2
|\
| * Merge remote-tracking branch 'origin/5.8' into 5.9Simon Hausmann2017-03-151-1/+2
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 caching of QML singleton typesSimon Hausmann2017-03-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Avoid an extra stat() on the source .qml file when loading cacheSimon Hausmann2017-03-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-17/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Re-do QML type compilation of ahead-of-time generated QML cache filesSimon Hausmann2017-01-311-0/+1
| | | | | | | | | | | | | | | | | | | | 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>
* | Un-nest QQmlTypeLoader::QmldirContentRobin Burchell2017-01-261-30/+30
| | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | Change-Id: I325a0c27f4a851d91876612c5eb2da08bd1fb75e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | headers: Add missing override and remove redundant virtualAlexander Volkov2016-12-071-2/+2
| | | | | | | | | | | | Change-Id: Ifa816ebcd79372afca42dbd0dc0ecde006bb688a Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> 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-181-6/+7
|\| | | | | | | | | | | | | | | | | | | 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
| * Turn the no-network support into a configurable featureLars Knoll2016-10-101-6/+7
| | | | | | | | | | | | Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml: add missing 'override'Anton Kudryavtsev2016-10-071-16/+16
|/ | | | | | | ... and drop redundant 'virtual' Change-Id: Ib1f68c1ebd0468cb4a77eecc986bbf718f6bf789 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Disable disk caching when debugging JavaScriptSimon Hausmann2016-08-051-0/+2
| | | | | | | | The debugging changes the code generation and is currently not suitable for caching. Change-Id: I40db58a5f24457cf3383d08a1de3a4168874056f Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Safeguard disk cache loading with checksum verificationSimon Hausmann2016-08-041-2/+8
| | | | | | | | | | | | | | | 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>
* Add a checksum to the generated QML compilation unitsSimon Hausmann2016-08-021-1/+3
| | | | | Change-Id: Icd5b1d805059981cbbb4c0eb2a5c842d59223839 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Cleanup: Move ResolvedTypeReference(Map) one scope upSimon Hausmann2016-08-011-1/+4
| | | | | | | | The class is a candidate for further functionality, it doesn't have to be nested in CompilationUnit. Change-Id: I100553160f5ae34f66b9f8ff5df9f636da2ffb67 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Improve robustness of qml cache expiry checkingSimon Hausmann2016-07-191-1/+1
| | | | | | | | | | | Instead of relying on two time stamps in the file system (source file and cache file), make the determination on whether the source file is newer than the cache solely depend on the time stamp of only the source file. This means that when cache files are stored in archives for example their modification date does not need to be preserved upon extraction. Change-Id: I0b4362663868c6fb9bd7e106028161b2d67274d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Added basic loading of compilation units from diskSimon Hausmann2016-07-191-0/+2
| | | | | | | | This remains hidden behind the QML_DISK_CACHE flag until all backends support it and the verification code is in place. Change-Id: Ic77c64e20a2dc4c43473c47640e09f8070237e85 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move type compilation independent bits out of QQmlTypeCompilerSimon Hausmann2016-06-201-0/+1
| | | | | | | | | | The type validation is something that works on the final compilation unit, so it can be done separately. The same applies to the composite type registration and object/binding calculation. Both steps will be shared with compilation units loaded from disk. Change-Id: I43636d7ac76077c76289d7c1c9eba5e9c6b8239a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Minor cleanup for implicit import handlingSimon Hausmann2016-06-201-1/+0
| | | | | | | | We don't need the m_implicitImport member in the QQmlTypeData when it is used in only one function and generally a pointer into the memory pool. Change-Id: Ib3de07631a6626ba1ebdf9e6fef379af1231fd24 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up pragma singleton handling in the type loaderSimon Hausmann2016-06-201-2/+0
| | | | | | | | | Get rid of the m_isSingleton boolean by checking the CompiledData::Unit::flags after the type compilation. This is more compact and makes the singleton type checks independent from the IR. Change-Id: I04189d284e6ea275ac8540918836b641914e7588 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Clean up file/error handling in the type loaderSimon Hausmann2016-06-201-43/+4
| | | | | | | | | | | Fold the functionality of reading QFile contents via QQmlFile into QQmlDataBlob::Data. This reduces the dependency on QQmlFile - which is scheduled for removal - and it makes it possible in the future to avoid reading the file altogether if we have a cached compilation unit on disk. Change-Id: Ieeaf52b6fb1d25665cd3c3b196819e25aba3dd15 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Moved import cache and type resolution cache codeSimon Hausmann2016-06-171-4/+4
| | | | | | | | | | The code reads mostly from QQmlTypeData internal data structures, so it's cleaner to move it there - we can remove the getters for these internal fields. And it also allows for re-use later when not using the type compiler. Change-Id: I36cfaf3f1cecd6c8b223ee08516884a07bc60d6c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup: generalize type reference collection codeSimon Hausmann2016-06-141-0/+1
| | | | | | | | | | For loading compilation units from disk we'll have to scan the unit for type references, in order to correctly load dependencies. In preparation for that this patch template'izes the loops so that they can work on the Qml IR as well as on the CompiledData::Object structures. Change-Id: I32e4e3277e16c5a2d1bf6baf24456c9837c189ff Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Another manual refcounting cleanupSimon Hausmann2016-06-071-1/+1
| | | | | | | | There is little reason to use manual reference counting for an encapsulated member. Change-Id: I024a6ff700872da6837954a5167e502487e9b12c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove QQmlCompiledData in favor of QV4::CompiledData::CompilationUnitSimon Hausmann2016-06-011-3/+2
| | | | | | | | | QQmlCompiledData used to contain the binary data for instantiating QML types in the QML VME. Nowadays the QML type compiler as well as the JavaScript compiler create a QV4::CompiledData::CompilationUnit. Change-Id: I155f62a5ecfb55a3fe230520231b6d8fd5b28ac9 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-04-271-0/+2
| |\ | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quick/items/qquickimagebase.cpp src/imports/layouts/plugin.cpp Change-Id: I5f48474df4034a1347ec74795c85d369a55b6b21
| | * Occasionally trim the type cacheUlf Hermann2016-04-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As loaded components are kept in a cache, they are never removed by the garbage collector. So, if you periodically create new components, they leak. This change adds a floating threshold for the number of components. When that threshold is surpassed trimCache() is called and unneeded components are removed. Task-number: QTBUG-42055 Change-Id: I30e3e4ee287f6d34376713668009c67614a50e0c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | | QtLite: no_network option for QtDeclarativePaolo Angelelli2016-03-041-0/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | This patch adds the support for a no_network option for QtDeclarative, and the necessary #ifndef all around the code. no_network changes the interface of some classes, therefore using it breaks source compatibility. Change-Id: Iff612fb07041b8a7db99bd595bf038efaac2dd8a Reviewed-by: Risto Avila <risto.avila@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* / Updated license headersJani Heikkinen2016-01-191-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Load component synchronously in method_createQmlObjectUlf Hermann2015-11-031-2/+9
| | | | | | | | | | | setData() is not guaranteed to synchronously load the type. In fact, most of the time, it doesn't. However, by adding a private Synchronous mode to QQmlTypeLoader we can prefetch the type synchronously and then inject it into the component. Task-number: QTBUG-45418 Change-Id: I640f12ad20c01b778b5bc41f43574d8aea504195 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix function signatureLars Knoll2015-09-221-1/+1
| | | | | | | Returning a PersistentValue doesn't make much sense. Change-Id: I6044a12e48aa835ef78008e070bacda5125a7ca7 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.hLars Knoll2015-04-241-1/+1
| | | | | | | | This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Typeloader cleanupSimon Hausmann2015-01-231-6/+9
| | | | | | | | | | | | | | | | | | The QQmlDataBlob base class had a typeloader member that was provided with startLoading() later, just to allow calling the url interceptor. The one sub-class of QQmlDataBlob - QQmlTypeLoader::Blob - also had a typeloader pointer, provided at constructor time. This patch cleans this up by removing the duplicated typeloader pointer in the sub-class and passing it straight through to the base-class at construction type. This also allows moving the url interception to the constructor. Also fixed the findCachedCompilationUnit calls to use the url after applying the intercept and removed one unnecessary findCachedCompilationUnit call - the QFile::exists call is sufficient. Change-Id: If5c49d38a6ec66fea6cd7c21013c046cf75acafd Reviewed-by: Lars Knoll <lars.knoll@digia.com>