1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-23 13:04:23 +00:00

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.
This commit is contained in:
Chocobo1 2019-09-25 02:36:37 +08:00
parent 7a3607c729
commit 103e2b9398
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
2 changed files with 2 additions and 4 deletions

View File

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

View File

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