make withWriteLock and withTryWriteLock const

This commit is contained in:
Seth Alves 2015-10-28 13:49:52 -07:00
parent a1096510e8
commit 22d6b6df34
2 changed files with 4 additions and 5 deletions

View file

@ -1792,8 +1792,7 @@ const QByteArray EntityItem::getActionData() const {
assertUnlocked();
if (_actionDataDirty) {
EntityItem* unconstThis = const_cast<EntityItem*>(this);
unconstThis->withWriteLock([&] {
withWriteLock([&] {
getActionDataInternal();
result = _allActionsDataCache;
});

View file

@ -14,7 +14,7 @@
class ReadWriteLockable {
public:
template <typename F>
bool withWriteLock(F f, bool require = true) {
bool withWriteLock(F f, bool require = true) const {
if (!require) {
bool result = _lock.tryLockForWrite();
if (result) {
@ -22,7 +22,7 @@ public:
_lock.unlock();
}
return result;
}
}
QWriteLocker locker(&_lock);
f();
@ -30,7 +30,7 @@ public:
}
template <typename F>
bool withTryWriteLock(F f) {
bool withTryWriteLock(F f) const {
return withWriteLock(f, false);
}