aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatypedata_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QQmlMetaTypeData: Key nameToType by QHashedStringUlf Hermann2020-06-291-1/+3
| | | | | | | | | As the new QMultiHash does not store a separate copy of the key for each value, we'd get dangling string references when the "wrong" values were removed. Change-Id: I4ccf6db8bdbf4d38ef393b66b61b285ce763f5c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Discern between "auto" and versioned imports in qmldirsUlf Hermann2020-06-241-0/+3
| | | | | | | | | | | | | You can now import the latest version, a specific version, or, "auto" which is the same version as the parent module. [ChangeLog][QtQml] You can now procedurally add module imports to modules, using qmlRegisterModuleImport(). However, actual import statements in qmldir files should be preferred wherever possible. Fixes: QTBUG-84899 Change-Id: I3b32dd8b07a19d31b6538b9a6bb436840862f345 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlMetaTypeData: Use a better container for the type modulesUlf Hermann2020-06-181-5/+15
| | | | | | | | | | | We often want to retrieve all type modules of a specific URI, no matter what version. Use a sorted vector to make those available without iterating all modules. Also, use a unique_ptr rather than manual memory management. Sorting the pointers should be fairly cheap, and we also don't have to store the keys anymore. Change-Id: I132c2ec3817afab1d60c3ba832d0b907ff6bfeb0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Refactor QQmlMetaTypeData::VersionedUri a bitUlf Hermann2020-06-181-7/+10
| | | | | | | | The hash function should take a seed, and properly combine the hashes, both operator== and qHash are better defined as friends. Change-Id: I770a725b72477689a654078da6f57f750a85abbd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix race condition in QQmlData::createPropertyCacheFabian Kosmale2020-06-051-1/+1
| | | | | | | | | | | | | | As noted in QJSEnginePrivate::cache, there can be a race between calling addRef on the QQmlPropertyCache and another thread derefing and consequently deleting it. To avoid this, we introduce a doRef flag in QQmlMetaTypeData::propertyCache, which tells it to ref the the cache. This fixes the issue, as the QQmlMetaTypeDataPtr in propertyCache() acts as a mutex. Fixes: QTBUG-84692 Pick-to: 5.15 Change-Id: I962d28cfd22696aad89a660e41c55f63a8791b44 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Change qHash return value to size_tFabian Kosmale2020-04-161-1/+1
| | | | | | | | Else on Windows there's a warning: conversion from 'size_t' to 'uint', possible loss of data Change-Id: Ifed4899409a13fed31c206ae1e0f195280ee2925 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Adapt to the the new QMetaType changeOlivier Goffart2020-03-091-4/+3
| | | | | | Fixes: QTBUG-82453 Change-Id: I7e5682945a07c3af183becd3947a69568f139d16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Process major versions as part of Q_REVISIONUlf Hermann2020-02-131-2/+2
| | | | | | | | Retrieve the major version from the meta object revisions and use them to register types and generate qmltypes files. Change-Id: I35da8963457660d1a49ba9063574e1a68057a7ba Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-11/+10
| | | | | | | | | | | | | | In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QMultiHash when duplicate keys are wantedMÃ¥rten Nordheim2019-12-101-2/+2
| | | | | | | | | This also implicitly changes a previous simple QHash::insert to a QMultiHash::insert, changing its semantics. Change-Id: I6ebafe83e9e374f2e1a4c7cd69adbc2d14e095a1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Register compiled-in QML typesUlf Hermann2019-11-071-1/+1
| | | | | | | | | If we compile the QML types into the main application we cannot depend on plugin loading for triggering the registration. Rather, we need to register them immediately. Change-Id: I910fb13359f8b7524eafd7693c85205cb4ed4cd8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add support for semi-automatic QML type registrationsUlf Hermann2019-10-141-0/+4
| | | | | | | | | | | | | | | We can use the new moc JSON output to collect all meta-objects at build time and, for those that include QML element registration meta-data, generate code that automatically registers these types with QML. This eliminates the need to call qmlRegisterType manually. For now this generates free-standing functions (per module) that need to be called manually. This is intended as an intermediate step. Task-number: QTBUG-68796 Change-Id: Ib414eef9757344feee488ebc7388f957b975347f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use qmlProtectModule to protect a module from further modificationUlf Hermann2019-10-081-4/+0
| | | | | | | | | | | | | | | | | | | | | | We don't need two mechanisms to do essentially the same thing. QQmlTypeLoader::Blob::addImport() had an "optimization" to never check for qmldir files of locked imports. This meant the first time you imported a module with a plugin that locked the module you could use the qmldir file to load additional .qml files afterwards. The second time you imported the same thing, you couldn't. As this is not a great example of consistent behavior, we drop this optimization and always allow the qmldir files of plugins that lock the module to specify additional QML files. As a side effect of this, additional plugins listed in a qmldir file can also now be loaded after the module has been locked by some other means. However, any qmlRegisterFooBar() called from the module will be prevented. Change-Id: Idabb2bd5f75fc85b62f42625173672b4ae84382e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-231-19/+0
| | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp Change-Id: Ieff61c076e46eb50a059c8b0210f7f4d7ce0cbcf
* Move propertyCache-by-minor-version into QQmlMetaTypeDataUlf Hermann2019-04-181-0/+6
| | | | | | | | | | | | Ths data structure should only be accessed when protected by the metatype data lock. In fact we don't access it from anywhere else. To make that more obvious, move it to the right place. This allows us to eliminate some const_cast and poking around in QQmlTypePrivate from the outside. Change-Id: I16ffd240b9504b9c00010bdb2d17b05c8196fe8a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-02-251-1/+1
| | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp Change-Id: I517c001ea4eb0fdd8e469f9fffe5b7559a5b0795
* Eliminate excessive friendlyness of QQmlTypeUlf Hermann2019-02-081-0/+19
| | | | | | | | | | | | QQmlMetaTypeData does need to be exposed to the QQmlType ctors. Rather, we can use factory functions to create the QQmlTypePrivate objects. The static attachedPropertyIds should really be part of QQmlMetaTypeData and access to them should be protected by the lock. Task-number: QTBUG-73271 Change-Id: I154a3842fab03a02c710901a20afd1652364808d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move registration functions from qqmlimport.cpp to qqmlmetatype.cppUlf Hermann2019-02-081-7/+8
| | | | | | | | | | | | | | | | | These functions require the metatype data in multiple interdependent places. If they are executed concurrently data races are almost guaranteed. Move the functions to qqmlmetatype.cpp and keep the metatype mutex locked for their duration. Access to the internals of the metatype system also allows us to significantly simplify the logic. Additionally we can remove methods only used by those functions from the public interface of QQmlMetaType now. Task-number: QTBUG-73271 Change-Id: I1279259cca5cb5be63026d5b74f5d013e7a1ac5c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Split qqmlmetatype{_p.h|.cpp} into multiple filesUlf Hermann2019-02-061-0/+141
Having all those classes in one big file promotes spaghetti code and makes the code unreadable. Change-Id: I3b6df93b9cfe1d97228771049b3054e78b868ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>