summaryrefslogtreecommitdiffhomepage
path: root/compat/copyable-mutex.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/copyable-mutex.cpp')
-rw-r--r--compat/copyable-mutex.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/compat/copyable-mutex.cpp b/compat/copyable-mutex.cpp
index dde84c83..17b5aa34 100644
--- a/compat/copyable-mutex.cpp
+++ b/compat/copyable-mutex.cpp
@@ -1,18 +1,19 @@
#include "copyable-mutex.hpp"
+#include <cstdlib>
-mutex& mutex::operator=(const mutex& datum)
+mutex& mutex::operator=(const mutex& rhs)
{
- inner.emplace(datum->isRecursive() ? QMutex::Recursive : QMutex::NonRecursive);
+ if (rhs->isRecursive() != inner.isRecursive())
+ std::abort();
+
return *this;
}
-mutex::mutex(const mutex& datum)
+mutex::mutex(const mutex& datum) : mutex{datum.inner.isRecursive() ? Recursive : NonRecursive}
{
- *this = datum;
}
-mutex::mutex(mutex::mode m) :
- inner { std::in_place, static_cast<QMutex::RecursionMode>(int(m)) }
+mutex::mutex(RecursionMode m) : inner{m}
{
}
@@ -21,13 +22,12 @@ QMutex* mutex::operator&() const
return *this;
}
-QMutex* mutex::operator->() const
+mutex::operator QMutex*() const
{
- return *this;
+ return &inner;
}
-mutex::operator QMutex*() const
+QMutex* mutex::operator->() const
{
- return const_cast<QMutex*>(&inner.value());
+ return *this;
}
-