Skip to content

Commit

Permalink
Shell|GUI: Inform user about an invalid port number
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 13, 2013
1 parent 90a7a5f commit 7d8e0c4
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions doomsday/tools/shell/shell-gui/src/localserverdialog.cpp
Expand Up @@ -80,8 +80,8 @@ DENG2_PIMPL(LocalServerDialog)
port->setMinimumWidth(80);
port->setMaximumWidth(80);
port->setText(QString::number(st.value("LocalServer/port", 13209).toInt()));
port->setToolTip(tr("Port must be between 0 and 65535."));
portMsg = new QLabel(tr("Port already in use."));
port->setToolTip(tr("The default port is 13209."));
portMsg = new QLabel;
QPalette pal = portMsg->palette();
pal.setColor(portMsg->foregroundRole(), Qt::red);
portMsg->setPalette(pal);
Expand Down Expand Up @@ -178,19 +178,25 @@ void LocalServerDialog::validate()
if(txt.isEmpty() || port < 0 || port >= 0x10000)
{
isValid = false;
d->portMsg->setText(tr("Must be between 0 and 65535."));
d->portMsg->show();
}

// Check known running servers.
bool inUse = false;
foreach(Address const &sv, GuiShellApp::app().serverFinder().foundServers())
else
{
if(Socket::isHostLocal(sv.host()) && sv.port() == port)
// Check known running servers.
bool inUse = false;
foreach(Address const &sv, GuiShellApp::app().serverFinder().foundServers())
{
isValid = false;
inUse = true;
if(Socket::isHostLocal(sv.host()) && sv.port() == port)
{
isValid = false;
inUse = true;
d->portMsg->setText(tr("Port already in use."));
break;
}
}
d->portMsg->setVisible(inUse);
}
d->portMsg->setVisible(inUse);

if(d->runtime->path().isEmpty()) isValid = false;

Expand Down

0 comments on commit 7d8e0c4

Please sign in to comment.