summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/thread/qmutex.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index 80b50fc..677412e 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -95,7 +95,7 @@ class Q_CORE_EXPORT QMutexLocker
{
public:
inline explicit QMutexLocker(QMutex *m)
- : mtx(m)
+ : val(reinterpret_cast<quintptr>(m))
{
Q_ASSERT_X((val & quintptr(1u)) == quintptr(0),
"QMutexLocker", "QMutex pointer is misaligned");
@@ -105,19 +105,19 @@ public:
inline void unlock()
{
- if (mtx) {
+ if (val) {
if ((val & quintptr(1u)) == quintptr(1u)) {
val &= ~quintptr(1u);
- mtx->unlock();
+ mutex()->unlock();
}
}
}
inline void relock()
{
- if (mtx) {
+ if (val) {
if ((val & quintptr(1u)) == quintptr(0u)) {
- mtx->lock();
+ mutex()->lock();
val |= quintptr(1u);
}
}
@@ -140,10 +140,7 @@ public:
private:
Q_DISABLE_COPY(QMutexLocker)
- union {
- QMutex *mtx;
- quintptr val;
- };
+ quintptr val;
};
#else // QT_NO_THREAD