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

This commit is contained in:
Christophe Dumez 2011-05-05 16:16:20 +00:00
parent 86d3c98069
commit 122db6a77e
3 changed files with 23 additions and 8 deletions

View file

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

View file

@ -2505,12 +2505,20 @@ void QBtSession::readAlerts() {
//emit UPnPSuccess(QString(p->msg().c_str()));
}
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) {
addPeerBanMessage(QString(p->ip.to_string().c_str()), true);
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str()));
boost::system::error_code ec;
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())) {
addPeerBanMessage(QString(p->ip.address().to_string().c_str()), false);
//emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str()));
boost::system::error_code ec;
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())) {
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()));
}
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
std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator it;

View file

@ -60,7 +60,9 @@ public:
}
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;
if(m_cache.contains(ip_str)) {
qDebug("Got host name from cache");
@ -72,7 +74,9 @@ public:
}
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)) {
qDebug("Resolved host name using cache");
emit ip_resolved(ip_str, *m_cache.object(ip_str));