Browse Source

Handle exceptions in readAlerts()

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
81b0a7f785
  1. 21
      src/qtlibtorrent/qbtsession.cpp

21
src/qtlibtorrent/qbtsession.cpp

@ -2159,6 +2159,7 @@ void QBtSession::readAlerts() {
// look at session alerts and display some infos // look at session alerts and display some infos
std::auto_ptr<alert> a = s->pop_alert(); std::auto_ptr<alert> a = s->pop_alert();
while (a.get()) { while (a.get()) {
try {
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) { if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
if (h.is_valid()) { if (h.is_valid()) {
@ -2190,13 +2191,13 @@ void QBtSession::readAlerts() {
} }
} catch(std::exception&) { } catch(std::exception&) {
qDebug("Caught error loading torrent"); qDebug("Caught error loading torrent");
#if defined(Q_WS_WIN) || defined(Q_OS_OS2) #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
QString displayed_path = torrent_fullpath; QString displayed_path = torrent_fullpath;
displayed_path.replace("/", "\\"); displayed_path.replace("/", "\\");
addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(displayed_path), QString::fromUtf8("red")); addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(displayed_path), QString::fromUtf8("red"));
#else #else
addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(torrent_fullpath), QString::fromUtf8("red")); addConsoleMessage(tr("Unable to decode %1 torrent file.").arg(torrent_fullpath), QString::fromUtf8("red"));
#endif #endif
} }
} }
} }
@ -2221,21 +2222,21 @@ void QBtSession::readAlerts() {
qDebug("Emitting finishedTorrent() signal"); qDebug("Emitting finishedTorrent() signal");
emit finishedTorrent(h); emit finishedTorrent(h);
qDebug("Received finished alert for %s", qPrintable(h.name())); qDebug("Received finished alert for %s", qPrintable(h.name()));
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
bool will_shutdown = (pref.shutdownWhenDownloadsComplete() || bool will_shutdown = (pref.shutdownWhenDownloadsComplete() ||
pref.shutdownqBTWhenDownloadsComplete() || pref.shutdownqBTWhenDownloadsComplete() ||
pref.suspendWhenDownloadsComplete()) pref.suspendWhenDownloadsComplete())
&& !hasDownloadingTorrents(); && !hasDownloadingTorrents();
#else #else
bool will_shutdown = false; bool will_shutdown = false;
#endif #endif
// AutoRun program // AutoRun program
if (pref.isAutoRunEnabled()) if (pref.isAutoRunEnabled())
autoRunExternalProgram(h, will_shutdown); autoRunExternalProgram(h, will_shutdown);
// Mail notification // Mail notification
if (pref.isMailNotificationEnabled()) if (pref.isMailNotificationEnabled())
sendNotificationEmail(h); sendNotificationEmail(h);
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
// Auto-Shutdown // Auto-Shutdown
if (will_shutdown) { if (will_shutdown) {
bool suspend = pref.suspendWhenDownloadsComplete(); bool suspend = pref.suspendWhenDownloadsComplete();
@ -2267,7 +2268,7 @@ void QBtSession::readAlerts() {
qApp->exit(); qApp->exit();
return; return;
} }
#endif // DISABLE_GUI #endif // DISABLE_GUI
} }
} }
} }
@ -2541,6 +2542,10 @@ void QBtSession::readAlerts() {
} }
} }
} }
} catch (const std::exception& e) {
qWarning() << "Caught exception in readAlerts(): " << e.what();
}
a = s->pop_alert(); a = s->pop_alert();
} }
} }

Loading…
Cancel
Save