aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlpropertycache_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-111-1/+1
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Div. smart pointer/raii classes: mark ctors [[nodiscard]]Marc Mutz2023-06-261-3/+3
| | | | | | | | | | | | | | | | The following classes are smart pointers or RAII classes, whose ctors QUIP-0019 asks to mark as [[nodiscard]]: - QQmlMetaObjectPointer - QQuickDeferredPointer - QuitLockDisabler QUIP: QUIP-0019 Fixes: QTBUG-104168 Pick-to: 6.6 Change-Id: Ia362f5d0eab7376f4536aefc61c31ceb296b1cc2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQmlRefCount: de-virtualize dtorMarc Mutz2023-06-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | Now that QQmlRefCounted ensures no-one uses ~QQmlRefCount() directly anymore, we can make it non-virtual, shrinking the sizeof(QQmlRefCount) from 8/16 to 4/4 bytes (32/64 bit platforms). This requires moving the release() function from QQmlRefCount down into QQmlRefCounted<T>, and static_cast'ing *this to T before calling delete. We need to be careful, of course, that no derived class relied on the implied virtualness of ~QQmlRefCount() making their dtors virtual, so require that all classes that use QQmlRefCounted are either final or have a virtual destructor. Update the toolsupport test and the TypeInformationVersion, as sizeof(QQmlRefCount) was one the items checked. Fixes: QTBUG-114817 Change-Id: I69afd36ec5b63313842c1438e0244503603ed96f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlRefCount: break all users that attempt to access the dtorMarc Mutz2023-06-251-2/+3
| | | | | | | | | | | | | | | | | | | | | ... by making the dtor private, accessible only via an auxiliary friend class QQmlRefCounted<T>. There are no users of QQmlRefCount outside of qtdeclarative, but we cannot rule out that users use this private API. Since we develop this patch as part of our own due diligence, we might as well put it into the 6.6 release so as to alert any potential users outside the qt5.git tree. Once this change is released as part of 6.6, we know we have no users of ~QQmlRefCount() (anymore), and can, in the next step, drop the virtual from the dtor, saving sizeof(void*) on each object in the hierarchy that isn't virtual of its own volition. Task-number: QTBUG-114817 Pick-to: 6.6 Change-Id: I16ea02dc57f9555e302d9415f3e573d8765cf7a3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Insert aliases in inline components when loading from disk cacheUlf Hermann2023-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far we did not completely restore aliases in inline components. This was masked by the fact that until recently we failed to load inline components from the disk cache and always loaded them from source instead. To fix this, refactor QQmlComponentAndAliasResolver to work for both, QmlIR and QV4::CompiledData. With QmlIR, it populates the relevant data structures. With QV4::CompiledData, it sanity-checks them. The sanity-checks do incur some overhead, but given recent events, we should err on the side of caution here. Since QQmlComponentAndAliasResolver has received all the fixes we've applied to make inline components work, this should lead to inline components loaded from cache files to work the same way as those compiled from source. In turn, we can drop some methods of QQmlPropertyCacheAliasCreator. Amends commit 131db085a752469e8f19974c2edb3a138d900249 Pick-to: 6.5 Fixes: QTBUG-111766 Fixes: QTBUG-111857 Change-Id: I9cc75e700a5fe5810a866e9aa930b9811368b1b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Drop some dead code from qqmlpropertycache*Ulf Hermann2022-11-251-3/+1
| | | | | | | _hasPropertyOverrides was never read. Change-Id: I96575a9c76379ede6cb76e12262e1b90ab3c7963 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlpropertycache_p.h: Explicitly cast size to intFabian Kosmale2022-10-311-4/+4
| | | | | | | | | | | | | The number of properties, methods and enums are already limited by what QMetaObject supports (which is at most INT_MAX, but realistically much less). Therefore, we know that the containers will never contain more than INT_MAX many elements, and we can cast size() to int to avoid a -Wshorten-64-to-32 warning. Task-number: QTBUG-105055 Change-Id: Ieea970984e41e95ae3dccecf8656591f959645ec Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQmlPropertyCache: Guarantee 1:1 relationship to meta objectUlf Hermann2022-04-251-3/+3
| | | | | | | | | | | | | | | | | | The QQmlPropertyCache ctor that just takes a QMetaObject is really dangerous. It misbehaves for anything but plain QObject. Remove it. Also, realize that we never want to update a property cache "recursively". That is, each property cache maps exactly one metaobject. We cannot cover multiple metaobjects with the same property cache. Finally, any property caches constructed dynamically must not be recorded in the type registry. These caches are not comparable to anything else. Introduce a special method to create them. Fixes: QTBUG-102454 Pick-to: 6.2 6.3 Change-Id: I47a1ff0f467e9444ff9f581ffcdf0a8b5730b0b8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlMetaObjectPointer: fix missing release memory fence in setSharedOnce()Marc Mutz2022-04-051-1/+1
| | | | | | | | | | | | | We have new'ed up a SharedHolder object whose address we then implant into the atomic variable. This operation requires release semantics, to prevent writes to the object being re-ordered to after the write to the atomic. QQmlMetaObjectPointer did not exist in 6.2, so only Pick-to: 6.3 Change-Id: I04fac8ec6ede0bc02ce44de7334b06f84342da44 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QQmlMetaObjectPointer: restrict copy ctor to QQmlPropertyCacheMarc Mutz2022-04-051-0/+4
| | | | | | | | | ... using friendship. Pick-to: 6.3 Change-Id: I311256d7e8d167120e31142b846615d793e17ce1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlMetaObjectPointer: optimize atomic operations [2/2]: acquires /= 2Marc Mutz2022-04-051-5/+7
| | | | | | | | | | | | | | | | | | | In the destructor, as well as in the metaObject() method, the old code used the implicit conversion from QAtomic<T> to T, which is equivalent to load-acquire. The code performed up to two reads each, which means two load-acquire operations where one suffices. Cache the result of the loadAcquire() and perform further operations on the cached value instead of the atomic variable. Found by locally disabling QAtomic<T> -> T implicit conversion operators. Change-Id: I6a4ceaf462714eaad8c79fc4f26a9521525ee1c7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QQmlMetaObjectPointer: optimize atomic operations [1/2]: relaxed sufficeMarc Mutz2022-04-051-5/+7
| | | | | | | | | | | | | | | | | | When asserting, or in isNull() or isShared(), we don't need an acquire fence, because the value of 'd' is all we're interested in. So just do one relaxed atomic load, as opposed to up to two load-acquire operations, which is what the old code used, via the implicit conversion operator. In the copy ctor, we can assume that external synchronization is in place otherwise reading from other would be a data race. Found by locally disabling QAtomic<T> -> T implicit conversion operators. Change-Id: I6158878a4fa9b0b511b346026f32585176b01beb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make most QQmlPropertyData constUlf Hermann2022-03-141-24/+22
| | | | | | | You really should not mess with that after creating the property cache. Change-Id: I070200772475bb67f539dbbd85a298020b14ca79 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use const QQmlPropertyCache wherever possibleUlf Hermann2022-03-141-11/+23
| | | | | | | | We're not supposed to modify property caches after they've been created. Task-number: QTBUG-73271 Change-Id: I0ab8ed6750508fa4e28931995142f56cd5fa3061 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Restore immutability of QQmlPropertyCacheUlf Hermann2022-03-121-68/+65
| | | | | | | | | | | | | | | | | | | We need to make sure the operations on the metaobject pointer are atomic. Otherwise we can mess up the refcounting or create the shared metaobjects multiple times. We have an atomic refcounting mechanism, so let's use that. At the same time, realize that we don't have to double-indirect access to the static metaobjects because we don't have to refcount those. Therefore, replace the RefCountedMetaObject with a class that makes both the pointer operations and the refcounting atomic, and stores static metaobject pointers directly. Pick-to: 6.3 Fixes: QTBUG-73271 Change-Id: Icd63413a3dbbb43ebb266ed6b4f9e6444ecbf908 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCache: Store checksums in type loaderUlf Hermann2022-03-091-2/+1
| | | | | | | | | | | | | The type loader is specific to the engine. This way we can calculate/retrieve the checksum without modifying the property cache, which makes checksum() threadsafe. The checksums are only needed for loading and storing compilation units from/to disk. Therefore, there is no point in keeping them inside the property caches anyway. Pick-to: 6.3 Task-number: QTBUG-73271 Change-Id: I7bea65e73769f76352bb5947d7229e256e7f2f25 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move QJSEnginePrivate::cache() to QQmlMetaTypeUlf Hermann2022-01-181-6/+9
| | | | | | | | | It is just in line with the other propertyCache() methods, and should be treated the same way. The comment made no sense anymore. This allows us to drop more engine pointers. Change-Id: I2e9b479b555c7f771b619e4693d59cbfcf244df6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up PropertyCache life cycleUlf Hermann2021-11-091-18/+20
| | | | | | | | | | | | | We generally want to use QQmlRefPointer for it, rather than manually calling addref() and release() all over the place. Also, we can completely inline its ctor and drop an unused member. Also, do not keep property caches of dynamic meta objects in type registry. The dynamic metaobjects will change, and the outdated property caches will eventually be retrieved. Change-Id: I8042c85b32f3031b554f97a35c1545a3412d2acb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Clean up some includesUlf Hermann2021-11-051-9/+6
| | | | | | | | | We should not include qqmlglobal_p.h just for the export macros as that pulls in a number of other things. Rather, include qtqmlglobal_p.h for that. Change-Id: Iecb60ef676dd880c0d94360ccef6517ef1ec73bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename qflagpointer_p.h to qbipointer_p.hFabian Kosmale2021-11-031-1/+0
| | | | | | | | | QFlagPointer has been moved to qtbase. As a drive-by, remove includes of qbipointer_p.h which are no longer needed and add them where the type is actually used. Change-Id: I067864e6c082dcbd422deb79812ea7c36412caba Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add a Pragma for list assign behaviorUlf Hermann2021-10-131-0/+1
| | | | | | | | | | [ChangeLog][QtQml] You can now specify the list property assignment behavior in QML using the "ListPropertyAssignBehavior" pragma. This is analogous to the macros you can use in C++. Fixes: QTBUG-93642 Change-Id: I9bdcf198031f1e24891f947b0990a3253d29a998 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid QAbstractDynamicMetaObject where possibleUlf Hermann2021-10-121-10/+40
| | | | | | | | | | | | | | | | | | | | | We don't want to copy metaobjects, but QAbstractDynamicMetaObject forces us. Rather, use plain QDynamicMetaObjectData, and store a pointer to the actual metaobject. This requires us to drop the "isDirect()" optimization for property access, as we realize that there can be dynamic meta objects which are not QAbstractDynamicMetaObject. However, this optimization was questionable anyway. What it did was cache the fact that an object might have a dynamic metaobject in a flag. Checking this on the object itself should not be much more expensive, though. On the other hand, an object might receive a dynamic metaobject individually without us adjusting flags for its type. In that case we would call the wrong method. Furthermore, most property access can be done using the static metacall function anyway. Change-Id: I5897351253496309721bd38adf3e35a1f069b080 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix required properties detection in QQmlObjectCreatorAndrei Golubev2021-09-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the type comes from QML (either because it's invalid - defined in another document/compilation unit OR because it's an inline component), it means that our instance has a QML-originated base class. That class might have bindings on required properties (making them initialized). If those properties come from some more-distant C++ base type, they'll be in the propertyCache of currently processed type (in one of the parent caches), but we must not include them into the sharedState->requiredProperties as we lack the bindings from the QML-originated base class (so we may accidentally see uninitialized required properties that were actually initialized, just in a parent QML document). So: only consider own properties in such case, leaving the handling of parent-and-own properties to the first QML-defined type that has an immediate C++ base class - since we use sharedState to collect required properties, this'll work fine across different (sub)creators The only problematic case is when attached and group properties are involved. We need to decide what to do with them (maybe just leave the old logic for simplicity) While fixing the behavior, also update places that used propertyCount() implementation without using the function itself Pick-to: 6.2 Fixes: QTBUG-96200 Task-number: QTBUG-96544 Change-Id: I28f45037790faddaa1b2f07e78544839f60563c7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Reject overrides of final properties (and potentially methods)Ulf Hermann2021-06-021-0/+22
| | | | | | | | | | | | | | | | | | | | | | | If you specify FINAL in Q_PROPERTY you explicitly don't want it to be overridden. Before, we would still accept overrides of such properties. Issue a warning and decline overriding them. For consistency, treat methods the same, even though we cannot declare them final yet. [ChangeLog][QtQml][Important Behavior Changes] C++ properties declared FINAL now refuse to be overridden by other C++ properties. This mirrors the treatment of QML properties trying to override FINAL properties. As we cannot reject the C++ types the way we can reject QML types, the overrides are ignored and a warning is issued. It is also impossible to override final properties with functions now. This used to be possible in the past. Task-number: QTBUG-93662 Change-Id: I244c3e83a33875472bc5bf6786a1e949fe981995 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Remove QString overload forwarding to QStringViewFabian Kosmale2021-04-091-7/+0
| | | | | | Change-Id: Ia97aefc3dbedae1e979db93638836b366eee153f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Optimize stack frame setup for AOT compiled functionsUlf Hermann2021-03-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When called via the metaobject system, parameters and return values are passed as void*, with accompanying type information in the form of QMetaType. The same format is expected when calling an AOT compiled function. Previously, we would first convert all the parameters to QV4::Value, just to convert them back the moment we notice that there is an AOT compiled function. This is wasteful. This change provides a second call infrastructure that accepts void* and QMetaType as parameter and return value format, and passes them as-is all the way to any AOT compiled functions. If there is no AOT compiled function, the conversion is done when detecting this, rather than when initiating the call. This also passes the information "ignore return value" all the way down to the actual function call. If the caller is not interested in the return value, we don't have to marshal it back at all. For now, we only add the extra "callWithMetaTypes" vtable entry to ArrowFunction. However, other callables could also receive variants optimized for calling with void*/int rather than V4 values. This required changing the way how function arguments are stored in the property cache. We squeeze the return type into QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of integers. In turn, we remove some unused bits. Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCache: Optimize layout to avoid paddingFabian Kosmale2021-03-051-6/+6
| | | | | Change-Id: I4022cf5acf63e2e2e9257acd1dd4439b85645faf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine internals: Do not require mutable QObject pointerFabian Kosmale2021-02-281-1/+1
| | | | | | | | | | All we need is to get the meta-object from the object. This also works with a const pointer, which is helpful for const-correctness in the FSM framework. Pick-to: 6.1 Change-Id: Ie554fe81e67bced5f74c844c72e7f9b0df7ded58 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove QQmlCleanupUlf Hermann2021-01-131-1/+0
| | | | | | | | | | | | | | | | | The only place where it was still used is QQmlOpenMetaObjecType. The only effect of QQmlCleanup is that clear() is eventually called by the engine. In the case of QQmlOpenMetaObjectType the only effect of that was that the "engine" member was reset. However, the only place where that member was used was in setCached(), and in that place it was irrelevant. There is no reason why setCached() should be prohibited when there is no engine. We may be worried that the property cache assigned to the open metaobject might go away somehow if there is no engine, but the cleanup mechanism clearly demonstrates that checking for the engine on setCached() does not protect against this. Fixes: QTBUG-90004 Change-Id: I05445eaeb53a64c70de366090ea2ee4aecf2bad8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropertyCache: Remove unused copyAndAppend overloadFabian Kosmale2020-12-031-4/+0
| | | | | | | Original-patch-by: Lars Knoll <lars.knoll@qt.io> Task-number: QTBUG-88765 Change-Id: I85dad61a1c3ade29137be9870ce8af726be81a28 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML engine: Use QMetaType instead of metatype-id in propertydataFabian Kosmale2020-11-261-1/+1
| | | | | | | | | | | | | | We don't want to convert back and forth between QMetaTypes and ids. This change is the first step towards using QMetaType directly everywhere. By reordering the members of QQmlPropertyData to avoid a gap caused by alignment, we can replace the typeid int with a QMetaType without requiring more space. There are still a few places left using metatype ids, notably the value type logic. Task-number: QTBUG-82931 Change-Id: Ic38f38d10c71ed20655877976c9cb5ee3cbe2d77 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Always fully resolve property data on creationFabian Kosmale2020-11-261-16/+3
| | | | | | | | Resolving things lazily is not really optimizing anything. Task-number: QTBUG-82931 Change-Id: Iff9e1c7c16ae0dec7e0cec018ed73c6c98542925 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlPropertyCache: Don't retrieve metaObjectOffset() twiceUlf Hermann2020-06-241-1/+1
| | | | | Change-Id: I233fc368a26d7a571a32829dcd6149096dfe2e07 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-161-2/+2
| | | | | | | | 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>
* Add a wrapper class for the meta object in the property cacheLars Knoll2020-06-081-5/+55
| | | | | | Change-Id: Ie324f0bd29ff3df5528682d3bc135a28ca1b597f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Consistently use pointers for the local variant in findPropertyUlf Hermann2020-05-261-4/+4
| | | | | | | | Creating property data on the fly shall be optional, and we generally use pointers for such "output" parameters. Change-Id: I0e4c6c079381b60140971f4fd70a25d6548323eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Encapsulate QQmlContextDataUlf Hermann2020-03-231-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is not a private detail of QQmlContext. And it is incredibly hard to see who owns what in there. Let's add some civilization ... We enforce refcounting for QQmlContextData across the code base, with two exceptions: 1. QQmlContextPrivate may or may not own its QQmlContextData. 2. We may request a QQmlContextData owned by its parent QQmlContextData. For these two cases we keep flags in QQmlContextData and when the respective field (m_parent or m_publicContext) is reset, we release() once. Furthermore, QQmlContextData and QQmlGuardedContextData are moved to their own files, in order to de-spaghettify qqmlcontext_p.h and qqmlcontext.cpp. When the QQmlEngine is deleted, any QQmlComponents drop their object creators now, in order to release any context data held by those. Before, the context data would be deleted, but the object creators would retain the dangling pointer. [ChangeLog][QML][Important Behavior Changes] QQmlContext::baseUrl() does what the documentation says now: It prefers explicitly set baseUrls over compilation unit URLs. Only if no baseUrl is set, the CU's URL is returned. It used to prefer the CU's URL. Change-Id: Ieeb5dcb07b45d891526191321386d5443b8f5738 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow partial and absent version specifiers in import statementsUlf Hermann2020-03-171-3/+17
| | | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-02-031-0/+1
|\ | | | | | | | | | | | | | | Conflicts: src/qml/common/qv4compileddata_p.h tests/auto/qml/qmlmin/tst_qmlmin.cpp Change-Id: Ieabc9e0729630de6a8644024d11b765f35199f29
| * Required properties: Do not fully resolve property cachesFabian Kosmale2020-02-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | There's no need to have the property cache fully resolved when checking for required properties, and it introduces bugs as information for fully resolving the type is missing at that point. This would later cause errors in the QQmlPropertyValidator, due to the propType being wrong. Fixes: QTBUG-81806 Change-Id: I413cc3fab57f258f5e4cf4164c505312b10543e2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-9/+12
|/ | | | | | | | | | | | | | 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>
* Add support for C++ accessible typed parameters and return types in qml ↵Simon Hausmann2019-07-091-2/+2
| | | | | | | | | | | | functions These can be declared using the new typescript-like syntax and using type names that are also used for signal parameters and property types. This merely affects their signature on the C++ side and allows the corresponding invocation. Change-Id: Icaed4ee0dc7aa71330f99d96e073a2a63d409bbe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Dissolve QQmlPropertyRawDataLars Knoll2019-04-181-11/+11
| | | | | | | There is no reason anymore to split the class in two parts. Change-Id: Iabef7acec1db7afc0ed4e89e1fd5b78699dc0847 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Move propertyCache-by-minor-version into QQmlMetaTypeDataUlf Hermann2019-04-181-2/+0
| | | | | | | | | | | | 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-3/+3
|\ | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp Change-Id: I517c001ea4eb0fdd8e469f9fffe5b7559a5b0795
| * QML: Pass type minor version when creating property dataUlf Hermann2019-02-211-2/+2
| | | | | | | | | | | | | | | | | | Depending on the type minor version recursive properties should be available or not. Check for that when resolving grouped properties. Fixes: QTBUG-33179 Change-Id: Id8f62befdc4a29d879710499e19d3d289bd18775 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * QQmlPropertyCache: support setting an explicit metaObject revisionRichard Moe Gustavsen2019-02-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a QQmlPropertyCache for a QMetaObject, there were currently no way to specify which revision to use. Normally this is not needed, since when creating property caches for types declared in QML, the correct revision would be filled in later, based on the import version found in the QML file. But sometimes we need to create a QQmlPropertyCache for a QMetaObject created in C++, that has no associated QML file and import version. And if that meta object has revisioned properties, we need to specify which revision of the meta object the cache should represent. Otherwise, the revision would just be 0, which means that revisoned properties would not be found by the V4 runtime later. As an example, QQmlAdaptorModel has a set of classes that wraps various models (QAIM, arrays, etc). When a new delegate item is created by a view, an instance of a model class will be created as well (from C++). This instance will be set as context object for the delegate item, enabling properties such as index, row, column and model roles. But since row and column should a revision (currently they don't), we need to be able to specify that the property cache should have a revision that matches the import version of the view. That way, we can ensure that they don't shadow any existing row and column properties that might exist in the application from before, and as such, cause regressions. This patch will add an extra argument to the constructor that lets you specify which revision of the QMetaObject to use. Task-number: QTBUG-70031 Change-Id: I1c245a0c8b6f071e35865966fedc97f2839cd2f3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>