[Kst] extragear/graphics/kst/src/libkst
Eli Fidler
eli at staikos.net
Wed Jul 12 22:25:02 CEST 2006
SVN commit 561648 by fidler:
prevent readLock/writeLock and readUnlock/writeUnlock races
reviewed by George
M +9 -14 kstprimitive.cpp
M +1 -1 kstprimitive.h
--- trunk/extragear/graphics/kst/src/libkst/kstprimitive.cpp #561647:561648
@@ -24,7 +24,7 @@
KstPrimitive::KstPrimitive(KstObject *provider)
-: KstObject(), _provider(provider), _readLockMutex(true), _readUnlockMutex(true), _writeLockMutex(true), _writeUnlockMutex(true), _inReadLock(false), _inReadUnlock(false), _inWriteLock(false), _inWriteUnlock(false) {
+: KstObject(), _provider(provider), _lockMutex(true), _unlockMutex(true), _inReadLock(false), _inReadUnlock(false), _inWriteLock(false), _inWriteUnlock(false) {
}
@@ -65,21 +65,16 @@
}
-//void KstPrimitive::setProvider(KstObject *obj) {
-// _provider = obj;
-//}
-
-
void KstPrimitive::readLock() const {
KstObjectPtr prov = KstObjectPtr(_provider);
if (prov) {
- _readLockMutex.lock();
+ _lockMutex.lock();
if (!_inReadLock) {
_inReadLock = true;
prov->readLock();
_inReadLock = false;
}
- _readLockMutex.unlock();
+ _lockMutex.unlock();
} else {
KstObject::readLock();
}
@@ -89,13 +84,13 @@
void KstPrimitive::readUnlock() const {
KstObjectPtr prov = KstObjectPtr(_provider);
if (prov) {
- _readUnlockMutex.lock();
+ _unlockMutex.lock();
if (!_inReadUnlock) {
_inReadUnlock = true;
prov->readUnlock();
_inReadUnlock = false;
}
- _readUnlockMutex.unlock();
+ _unlockMutex.unlock();
} else {
KstObject::readUnlock();
}
@@ -105,13 +100,13 @@
void KstPrimitive::writeLock() const {
KstObjectPtr prov = KstObjectPtr(_provider);
if (prov) {
- _writeLockMutex.lock();
+ _lockMutex.lock();
if (!_inWriteLock) {
_inWriteLock = true;
prov->writeLock();
_inWriteLock = false;
}
- _writeLockMutex.unlock();
+ _lockMutex.unlock();
} else {
KstObject::writeLock();
}
@@ -121,13 +116,13 @@
void KstPrimitive::writeUnlock() const {
KstObjectPtr prov = KstObjectPtr(_provider);
if (prov) {
- _writeUnlockMutex.lock();
+ _unlockMutex.lock();
if (!_inWriteUnlock) {
_inWriteUnlock = true;
prov->writeUnlock();
_inWriteUnlock = false;
}
- _writeUnlockMutex.unlock();
+ _unlockMutex.unlock();
} else {
KstObject::writeUnlock();
}
--- trunk/extragear/graphics/kst/src/libkst/kstprimitive.h #561647:561648
@@ -49,7 +49,7 @@
*/
QGuardedPtr<KstObject> _provider;
- mutable QMutex _readLockMutex, _readUnlockMutex, _writeLockMutex, _writeUnlockMutex;
+ mutable QMutex _lockMutex, _unlockMutex;
mutable bool _inReadLock, _inReadUnlock, _inWriteLock, _inWriteUnlock;
};
More information about the Kst
mailing list