aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
Commit message (Collapse)AuthorAgeFilesLines
* QQmlProperty::write: historical reason does not hold in Qt 6Fabian Kosmale2020-10-031-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | There was a codepath which checked after a failed QVariant conversion whether the variant is valid and is null at the same time. In that case, the conversion would be treated as successful. The motivation for this can be traced back to QTBUG-37197, and our handling of strings. However, since those times various things have changed: - QVariant::isNull() does not return true anymore if its contained type is null. Thus the conversion of a QVariant holding a null QString will not lead to a conversion failure (as long as the target type is actually a conversion target for a QString). - A failed conversion will always leave the resulting variant in a state in which it is valid. The latter is rather problematic, as we would thus always enter the code path when the source QVariant happened to be null; even in the case where the source and target types are really incompatible. This can for instance be observed in tst_qjsonbinding, where assigning null to a QJsonArray would suddenly "work", thus leading to a test failure. However, thanks to the first point, it is safe to completely remove this code. Change-Id: I176a5c4b04295d128919cab8a333b8a5a2c2345d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* qmllint: Unify injected and "normal" JavaScript identifiersUlf Hermann2020-10-021-0/+13
| | | | | | | | The specifics of how to warn about the injected identifiers are moved out of ScopeTree as that is not related to the structure of the scopes. Change-Id: I26418c3fa492da8339abf045a4034a8464b7bbb8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use factory functions and ctors for creating value typesUlf Hermann2020-10-0214-80/+101
| | | | | | | | | | As you can extend value types with QML_EXTENDED we may as well allow a factory function in the extended type. Furthermore, if the original type allows construction from QJSValue, we may just use that. In turn, we can get rid of the value type providers now. Change-Id: I9124ea47537eab6c33d7451080ab2fff942eaa7b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Rewrite qv4sequenceobject based on QMetaSequenceUlf Hermann2020-10-0212-339/+343
| | | | | | | | | | This avoids the template explosion and makes the mechanism extendable. You can now register additional anonymous sequential containers. Fixes: QTBUG-71574 Task-number: QTBUG-82443 Change-Id: I5b9ed9af1533a3b7df8fc5bb37bbb73b8304e592 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlimport: Use stable_partition instead of stable_sortFabian Kosmale2020-09-281-2/+2
| | | | | | | | | | | | We do not actually need to sort the imports list, we just require that all inline component imports come before all other imports. This avoids triggering a MSVC STL debug assertion about the used Compare function not actually creating a strict ordering. Fixes: QTBUG-86989 Pick-to: 5.15 Change-Id: I381852392545287ec02b186fcb4f33be3ae95b33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Export QQmlLocale symbolsVolker Hilsheimer2020-09-281-4/+4
| | | | | | | | | After 8e222a70d19d5eef616e1d6306415da64fbab4cb, QQmlLocale is a namespace and doesn't export any symbols. Export the member functions explicitly, as they are needed by Qt Quick Controls. Change-Id: I867cb5c0325c6c19200408b514c086c8057c82a9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt to changes in QMetaSequenceInterface and iterablesUlf Hermann2020-09-251-7/+7
| | | | | | | | metaSequence() became metaContainer() and we should ask for canConvert() as there are two ways to convert to a container. Change-Id: Iba868491ff9d2cc8fc89de1cab29818b834b53f4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlDirParser: Treat dependencies like importsUlf Hermann2020-09-252-24/+15
| | | | | | | In particular, allow auto and latest versions. Change-Id: I4a6b26112950d066ae2d8a37dc0e9fa1dec24724 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Rename internal functions to contain qt_internalAlexandru Croitor2020-09-251-4/+10
| | | | | | | | | Offer compatibility wrapper functions until we update all of the Qt repos to use the new names. Task-number: QTBUG-86815 Change-Id: I834ac1d5d6549bd4e33b9916a2198a7a03c0d183 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QQmlTypeCompiler: Resolve aliases earlierFabian Kosmale2020-09-231-11/+12
| | | | | | | | | This is a prequisite for determining whether a change handler of an alias should use its change signal, or whether it can use the alias target's bindable interface. Change-Id: I6f5220a6889601327cb478479c7c9e58f1a64d97 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Condense the different value type creation functions into oneUlf Hermann2020-09-236-51/+26
| | | | | | | They all did the same thing. Change-Id: I7661b19ad16c0713d46c4df337899e3897349b2e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::storeValueType()Ulf Hermann2020-09-233-23/+4
| | | | | | | | | | | | It was only used for QColor. The string representation of QColor was funneled through the color provider to get a numerical RGBA value and that one was passed to storeValueType() which would create a QColor object. The RGBA value was retrieved by creating a QColor object. We can just directly create the QColor from the string, and we can use the generic create() method for that. Change-Id: If36775830882237e5e36f748872ce23530c3bb71 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::createVariantFromString()Ulf Hermann2020-09-233-23/+1
| | | | | | | This can be expressed as constructing the variant from a QJSValue. Change-Id: I3140958469423acdc498e26129e349bcfb601198 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::createFromStringUlf Hermann2020-09-236-99/+29
| | | | | | | It can be expressed as a special case of create() with a QJSValue. Change-Id: I7342026ad694077d2780dd8a852714fa72dd68d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlValueTypeProvider::variantFromJsObjectUlf Hermann2020-09-233-9/+9
| | | | | | | This can be expressed in terms of create(). Change-Id: Id1950390bf4a1c9dfd9364ea351b81c75eb7e28f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlValueTypeProvider: Pass arguments as QJSValueUlf Hermann2020-09-233-74/+26
| | | | | | | | This is so that we can replace them with factory functions as a next step. Change-Id: Ic8619e4e779bd3e47471642c556601555758697b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow proper registration of value typesUlf Hermann2020-09-2312-167/+231
| | | | | | | | | | | | | | | | | | | | You can now have an extension object on a value type that offers additional properties. This is how we model the QtQuick value types. It allows us to retrieve the extension's metaobject without using the virtual functions in the value type provider. As before, this mechanism is still rather dangerous and not fit for public consumption. It relies on the extension object having exactly the same layout as the original value type, and it hides any properties the original value type might expose. Furthermore we enforce now that gadgets should have lowercase names. The ones that didn't before are split up into an anonymous value type and a namespace that contains all the addressable bits. Task-number: QTBUG-82443 Change-Id: Ic93d6764538d6ccc0774b3c5648eee08ba0939c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix ubsan errorAllan Sandfeld Jensen2020-09-231-5/+9
| | | | | | | | memcpy can't officially copy from nullptr, not even 0 bytes. Pick-to: 5.15 Change-Id: Ie6ede9a861cb2ae7ab35a50db5aa6c82cea6ad76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid crash when module version cannot be resolvedEskil Abrahamsen Blomfeldt2020-09-231-1/+5
| | | | | | | | | | | | | | | When QQmlMetaType::latestModuleVersion() returned an invalid version, we would fail importStaticPlugin() without adding any error. Since we unconditionally called takeFirst() on the errors list, we would later crash. The precondition here is that any failure adds an error, so we now assert to make this explicit. Also, add a simple module not found error when we can't resolve it. Change-Id: I7a13775b2ef56d95b7738ac53e58501b8c68895f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Prevent crash when destroying asynchronous LoaderJoni Poikelin2020-09-231-1/+1
| | | | | | | Fixes: QTBUG-86255 Pick-to: 5.15 Change-Id: I30488b64d910a1409a43e2e98ee7ab084aec33d2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlPropertyCapture: Replace list with forward listFabian Kosmale2020-09-222-1/+11
| | | | | | | | This required adding one missing function from QFieldList to QForwardFieldList, but saves one pointer and one quint32. Change-Id: I022fcd2e6bffe39b2d01f4664fd2ab154445fb00 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace QmlVoidT with std::void_tUlf Hermann2020-09-221-14/+11
| | | | | | | Now that we can use C++17 we don't need to invent our own. Change-Id: I6c6e02ac9b48f2fbe88160e7f9ebf9655092c9fc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Handle QProperty inside bindingsFabian Kosmale2020-09-215-6/+74
| | | | | | | | | | | | | | | | | | | If we have a binding containing QProperties, and the binding target is an old style binding, still we have to trigger an update if any of the captured properties changes. We cannot reuse the QQmlJavaScriptExpressionGuards as those depend on Qt's signals, and a QProperty is not associated with a change signal in the general case. Therefore, we introduce a new list of QPropertyChangeHandler, which when triggered cause a reevaluation of the binding. As an optimization, we skip the whole capturing process for QQmlPropertyBinding, as that one already takes care of updating itself. Reverts 845bbb99a41a3e4f05c2b3d05d6db748c825dca0 (because skipping the capture is only possible when _both_ the bindee and the property in the binding are QProperty based.) Change-Id: Iafed2a41dcd708bcc33912ce810d803949379c63 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename QQmlQPointer to QV4QPointerUlf Hermann2020-09-218-14/+14
| | | | | | | You can wrap QObject pointers in plain JavaScript. Change-Id: I246a72a7d5d7b2562e722bf9eafc7880b772a806 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QQmlSequence to QV4SequenceUlf Hermann2020-09-213-72/+72
| | | | | | | This feature is available without QML, in pure JavaScript. Change-Id: Iec8a52ed10ed3eeaec24d3955c8c132bf2bd9677 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt to change in QMetaSequenceInterface::valueMetaTypeUlf Hermann2020-09-181-1/+1
| | | | | | | | valueMetaType is a QMetaTypeInterface* now. Change-Id: If7e12e89b1801258d9e0892cbfb3b70b85b52376 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Don't capture bindable propertiesUlf Hermann2020-09-171-1/+1
| | | | | | | We don't need notify signals for those. Change-Id: If78329d1c9e98aee3fb9cd028963a881179ba02f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CMake: Fix in-source example buildsAlexandru Croitor2020-09-171-2/+2
| | | | | | | | | | | | QT_QMLTYPES_FILENAME can contain a path including subdirectories, so before creating the marker file in the .generated subfolder, we need to recreate the whole directory structure. Amends 1d67ecd790fe08a7cea1327ee754a9b8e74d113f Change-Id: I20ad48202d4e643df1ed3b86e631abb12d179b9d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Match new qHash() signatureEskil Abrahamsen Blomfeldt2020-09-174-5/+5
| | | | | | | | As documented in Qt 6 porting guide, qHash() should now also accept a size_t as seed in addition to returning it. Change-Id: I2b3ea26f631203468c071fa6ff65f95d82566132 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Add porting guides for all modules to porting guidePaul Wicking2020-09-161-0/+46
| | | | | | | Task-number: QTBUG-84051 Change-Id: Iffc8774898dba5bda329fa572289cc0134fddb6f Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Fix additional warnings from usage of deprecated APIsVolker Hilsheimer2020-09-161-1/+1
| | | | | | | | | | Replace more QLibaryInfo::location with QLibraryInfo::path Replace old event accessors APIs, including relevant comments. Change-Id: Ie205fc93b6e1c0dfb3dca9100fbde417ab68fc9f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQmlValueTypeProvider: Use QMetaTypeUlf Hermann2020-09-162-38/+18
| | | | | | | | We can create, compare, convert registered types without going through special virtual value type providers. Change-Id: I0431256540b8dd6861ff3a945570ea7df45ed98d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlValueTypeProvider: Remove dead codeUlf Hermann2020-09-162-34/+0
| | | | | | | | | The more adventurous variant/string conversions are luckily unused. Let's remove them before anyone gets ideas. Change-Id: I6f95cbdf9ead12ab723cafdbb2b0f02a0ff461fa Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlStringConverters: Remove dead codeUlf Hermann2020-09-161-86/+1
| | | | | | | | | createFromString() is only ever called for QVector2D, QVector3D, QVector4D, and QQuaternion. Those are all handled by the QtQuick implementation. Change-Id: Iaf2662207bf1110cb21761e4ffb401d8ebe521c6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* CMake: Make reconfiguration work for in-source buildsAlexandru Croitor2020-09-161-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Qml plugins can either use a plugins.qmltypes file from the source repository, or opt into generating it if the file doesn't exist. There is a use case for the file not to be generated for some Qml tests. To protect against accidentally overriding the source repo file, an error is shown if the file exists in the source directory and we also also try to generate it. With an in-source build, all plugins.qmltypes files are generated in the source directory, and this causes the above check to be triggered on reconfiguration. To avoid the false issue, create a new "${CMAKE_CURRENT_BINARY_DIR}/.generated/plugins.qmltypes" file to serve as a marker that the actual file was generated, and is not part of the source repository. If the marker file exists, don't error out. Change-Id: Ieca28b4da0251f67f8c066cbac471c8e6e955758 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix additional warnings from usage of deprecated APIsVolker Hilsheimer2020-09-161-1/+1
| | | | | | | | Replace QLibaryInfo::location with QLibraryInfo::path, and remove usage of Qt::AA_EnableHighDpiScaling, which doesn't have any effect anymore. Change-Id: I347e8a83e0f4c2b4405f2512e569ad3234f05a98 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Avoid various warnings about deprected QMetaType methodsUlf Hermann2020-09-1614-59/+60
| | | | | Change-Id: I8f4b2703fdd08ff341904219cec33c321e0511c7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QQmlMetaType: Unregister metatype interfaces before deleting themUlf Hermann2020-09-151-2/+6
| | | | | | | Otherwise the type may be retained in the aliases map. Change-Id: If6fbca53a417d76ad21548bea10f68401feb5c8c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix build after QStringList change in qtbaseVolker Hilsheimer2020-09-151-3/+0
| | | | | Change-Id: I258bcd59e7e97e025fa9ff77594bd8fdba0c34dd Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Do not write the 0 terminator for QStringLars Knoll2020-09-151-2/+0
| | | | | | | | | | | | | QString does this for us in any case, and writing there was always undefined behavior. This is causing problems after an optimization in QString, where creating a QString with size 0 will avoid any memory allocation and simply point to the (readonly) _empty member in QString. Change-Id: I0516dc2e8672b8290efa891bd9b5486dac8021b6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Adapt to changes in qtbaseUlf Hermann2020-09-153-70/+160
| | | | | | | | | Due to qiterable.h specializing a template declared in qmetatype.h we temporarily need to include it in a few tests so that the iterables work. Change-Id: Ia32392419dead76eaf2b91b2ec4157b726d8de74 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix QQmlPropertyData after QQMetaType changes in Qt CoreLars Knoll2020-09-151-6/+2
| | | | | | | | | | QMetaType::User is now much bigger than it used to be in Qt 5. This means that 16 bits to hols the property type is not enough. Use a regular int instead, reorder the members a bit and remove the unused short. Change-Id: I4b073e6cf1c7baa664bdee5df9552d109019665d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Adjust to qtbase changesFabian Kosmale2020-09-045-17/+22
| | | | | | | | | | | | | - isQProperty has been renamed to bindable - QNotifiedProperty is no more - Bindable properties have a function to obtain the QBindable; store that information in the qmltypes files. Task-number: QTBUG-86434 Task-number: QTBUG-86435 Change-Id: I2ba593af1e197d04d2c30cfb9e6904a3d2059e4b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QJSEngine::evaluete: fix documentationFabian Kosmale2020-09-031-2/+2
| | | | | | Change-Id: Ie0e6d975079e4cbedad2dd4f17d3efe8aee553bc Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QJSEngine: provide a way to check if an exception was thrownFabian Kosmale2020-09-022-6/+28
| | | | | | | | | | | [ChangeLog][QML][QJSEngine] QJSEngine::evaluate gained an optional stackTrace parameter. It can be used to check if the returned QJSValue comes from an uncaught exception, and to retrieve the backtrace of the execution leading to the error. Fixes: QTBUG-54925 Change-Id: I2b5ada1f0c33c335b4b9d0d1268e70ca63a1fad1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use QDate::startOfDay() rather than assuming midnight existsEdward Welbourne2020-09-011-1/+1
| | | | | | | | | When converting a QDate to a QDateTime, startOfDay() takes care of avoiding any gaps in time at the start of the day, where naively asking for QTime(0, 0, 0) can produce an invalid date-time. Change-Id: I24f3d230eb1ee7396600b030ad1305e060215cbd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4 Date: pass QDate, QTime by value, not by const referenceEdward Welbourne2020-09-014-4/+4
| | | | | | | They're value types, packaging qint64 and int respectively. Change-Id: I78a0097f77238751ac3ef9f928537f719a6d05d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickImageProvider: Remove reliance on RTTIFabian Kosmale2020-09-011-1/+2
| | | | | | | | | | | | | Using staticCast is unsafe, because in theory you can derive from QQmlImageProviderBase instead of QQuickImageProvider. But using dynamicCast runs into issues, because while Qt needs to be compiled with RTTI, user code does not. We thus turn the baseclass into a QObject so that qobject_cast does work. Fixes: QTBUG-84127 Change-Id: Id40d8a13eaa0101d80bd5742a23996354d70c72a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Re-generate configure CMake filesJoerg Bornemann2020-08-311-0/+2
| | | | | | | This generates the qt_cmdline.cmake files needed for the CMake-based configure script. Change-Id: I0f6ee452453b0cf11813d1e6d7d3659487d74c50 Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* Remove deprecated QQmlListProperty constructorFabian Kosmale2020-08-311-8/+0
| | | | | | | | | | [ChangeLog][QML][QQmlListProperty] Removed deprecated QQmlListProperty constructor taking a reference. Use the overload taking a pointer instead. Change-Id: I8942026d1bb1c88065659d96d648a4b256d7d427 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>