From 055ad080a1d4a1e852c49a404f8c098acd20551a Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Tue, 10 Nov 2015 00:22:18 +0200 Subject: [PATCH] Pass the alertMask to the session constructor to not lose initial alerts. --- src/core/bittorrent/session.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp index ba34c626b..39f398b54 100644 --- a/src/core/bittorrent/session.cpp +++ b/src/core/bittorrent/session.cpp @@ -162,33 +162,31 @@ Session::Session(QObject *parent) const unsigned short port = pref->getSessionPort(); std::pair ports(port, port); const QString ip = getListeningIPs().first(); + // Set severity level of libtorrent session + int alertMask = libt::alert::error_notification + | libt::alert::peer_notification + | libt::alert::port_mapping_notification + | libt::alert::storage_notification + | libt::alert::tracker_notification + | libt::alert::status_notification + | libt::alert::ip_block_notification + | libt::alert::progress_notification + | libt::alert::stats_notification + ; if (ip.isEmpty()) { logger->addMessage(tr("qBittorrent is trying to listen on any interface port: %1", "e.g: qBittorrent is trying to listen on any interface port: TCP/6881").arg(QString::number(port)), Log::INFO); - m_nativeSession = new libt::session(fingerprint, ports, 0, 0); + m_nativeSession = new libt::session(fingerprint, ports, 0, 0, alertMask); } else { logger->addMessage(tr("qBittorrent is trying to listen on interface %1 port: %2", "e.g: qBittorrent is trying to listen on interface 192.168.0.1 port: TCP/6881").arg(ip).arg(port), Log::INFO); - m_nativeSession = new libt::session(fingerprint, ports, ip.toLatin1().constData(), 0); + m_nativeSession = new libt::session(fingerprint, ports, ip.toLatin1().constData(), 0, alertMask); } logger->addMessage(tr("Peer ID: ") + Utils::String::fromStdString(fingerprint.to_string())); m_nativeSession->set_alert_dispatch(boost::bind(&Session::dispatchAlerts, this, _1)); - // Set severity level of libtorrent session - m_nativeSession->set_alert_mask( - libt::alert::error_notification - | libt::alert::peer_notification - | libt::alert::port_mapping_notification - | libt::alert::storage_notification - | libt::alert::tracker_notification - | libt::alert::status_notification - | libt::alert::ip_block_notification - | libt::alert::progress_notification - | libt::alert::stats_notification - ); - // Load previous state loadState();