Improved IP address parsing

This commit is contained in:
Christophe Dumez
2010-11-07 11:36:37 +00:00
parent da95d5e0df
commit 41a61ced89
2 changed files with 40 additions and 7 deletions

View File

@@ -60,7 +60,12 @@ public:
~PeerAdditionDlg(){}
QString getIP() const {
return lineIP->text();
QHostAddress ip(lineIP->text());
if(!ip.isNull()) {
// QHostAddress::toString() cleans up the IP for libtorrent
return ip.toString();
}
return QString();
}
unsigned short getPort() const {
@@ -87,8 +92,7 @@ public:
protected slots:
void validateInput() {
QHostAddress ip(getIP());
if(ip.isNull()) {
if(getIP().isEmpty()) {
QMessageBox::warning(this, tr("Invalid IP"),
tr("The IP you provided is invalid."),
QMessageBox::Ok);