1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 14:57:52 +00:00

Fix possible crash when adding a tracker to a magnet torrent without metadata (Closes #1034254)

This commit is contained in:
Christophe Dumez 2012-08-10 11:18:37 +03:00
parent 81b0a7f785
commit 8104c41332
4 changed files with 39 additions and 20 deletions

View File

@ -396,7 +396,9 @@ void PropertiesWidget::loadDynamicData() {
filesList->setUpdatesEnabled(true); filesList->setUpdatesEnabled(true);
} }
} }
} catch(invalid_handle e) {} } catch(const invalid_handle& e) {
qWarning() << "Caught exception in PropertiesWidget::loadDynamicData(): " << e.what();
}
} }
void PropertiesWidget::loadUrlSeeds() { void PropertiesWidget::loadUrlSeeds() {

View File

@ -186,6 +186,28 @@ void TrackerList::clear() {
} }
void TrackerList::loadStickyItems(const QTorrentHandle &h) { void TrackerList::loadStickyItems(const QTorrentHandle &h) {
// load DHT information
if (QBtSession::instance()->isDHTEnabled() && (!h.has_metadata() || !h.priv())) {
dht_item->setText(COL_STATUS, tr("Working"));
} else {
dht_item->setText(COL_STATUS, tr("Disabled"));
}
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"));
// 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... // XXX: libtorrent should provide this info...
// Count peers from DHT, LSD, PeX // Count peers from DHT, LSD, PeX
uint nb_dht = 0, nb_lsd = 0, nb_pex = 0; uint nb_dht = 0, nb_lsd = 0, nb_pex = 0;
@ -201,27 +223,8 @@ void TrackerList::loadStickyItems(const QTorrentHandle &h) {
if (it->source & peer_info::pex) if (it->source & peer_info::pex)
++nb_pex; ++nb_pex;
} }
// load DHT information
if (QBtSession::instance()->isDHTEnabled() && !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)); 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)); 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"));
lsd_item->setText(COL_PEERS, QString::number(nb_lsd)); lsd_item->setText(COL_PEERS, QString::number(nb_lsd));
} }

View File

@ -28,6 +28,7 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include <QDebug>
#include "sessionapplication.h" #include "sessionapplication.h"
SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) : SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) :
@ -42,3 +43,13 @@ void SessionApplication::commitData(QSessionManager & manager) {
Q_UNUSED(manager); Q_UNUSED(manager);
emit sessionIsShuttingDown(); 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;
}

View File

@ -54,6 +54,9 @@ public:
SessionApplication(const QString &id, int &argc, char **argv); SessionApplication(const QString &id, int &argc, char **argv);
void commitData(QSessionManager & manager); void commitData(QSessionManager & manager);
protected:
virtual bool notify(QObject* receiver, QEvent* event);
signals: signals:
void sessionIsShuttingDown(); void sessionIsShuttingDown();
}; };