diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index 289a9b1e6..5eda693c9 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -396,7 +396,9 @@ void PropertiesWidget::loadDynamicData() { filesList->setUpdatesEnabled(true); } } - } catch(invalid_handle e) {} + } catch(const invalid_handle& e) { + qWarning() << "Caught exception in PropertiesWidget::loadDynamicData(): " << e.what(); + } } void PropertiesWidget::loadUrlSeeds() { diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index 4fb472d67..f7f63be37 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -186,42 +186,45 @@ void TrackerList::clear() { } void TrackerList::loadStickyItems(const QTorrentHandle &h) { - // XXX: libtorrent should provide this info... - // Count peers from DHT, LSD, PeX - uint nb_dht = 0, nb_lsd = 0, nb_pex = 0; - std::vector peers; - h.get_peer_info(peers); - std::vector::iterator it = peers.begin(); - std::vector::iterator end = peers.end(); - for ( ; it != end; ++it) { - if (it->source & peer_info::dht) - ++nb_dht; - if (it->source & peer_info::lsd) - ++nb_lsd; - if (it->source & peer_info::pex) - ++nb_pex; - } // load DHT information - if (QBtSession::instance()->isDHTEnabled() && !h.priv()) { + if (QBtSession::instance()->isDHTEnabled() && (!h.has_metadata() || !h.priv())) { dht_item->setText(COL_STATUS, tr("Working")); } else { dht_item->setText(COL_STATUS, tr("Disabled")); } - dht_item->setText(COL_PEERS, QString::number(nb_dht)); if (h.has_metadata() && h.priv()) { dht_item->setText(COL_MSG, tr("This torrent is private")); } + // Load PeX Information if (QBtSession::instance()->isPexEnabled()) pex_item->setText(COL_STATUS, tr("Working")); else pex_item->setText(COL_STATUS, tr("Disabled")); - pex_item->setText(COL_PEERS, QString::number(nb_pex)); + // Load LSD Information if (QBtSession::instance()->isLSDEnabled()) lsd_item->setText(COL_STATUS, tr("Working")); else lsd_item->setText(COL_STATUS, tr("Disabled")); + + // XXX: libtorrent should provide this info... + // Count peers from DHT, LSD, PeX + uint nb_dht = 0, nb_lsd = 0, nb_pex = 0; + std::vector peers; + h.get_peer_info(peers); + std::vector::iterator it = peers.begin(); + std::vector::iterator end = peers.end(); + for ( ; it != end; ++it) { + if (it->source & peer_info::dht) + ++nb_dht; + if (it->source & peer_info::lsd) + ++nb_lsd; + if (it->source & peer_info::pex) + ++nb_pex; + } + dht_item->setText(COL_PEERS, QString::number(nb_dht)); + pex_item->setText(COL_PEERS, QString::number(nb_pex)); lsd_item->setText(COL_PEERS, QString::number(nb_lsd)); } diff --git a/src/sessionapplication.cpp b/src/sessionapplication.cpp index 4a8b264b6..8a06abedf 100644 --- a/src/sessionapplication.cpp +++ b/src/sessionapplication.cpp @@ -28,6 +28,7 @@ * Contact : chris@qbittorrent.org */ +#include #include "sessionapplication.h" SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) : @@ -42,3 +43,13 @@ void SessionApplication::commitData(QSessionManager & manager) { Q_UNUSED(manager); emit sessionIsShuttingDown(); } + +bool SessionApplication::notify(QObject* receiver, QEvent* event) { + try { + return QApplication::notify(receiver, event); + } catch(const std::exception& e) { + qCritical() << "Exception thrown:" << e.what() << ", receiver: " << receiver->objectName(); + receiver->dumpObjectInfo(); + } + return false; +} diff --git a/src/sessionapplication.h b/src/sessionapplication.h index d3ce6866b..a7bfbf6fd 100644 --- a/src/sessionapplication.h +++ b/src/sessionapplication.h @@ -54,6 +54,9 @@ public: SessionApplication(const QString &id, int &argc, char **argv); void commitData(QSessionManager & manager); +protected: + virtual bool notify(QObject* receiver, QEvent* event); + signals: void sessionIsShuttingDown(); };