diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-06-09 14:56:00 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-06-09 16:49:41 +0200 |
commit | b55c3d4f6cc14416c64a7e796abe3d9fd996fc94 (patch) | |
tree | b4ac469cdb40ad0aeda2a4bb276bb92858c92d40 /src/qml/qml/qqmltype.cpp | |
parent | 9752ad5af7c7ae188250ab5b8b65c74f70d57b41 (diff) |
QQmlTypePrivate: do not abuse volatile for atomic
Instead of using volatile, use proper atomics for thread safe access.
Moreover, we don't gain anything by using bitfields here, as we have
space for 4 bools due to alignment reasons anyway. Therefore using bools
does not create any overhead.
Change-Id: I390acd935656efcb20265ddb67fa0059f3f18118
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltype.cpp')
-rw-r--r-- | src/qml/qml/qqmltype.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/qml/qqmltype.cpp b/src/qml/qml/qqmltype.cpp index 0b21cc22ee..ffb1e0ac4c 100644 --- a/src/qml/qml/qqmltype.cpp +++ b/src/qml/qml/qqmltype.cpp @@ -207,11 +207,11 @@ static bool isPropertyRevisioned(const QMetaObject *mo, int index) void QQmlTypePrivate::init() const { - if (isSetup) + if (isSetup.loadAcquire()) return; QMutexLocker lock(QQmlMetaType::typeRegistrationLock()); - if (isSetup) + if (isSetup.loadAcquire()) return; const QMetaObject *mo = baseMetaObject; @@ -265,17 +265,17 @@ void QQmlTypePrivate::init() const } } - isSetup = true; + isSetup.storeRelease(true); lock.unlock(); } void QQmlTypePrivate::initEnums(QQmlEnginePrivate *engine) const { - const QQmlPropertyCache *cache = (!isEnumFromCacheSetup && isComposite()) + const QQmlPropertyCache *cache = (!isEnumFromCacheSetup.loadAcquire() && isComposite()) ? compositePropertyCache(engine) : nullptr; - const QMetaObject *metaObject = !isEnumFromBaseSetup + const QMetaObject *metaObject = !isEnumFromBaseSetup.loadAcquire() ? baseMetaObject // beware: It could be a singleton type without metaobject : nullptr; @@ -288,12 +288,12 @@ void QQmlTypePrivate::initEnums(QQmlEnginePrivate *engine) const if (cache) { insertEnumsFromPropertyCache(cache); - isEnumFromCacheSetup = true; + isEnumFromCacheSetup.storeRelease(true); } if (metaObject) { insertEnums(metaObject); - isEnumFromBaseSetup = true; + isEnumFromBaseSetup.storeRelease(true); } } |