Browse Source

Use non-recursive mutex

The related classes doesn't really need recursive mutex so drop it. And
if it is really required it usually indicates bad design and we should
avoid it anyway.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
103e2b9398
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 5
      src/base/logger.cpp
  2. 1
      src/base/settingsstorage.cpp

5
src/base/logger.cpp

@ -49,7 +49,6 @@ Logger *Logger::m_instance = nullptr; @@ -49,7 +49,6 @@ Logger *Logger::m_instance = nullptr;
Logger::Logger()
: m_messages(MAX_LOG_MESSAGES)
, m_peers(MAX_LOG_MESSAGES)
, m_lock(QReadWriteLock::Recursive)
{
}
@ -75,9 +74,9 @@ void Logger::freeInstance() @@ -75,9 +74,9 @@ void Logger::freeInstance()
void Logger::addMessage(const QString &message, const Log::MsgType &type)
{
QWriteLocker locker(&m_lock);
const Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
m_messages.push_back(temp);
locker.unlock();
emit newLogMessage(temp);
}
@ -85,9 +84,9 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type) @@ -85,9 +84,9 @@ void Logger::addMessage(const QString &message, const Log::MsgType &type)
void Logger::addPeer(const QString &ip, const bool blocked, const QString &reason)
{
QWriteLocker locker(&m_lock);
const Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
m_peers.push_back(temp);
locker.unlock();
emit newLogPeer(temp);
}

1
src/base/settingsstorage.cpp

@ -155,7 +155,6 @@ SettingsStorage *SettingsStorage::m_instance = nullptr; @@ -155,7 +155,6 @@ SettingsStorage *SettingsStorage::m_instance = nullptr;
SettingsStorage::SettingsStorage()
: m_data{TransactionalSettings(QLatin1String("qBittorrent")).read()}
, m_dirty(false)
, m_lock(QReadWriteLock::Recursive)
{
m_timer.setSingleShot(true);
m_timer.setInterval(5 * 1000);

Loading…
Cancel
Save