mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08: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:
parent
7a3607c729
commit
103e2b9398
@ -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()
|
||||
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)
|
||||
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);
|
||||
}
|
||||
|
@ -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…
Reference in New Issue
Block a user