mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
commit
68dcc972fa
@ -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,26 +74,26 @@ 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 msg = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
|
||||||
|
m_messages.push_back(msg);
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
const Log::Msg temp = {m_msgCounter++, QDateTime::currentMSecsSinceEpoch(), type, message.toHtmlEscaped()};
|
emit newLogMessage(msg);
|
||||||
m_messages.push_back(temp);
|
|
||||||
|
|
||||||
emit newLogMessage(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 msg = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
|
||||||
|
m_peers.push_back(msg);
|
||||||
|
locker.unlock();
|
||||||
|
|
||||||
const Log::Peer temp = {m_peerCounter++, QDateTime::currentMSecsSinceEpoch(), ip.toHtmlEscaped(), blocked, reason.toHtmlEscaped()};
|
emit newLogPeer(msg);
|
||||||
m_peers.push_back(temp);
|
|
||||||
|
|
||||||
emit newLogPeer(temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
|
QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&m_lock);
|
const QReadLocker locker(&m_lock);
|
||||||
|
|
||||||
const int diff = m_msgCounter - lastKnownId - 1;
|
const int diff = m_msgCounter - lastKnownId - 1;
|
||||||
const int size = m_messages.size();
|
const int size = m_messages.size();
|
||||||
@ -110,7 +109,7 @@ QVector<Log::Msg> Logger::getMessages(const int lastKnownId) const
|
|||||||
|
|
||||||
QVector<Log::Peer> Logger::getPeers(const int lastKnownId) const
|
QVector<Log::Peer> Logger::getPeers(const int lastKnownId) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&m_lock);
|
const QReadLocker locker(&m_lock);
|
||||||
|
|
||||||
const int diff = m_peerCounter - lastKnownId - 1;
|
const int diff = m_peerCounter - lastKnownId - 1;
|
||||||
const int size = m_peers.size();
|
const int size = m_peers.size();
|
||||||
|
@ -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);
|
||||||
@ -202,8 +201,9 @@ bool SettingsStorage::save()
|
|||||||
|
|
||||||
QVariant SettingsStorage::loadValue(const QString &key, const QVariant &defaultValue) const
|
QVariant SettingsStorage::loadValue(const QString &key, const QVariant &defaultValue) const
|
||||||
{
|
{
|
||||||
|
const QString realKey = mapKey(key);
|
||||||
const QReadLocker locker(&m_lock);
|
const QReadLocker locker(&m_lock);
|
||||||
return m_data.value(mapKey(key), defaultValue);
|
return m_data.value(realKey, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsStorage::storeValue(const QString &key, const QVariant &value)
|
void SettingsStorage::storeValue(const QString &key, const QVariant &value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user