From 490ef19e6470bade3d9e80a6c0ed6f8ab80cc9e3 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 17 Nov 2009 11:47:48 +0000 Subject: [PATCH] - Made peer addition more robust by catching exceptions --- src/peerlistwidget.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/peerlistwidget.cpp b/src/peerlistwidget.cpp index a3d9b5dfb..8bc978ce6 100644 --- a/src/peerlistwidget.cpp +++ b/src/peerlistwidget.cpp @@ -121,8 +121,12 @@ void PeerListWidget::showPeerListMenu(QPoint) { if(act == addPeerAct) { boost::asio::ip::tcp::endpoint ep = PeerAdditionDlg::askForPeerEndpoint(); if(ep != boost::asio::ip::tcp::endpoint()) { - h.connect_peer(ep); - QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent.")); + try { + h.connect_peer(ep); + QMessageBox::information(0, tr("Peer addition"), tr("The peer was added to this torrent.")); + } catch(std::exception) { + QMessageBox::critical(0, tr("Peer addition"), tr("The peer could not be added to this torrent.")); + } } else { qDebug("No peer was added"); }