aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlimport.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Match specific module imports also for versionless QML importsUlf Hermann2020-06-291-123/+173
| | | | | | | | | | Previously, if you registered a module import for a specific version X of a module, and the user imported the module without specifying a version, the module import would not be carried out even if X was the version actually imported. Change-Id: I853ed6f275501cf4cbd4e5a360985e67b07f3773 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Lock all type modules of the same URI when importing a pluginUlf Hermann2020-06-181-1/+1
| | | | | | | | | | | | | A plugin may provide multiple versions of the same types. If we don't lock them all, a further plugin may later mess with the ones we didn't lock. The code clearly attempts to prevent such a situation. Of course, a plugin may still register types under a wholly different URI, and sidestep this mechanism. However, in contrast to exposing multiple major versions from the same plugin, this is not recommended. Change-Id: Ib8d8bbeec8e738020c6d07aedcc4664157b80dcf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify error messages in qqmlimport.cppUlf Hermann2020-06-171-30/+31
| | | | | Change-Id: Iaa899f76f62273dd7cd5808ee090fcc6fcebf660 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Drop the "plugin cannot be loaded" extension to error messagesUlf Hermann2020-06-171-16/+0
| | | | | | | | This message adds very little extra value, and it complicates the tests that check for specific errors. Change-Id: I58553a8cbc56c3333c8e9815518cca5fa01fdde1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-161-7/+7
| | | | | | | | Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Remove QtQuick.Window pluginUlf Hermann2020-06-151-0/+2
| | | | | | | | | | | | | | | | | We move all the types into QtQuick itself and retain QtQuick.Window only as alias to QtQuick. This requires support for qmldirs that consist of only an import statement. [ChangeLog][QtQuick][Important Behavior Changes] The contents of the QtQuick.Window QML module have been moved into the QtQuick module. QtQuick.Window is merely and alias for QtQuick now. An explicit import of QtQuick will override this alias. Therefore, if you import QtQuick with a different version than QtQuick.Window, you will get the QtQuick.Window types of the version given in the QtQuick import now. Task-number: QTBUG-84639 Change-Id: Ia82afab0ac2faba70cfdaf53dc8dfe4261e1113f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Fix precedence of module importsUlf Hermann2020-06-111-24/+43
| | | | | | | | Types imported transitively via a qmldir import statement should not shadow types available from the module itself. Change-Id: Id34edc5c5e2fff4ba37009f4bab9039b7ed18dff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlImport: Parse resource paths from QML2_IMPORT_PATHUlf Hermann2020-06-101-6/+22
| | | | | | | | | We can interpret double colons as start of resource paths. Task-number: QTBUG-69435 Change-Id: If2b4412c28c7c59f160ddfcfe04ec293af437660 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Deduplicate the import resolution algorithmUlf Hermann2020-06-101-53/+5
| | | | | | | We will need it in various other places, too. Change-Id: I61c55f88b66ab85448ae8fff125fe34108532fc4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove uri member from loaded plugins mapUlf Hermann2020-06-091-19/+4
| | | | | | | It is only used for error messages and asserts. Change-Id: Ib68d25e4341d4a0b8cebce0a72ddef9005202707 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML imports: Improve naming and safety of path-to-plugin mapUlf Hermann2020-06-091-48/+63
| | | | | | | | We need to make sure the global map is always locked when using it, and we may not necessarily register any types from the plugins we load. Change-Id: Ib9da33baa9597b112408251e0cf01b5bb735ec42 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow QML plugins to be optionalUlf Hermann2020-06-091-50/+74
| | | | | | | | | | | If a plugin does nothing but load the library that provides the types, we can skip the plugin loading by linking the library directly. State that in the qmldir file, and evaluate it when loading the module. Task-number: QTBUG-84639 Change-Id: I2097237866a50f66c55e4653ad119fe10e18a893 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlImport: Make plugin resolution functions const and publicUlf Hermann2020-06-051-2/+2
| | | | | Change-Id: If21f788807cbcf5b134a9af5713eec6ec60fb362 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-181-0/+18
|\ | | | | | | | | | | | | Conflicts: tools/qmllint/findunqualified.cpp Change-Id: I2593b5cc0db1d14e0c944aec4b88a80f46f5b0c1
| * Prefer Inline Components over any other imported nameFabian Kosmale2020-03-161-0/+18
| | | | | | | | | | | | | | | | | | | | | | After processing all other imports, there might be other imports both in front and behind of the inline component imports in the import list. To avoid having to search for them, we sort the list so that they are in front. Fixes: QTBUG-82302 Change-Id: I9f6deb03608b1ebd0cbe0eddd1a1e5d39837a783 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Allow multiple URL interceptors per engineUlf Hermann2020-03-171-9/+8
| | | | | | | | | | | | | | | | | | | | | | We may want to have, for example, a QQmlFileSelector and a component-specific interceptor that chooses a theme or similar. Also, make the API public. We want to propose this as alternative to dynamically registering QML files via qmlRegisterType(QUrl, ...). Change-Id: I4a535d3ea556da6710fde816579ec188b3f57099 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Allow partial and absent version specifiers in import statementsUlf Hermann2020-03-171-17/+29
| | | | | | | | | | | | | | | | | | | | An import statement without version specifier imports the latest version available, one with only a major version imports the latest minor version from that major version. Task-number: QTBUG-71278 Change-Id: I43907ae4e1052be533039d545de5391c41d38307 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Avoid unloading plugins which register types to prevent crashesFabian Kosmale2020-03-091-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Plugins could register an arbitrary number of types in arbitrary places with qRegisterMetaType. This would lead to crashes when the plugin is unloaded, as the type registry would hold stale references to their QMetaTypes. By not unloading the plugin, the metatypes are kept safe in memory. [ChangeLog][QML][Important Behavior Changes] When writing a QQmlExtensionPlugin which procedurually registers types, you should overload the newly introduced unregisterTypes function, if you want to support unregistration with qmlClearEnginePlugins. Additionally, the destructor of your plugin should not contain any logic. Change-Id: I63b7a153f82be7996dbfca4d36f279c351dc6b9e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-091-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmlirbuilder_p.h src/qml/qml/qqmlpropertycachecreator_p.h src/qmltyperegistrar/qmltypesclassdescription.cpp src/qmltyperegistrar/qmltypesclassdescription.h src/qmltyperegistrar/qmltypescreator.cpp src/quick/items/qquicktext_p.h src/quick/util/qquickvaluetypes_p.h Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
| * Use Qt::SplitBehavior in preference to QString::SplitBehaviorEdward Welbourne2020-03-021-3/+3
| | | | | | | | | | | | | | | | The Qt version was added in 5.14 "for use as eventual replacement for QString::SplitBehavior." Move another step cloaser to that goal. Change-Id: I3214ad6ccaca9dfd4a026589cabeb40cbf4a6298 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-211-1/+7
|\| | | | | | | | | | | | | Conflicts: tests/auto/quick/qquickmousearea/BLACKLIST Change-Id: I3de2c6377d57f5f9204d2cfc688d50a7a0b4150c
| * Inline component: Avoid even more leaksFabian Kosmale2020-02-201-0/+2
| | | | | | | | | | | | | | Amends d4f3445bb050bbc34f0e86832fca9b7047041c1e Change-Id: I1071577529c2db6937affb3fd3087fec75917e8a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-201-1/+4
| |\ | | | | | | | | | Change-Id: I024445b3401a57040d7d67780ea32d2f8b02f41a
| | * Windows: Do look for <plugin>d.dll as a fallbackKai Koehne2020-02-151-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do look for d.dll as name of the library, even if Qt was built in release mode. This mitigates the change we did in Qt 5.14.0, where we switched the way our MinGW builds are configured from -debug-and-release to -debug -force-debug-info. But it is also more consisten in how we handle the release build, and macOS dylib loading. Fixes: QTBUG-81021 Change-Id: I73cd11941d86a732b92a3479d47b6e83a839994f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * | Avoid memory leaks for inline component typesFabian Kosmale2020-02-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | When a QQmlType is constructed from a QQmlTypePrivate, the latter's refcount is incremented. We decrement it again, as the QQmlType should be its sole owner. Change-Id: Id6ab618e06b49c10e3888c694113536caed7f058 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Process major versions as part of Q_REVISIONUlf Hermann2020-02-131-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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-173/+186
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Long live QML inline componentsFabian Kosmale2020-01-231-32/+141
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] It is now possible to declare new QML components in a QML file via the component keyword. They can be used just as if they were declared in another file, with the only difference that the type name needs to be prefixed with the name of the containing type outside of the file were the inline component has been declared. Notably, inline components are not closures: In the following example, the output would be 42 // MyItem.qml Item { property int i: 33 component IC: Item { Component.onCompleted: console.log(i) } } // user.qml Item { property int i: 42 MyItem.IC {} } Fixes: QTBUG-79382 Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | QQmlImport: Allow importing multiple versions of the same moduleUlf Hermann2020-01-101-1/+7
| | | | | | | | | | | | | | | | | | Previously, once a plugin had been loaded, the static module registrations were disregarded. Therefore, if there were static and dynamic registrations in the same plugin, only one set was ever loaded. Change-Id: I24f52cc579a833041c51f15555caf226a6189c99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Defer loading of local qmldir files when intercepted to remote onesUlf Hermann2020-01-021-26/+33
| | | | | | | | | | | | | | | | | | | | | | | | The qqmltypeloader test checks this case. As long as the types are actually loaded by the plugin it worked as we didn't register the module before. When the types are loaded by static type registrations in QtQuick we need to detect whether we still need to wait for a remote qmldir file to appear in order to load color providers etc. Change-Id: I7aa10903c6c23d1c9be01ee7ddafbdc696975407 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-241-1/+2
|\| | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlpropertyvalidator.cpp tests/auto/qml/qmlmin/tst_qmlmin.cpp Change-Id: I920c133e839d980ed32c179a0bc4fa44c46e2296
| * Android: Fix crash in release modeBogDan Vatra2019-10-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using the "auto" keyword, we would keep a reference to the QStringBuilder, instead of converting it to a QString. This object would in turn keep references to the pluginName string, which the compiler would delete, and we would get a crash later on, when the actual conversion took place. So this is a sneaky compiler bug and the work-around is to explicitly convert the QStringBuilder to a QString right away. Fixes: QTBUG-79230 Change-Id: I0759645c84d6f995f26063ea098cdaea61e924ab Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Add support for primitive self-references in composite typesSimon Hausmann2019-10-211-17/+25
| | | | | | | | | | | | | | | | | | | | | | This has been long missing and will also help with the implementation of inline components and the referenced bugs. Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Task-number: QTBUG-41087 Task-number: QTBUG-35910 Change-Id: Ia42a8f9808ece543f8ce2314b3352507fab22c62 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Provide methods to query and remove a dynamically loaded pluginUlf Hermann2019-10-161-0/+34
| | | | | | | | | | | | | | | | | | | | This may be necessary in some corner cases in order to manually manage memmory for loaded libraries. Also, clear the (static) plugins on qmlClearTypeRegistrations if !QT_CONFIG(library). Task-number: QTBUG-76074 Change-Id: Id33d2a4acd7ca94efad53353f8bcb020576c4010 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add support for semi-automatic QML type registrationsUlf Hermann2019-10-141-25/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge "Merge remote-tracking branch 'origin/5.14' into 5.15"Qt Forward Merge Bot2019-10-081-4/+4
|\|
| * Convert a few sizeof(array)/sizeof(element0) fors to range forsAlbert Astals Cid2019-10-041-4/+4
| | | | | | | | | | | | | | | | Increases readability Change-Id: I46d82fac83e538988cea79a053d70b954a3cb9f1 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-3/+16
|/ | | | | | | | | | | | | | | | | | | | | | 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>
* Android: Load QML plugins directly from APK libs dirBogDan Vatra2019-10-011-0/+22
| | | | | | | | | | | Also register qrc:/android_rcc_bundle/qml as the folder where declarative engine finds the other QML files (qmldir, *.qml, *.js, etc.). [ChangeLog][Android] load QML plugins directly from APK libs dir and use qrc:/android_rcc_bundle/qml to search for QML files. Change-Id: I9552121411d21537befc41646cdd161ce0cec760 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Android multiarch supportBogDan Vatra2019-08-281-2/+8
| | | | | Change-Id: Ifa70d6cb36be385280364cca9dd4e31b43aa9a18 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix bug in QQmlEngine::setImportPathList() when it had a resource pathJan Arve Sæther2019-07-301-1/+3
| | | | | | | | | | | | | | | | | | The bug is really in QQmlImportDatabase::setImportPathList(). It was missing the same conversions that was done in QQmlImportDatabase::addImportPath(), so it failed to use a resource path as a import path because it did not convert ":/foo" to "qrc:/foo". We therefore just use addImportPath() to ensure the paths are converted properly. Before this, several autotests in tests/auto/qml/qqmllanguage failed on Android, since they were calling QQmlEngine::setImportPathList() where the list had resource paths. Task-number: QTBUG-73512 Change-Id: Idc64f5ad20ec665df7cb57ea1c346bc0975c3b0d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-261-1/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/quick/handlers/qquickpointerdevicehandler.cpp src/quick/scenegraph/qsgdefaultglyphnode.cpp src/quick/scenegraph/qsgdefaultglyphnode_p.cpp src/quick/scenegraph/qsgdefaultglyphnode_p_p.h tests/auto/qml/qjsengine/tst_qjsengine.cpp Done-With: Jan Arve Sæther <jan-arve.saether@qt.io> Done-With: Laszlo Agocs <laszlo.agocs@qt.io> Change-Id: I35749152f8dce44b9af8d52b1283629879010f11
| * Do not search for Singletons from more recent versionsFabian Kosmale2019-07-231-1/+12
| | | | | | | | | | | | | | | | | | | | This would break importing older versions of a module, as we would try to locate a singleton which does not exist in this version. Fixes: QTBUG-77102 Change-Id: I78be1ec111d2be26a14b2a94bbf743cf6238cddd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Split qqmltypeloader{_p.h|.cpp} into a several filesUlf Hermann2019-07-111-0/+1
| | | | | | | | | | | | | | No one can read this mess. Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Clean up the QT_CONFIG(library) conditionsUlf Hermann2019-06-261-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | We can clear the engine plugins when compiled without library support as those might be static plugins. However, explicitly loading a dynamic plugin is pointless if compiled without library support. We can just disable the whole function. Furthermore, the ability to load dynamic qmldir plugins does not depend on Qt being compiled as shared library but rather on library support being available. Change-Id: I8553706f0f8f5bd4e98cc130bf56c4526f81b85f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Inline msgCannotLoadPlugin() into its only callerUlf Hermann2019-06-241-9/+4
| | | | | | | | | | Change-Id: I104f8776d34f4db2afe9d1940aa621a6a0b3892a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-181-1/+1
|\| | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlimport.cpp Change-Id: I6add6267297ea50a646d43d212027a168dca8916
| * QML: Allow fetchOrCreateTypeForUrl to report errors without qFatalErik Verbruggen2019-04-161-1/+1
| | | | | | | | | | | | | | | | Because qFatal will abort() the program. Task-number: QTBUG-71116 Change-Id: Ifd6be996cfbd6fff8e75ad2b26682c34f837ac88 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-101-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp src/qml/types/qqmlmodelsmodule.cpp Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
| * Avoid redundant slashes when creating qmldir URLsUlf Hermann2019-03-281-1/+1
| | | | | | | | | | | | | | | | | | If the path starts with ":" and we assume it's an absolute qrc path, the only thing we need to do to make it a URL is prepend "qrc". Fixes: QTBUG-74677 Change-Id: Iee0239296b6f48ce909db02ae16e24dfc745b637 Reviewed-by: Lars Knoll <lars.knoll@qt.io>