Browse Source

Fix exceptions on Windows XP when IPv6 is disabled (Thanks paolo zambotti)

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
122db6a77e
  1. 4
      src/properties/peerlistwidget.cpp
  2. 19
      src/qtlibtorrent/qbtsession.cpp
  3. 8
      src/reverseresolution.h

4
src/properties/peerlistwidget.cpp

@ -288,13 +288,15 @@ void PeerListWidget::saveSettings() const {
void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) { void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) {
if(!h.is_valid()) return; if(!h.is_valid()) return;
boost::system::error_code ec;
std::vector<peer_info> peers; std::vector<peer_info> peers;
h.get_peer_info(peers); h.get_peer_info(peers);
std::vector<peer_info>::iterator itr; std::vector<peer_info>::iterator itr;
QSet<QString> old_peers_set = peerItems.keys().toSet(); QSet<QString> old_peers_set = peerItems.keys().toSet();
for(itr = peers.begin(); itr != peers.end(); itr++) { for(itr = peers.begin(); itr != peers.end(); itr++) {
peer_info peer = *itr; peer_info peer = *itr;
QString peer_ip = misc::toQString(peer.ip.address().to_string()); QString peer_ip = misc::toQString(peer.ip.address().to_string(ec));
if(ec) continue;
if(peerItems.contains(peer_ip)) { if(peerItems.contains(peer_ip)) {
// Update existing peer // Update existing peer
updatePeer(peer_ip, peer); updatePeer(peer_ip, peer);

19
src/qtlibtorrent/qbtsession.cpp

@ -2505,12 +2505,20 @@ void QBtSession::readAlerts() {
//emit UPnPSuccess(QString(p->msg().c_str())); //emit UPnPSuccess(QString(p->msg().c_str()));
} }
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) { else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) {
addPeerBanMessage(QString(p->ip.to_string().c_str()), true); boost::system::error_code ec;
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str())); string ip = p->ip.to_string(ec);
if (!ec) {
addPeerBanMessage(QString::fromAscii(ip.c_str()), true);
//emit peerBlocked(QString::fromAscii(ip.c_str()));
}
} }
else if (peer_ban_alert* p = dynamic_cast<peer_ban_alert*>(a.get())) { else if (peer_ban_alert* p = dynamic_cast<peer_ban_alert*>(a.get())) {
addPeerBanMessage(QString(p->ip.address().to_string().c_str()), false); boost::system::error_code ec;
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str())); string ip = p->ip.address().to_string(ec);
if (!ec) {
addPeerBanMessage(QString::fromAscii(ip.c_str()), false);
//emit peerBlocked(QString::fromAscii(ip.c_str()));
}
} }
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) { else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
QTorrentHandle h(p->handle); QTorrentHandle h(p->handle);
@ -2538,7 +2546,8 @@ void QBtSession::readAlerts() {
//emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str())); //emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str()));
} }
else if (listen_succeeded_alert *p = dynamic_cast<listen_succeeded_alert*>(a.get())) { else if (listen_succeeded_alert *p = dynamic_cast<listen_succeeded_alert*>(a.get())) {
qDebug() << "Sucessfully listening on" << p->endpoint.address().to_string().c_str() << "/" << p->endpoint.port(); boost::system::error_code ec;
qDebug() << "Sucessfully listening on" << p->endpoint.address().to_string(ec).c_str() << "/" << p->endpoint.port();
// Force reannounce on all torrents because some trackers blacklist some ports // Force reannounce on all torrents because some trackers blacklist some ports
std::vector<torrent_handle> torrents = s->get_torrents(); std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator it; std::vector<torrent_handle>::iterator it;

8
src/reverseresolution.h

@ -60,7 +60,9 @@ public:
} }
QString getHostFromCache(const libtorrent::asio::ip::tcp::endpoint &ip) { QString getHostFromCache(const libtorrent::asio::ip::tcp::endpoint &ip) {
const QString ip_str = misc::toQString(ip.address().to_string()); boost::system::error_code ec;
const QString ip_str = misc::toQString(ip.address().to_string(ec));
if (ec) return QString();
QString ret; QString ret;
if(m_cache.contains(ip_str)) { if(m_cache.contains(ip_str)) {
qDebug("Got host name from cache"); qDebug("Got host name from cache");
@ -72,7 +74,9 @@ public:
} }
void resolve(const libtorrent::asio::ip::tcp::endpoint &ip) { void resolve(const libtorrent::asio::ip::tcp::endpoint &ip) {
const QString ip_str = misc::toQString(ip.address().to_string()); boost::system::error_code ec;
const QString ip_str = misc::toQString(ip.address().to_string(ec));
if (ec) return;
if(m_cache.contains(ip_str)) { if(m_cache.contains(ip_str)) {
qDebug("Resolved host name using cache"); qDebug("Resolved host name using cache");
emit ip_resolved(ip_str, *m_cache.object(ip_str)); emit ip_resolved(ip_str, *m_cache.object(ip_str));

Loading…
Cancel
Save