summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-28 16:43:43 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-31 13:14:28 +0300
commitf383f899cba71c02f2fcacd7f54b17a50f8e33d0 (patch)
tree70681e2a24d59afdfc1a17e408254ede559e1ecf /tests/auto/widgets
parent33a2c9aed3ee621c91853570087b500c830792e0 (diff)
Port from QMutex::Recursive to QRecursiveMutex
Also port from QMutexLocker to std::lock_guard, as the former will not support QRecursiveMutex going forward. Add a guard for Qt < 5.14 to fall back to the old implementation, as this module has to compile against the latest LTS, too. Change-Id: Ib247135326ed199fd5fc783e906e7e3018687570 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r--tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
index 8b75067ee..dd059791d 100644
--- a/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
+++ b/tests/auto/widgets/qwebengineprofile/tst_qwebengineprofile.cpp
@@ -40,6 +40,8 @@
#include <QtWebEngineWidgets/qwebengineview.h>
#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <mutex>
+
class tst_QWebEngineProfile : public QObject
{
Q_OBJECT
@@ -255,18 +257,18 @@ public:
bool isSequential() const override { return true; }
qint64 bytesAvailable() const override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
return m_bytesAvailable;
}
bool atEnd() const override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
return (m_data.size() >= 1000 && m_bytesRead >= 1000);
}
protected:
void timerEvent(QTimerEvent *) override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
m_bytesAvailable += 200;
m_data.append(200, 'c');
emit readyRead();
@@ -278,7 +280,7 @@ protected:
qint64 readData(char *data, qint64 maxlen) override
{
- QMutexLocker lock(&m_mutex);
+ const std::lock_guard<QRecursiveMutex> lock(m_mutex);
qint64 len = qMin(qint64(m_bytesAvailable), maxlen);
if (len) {
memcpy(data, m_data.constData() + m_bytesRead, len);
@@ -295,7 +297,12 @@ protected:
}
private:
- mutable QMutex m_mutex{QMutex::Recursive};
+#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
+ mutable QMutex m_mutex{QMutex::Recursive}
+ using QRecursiveMutex = QMutex;
+#else
+ mutable QRecursiveMutex m_mutex;
+#endif
QByteArray m_data;
QBasicTimer m_timer;
int m_bytesRead;