Unverified Commit a2fd11a8 authored by Andre Heinecke's avatar Andre Heinecke
Browse files

Change std::mutex to QMutex for portability

std::mutex is not available on all platforms especially
not in MinGW for Windows. So with Qt we can rather use
QMutex to have portable code.
parent 6e23b46c
Pipeline #100598 passed with stage
in 14 minutes and 28 seconds
......@@ -22,8 +22,7 @@
#include <KMessageBox>
#include <QVBoxLayout>
#include <mutex>
#include <QMutex>
#include "kleopatra_debug.h"
......@@ -61,16 +60,16 @@ void GroupsConfigPage::Private::setChanged(bool state)
void GroupsConfigPage::Private::onKeysMayHaveChanged()
{
static std::mutex mutex;
static QMutex mutex;
std::unique_lock<std::mutex> lock(mutex, std::try_to_lock);
if (!lock) {
if (!mutex.tryLock()) {
// prevent reentrace
return;
}
if (savingChanges) {
qCDebug(KLEOPATRA_LOG) << __func__ << "ignoring changes caused by ourselves";
mutex.unlock();
return;
}
if (!changed) {
......@@ -92,6 +91,7 @@ void GroupsConfigPage::Private::onKeysMayHaveChanged()
q->load();
}
}
mutex.unlock();
}
GroupsConfigPage::GroupsConfigPage(QWidget *parent)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment