aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/util/qqmlpropertymap.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-01-13 12:39:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-01-13 14:32:40 +0100
commitf1410debc7905e704b6ed16ae345e43765ef8ef5 (patch)
tree56c0acf733fff7bc08362b753bd7729421169709 /src/qml/util/qqmlpropertymap.cpp
parentcfe0b08b5439a27b4fdd14c29620e0492543f506 (diff)
Add a freeze() method to QQmlPropertyMap
After freezing a QQmlPropertyMap you cannot add any more properties, but in turn the property access is cached, and therefore faster. Task-number: QTBUG-57792 Change-Id: I2c6d768039c3b59eb2411194e463ee0de55f8bed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/util/qqmlpropertymap.cpp')
-rw-r--r--src/qml/util/qqmlpropertymap.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp
index e38cf3a2a9..2bf8ab0190 100644
--- a/src/qml/util/qqmlpropertymap.cpp
+++ b/src/qml/util/qqmlpropertymap.cpp
@@ -204,6 +204,22 @@ void QQmlPropertyMap::clear(const QString &key)
}
/*!
+ \since 6.1
+
+ Disallows any further properties to be added to this property map.
+ Existing properties can be modified or cleared.
+
+ In turn, an internal cache is turned on for the existing properties, which
+ may result in faster access from QML.
+ */
+void QQmlPropertyMap::freeze()
+{
+ Q_D(QQmlPropertyMap);
+ d->mo->setAutoCreatesProperties(false);
+ d->mo->setCached(true);
+}
+
+/*!
Returns the value associated with \a key.
If no value has been set for this key (or if the value has been cleared),