summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-04 10:40:29 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-21 10:55:02 +0200
commit0e681064b54a6873bef5ddb7edef7e2efc317efc (patch)
tree6a6f7cf5f396fc38d97c5455da1889f3f1c85bad /src/corelib
parent10bc093d4fa1889b7a5f6151c9bcc79aa31ecfc5 (diff)
Deprecate QMutex in recursive mode
Use QRecursiveMutex instead. Pick-to: 5.15 Change-Id: I862fc2b3143deeb5c96dc8d445be5f9fa2535670 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/thread/qmutex.cpp4
-rw-r--r--src/corelib/thread/qmutex.h11
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp2
3 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 7f052feaa5..7ae07a3aa2 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -152,6 +152,7 @@ public:
/*!
\enum QMutex::RecursionMode
+ \obsolete Use QRecursiveMutex to create a recursive mutex.
\value Recursive In this mode, a thread can lock the same mutex
multiple times and the mutex won't be unlocked
@@ -173,6 +174,7 @@ public:
/*!
Constructs a new mutex. The mutex is created in an unlocked state.
+ \obsolete Use QRecursiveMutex to create a recursive mutex.
If \a mode is QMutex::Recursive, a thread can lock the same mutex
multiple times and the mutex won't be unlocked until a
@@ -197,7 +199,7 @@ QMutex::QMutex(RecursionMode mode)
QMutex::~QMutex()
{
QMutexData *d = d_ptr.loadRelaxed();
- if (isRecursive()) {
+ if (QBasicMutex::isRecursive()) {
delete static_cast<QRecursiveMutexPrivate *>(d);
} else if (d) {
#ifndef QT_LINUX_FUTEX
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index c1c87100e6..b29a7e3a9b 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -132,8 +132,16 @@ public:
#else
QMutex() { d_ptr.storeRelaxed(nullptr); }
#endif
+#if QT_DEPRECATED_SINCE(5,15)
enum RecursionMode { NonRecursive, Recursive };
+ QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
explicit QMutex(RecursionMode mode);
+
+ QT_DEPRECATED_VERSION_X(5, 15, "Use QRecursiveMutex instead of a recursive QMutex")
+ bool isRecursive() const noexcept
+ { return QBasicMutex::isRecursive(); }
+#endif
+
~QMutex();
// BasicLockable concept
@@ -164,9 +172,6 @@ public:
}
#endif
- bool isRecursive() const noexcept
- { return QBasicMutex::isRecursive(); }
-
private:
Q_DISABLE_COPY(QMutex)
friend class QMutexLocker;
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index a1c973562b..4dbd774428 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -213,7 +213,7 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
{
if (! mutex)
return false;
- if (mutex->isRecursive()) {
+ if (static_cast<QBasicMutex *>(mutex)->isRecursive()) {
qWarning("QWaitCondition: cannot wait on recursive mutexes");
return false;
}