Browse Source

No longer fallback to ANY interface if the user-selected interface cannot be found (closes #143)

adaptive-webui-19844
Christophe Dumez 12 years ago
parent
commit
26314fae01
  1. 10
      src/preferences/advancedsettings.h
  2. 6
      src/qtlibtorrent/qbtsession.cpp

10
src/preferences/advancedsettings.h

@ -198,14 +198,22 @@ private slots:
// Network interface // Network interface
combo_iface.addItem(tr("Any interface", "i.e. Any network interface")); combo_iface.addItem(tr("Any interface", "i.e. Any network interface"));
const QString current_iface = pref.getNetworkInterface(); const QString current_iface = pref.getNetworkInterface();
bool interface_exists = current_iface.isEmpty();
int i = 1; int i = 1;
foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) { foreach (const QNetworkInterface& iface, QNetworkInterface::allInterfaces()) {
if (iface.flags() & QNetworkInterface::IsLoopBack) continue; if (iface.flags() & QNetworkInterface::IsLoopBack) continue;
combo_iface.addItem(iface.name()); combo_iface.addItem(iface.name());
if (!current_iface.isEmpty() && iface.name() == current_iface) if (!current_iface.isEmpty() && iface.name() == current_iface) {
combo_iface.setCurrentIndex(i); combo_iface.setCurrentIndex(i);
interface_exists = true;
}
++i; ++i;
} }
// Saved interface does not exist, show it anyway
if (!interface_exists) {
combo_iface.addItem(current_iface);
combo_iface.setCurrentIndex(i);
}
setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface); setRow(NETWORK_IFACE, tr("Network Interface (requires restart)"), &combo_iface);
// Network address // Network address
txt_network_address.setText(pref.getNetworkAddress()); txt_network_address.setText(pref.getNetworkAddress());

6
src/qtlibtorrent/qbtsession.cpp

@ -1917,12 +1917,6 @@ void QBtSession::setListeningPort(int port) {
if (!network_iface.isValid()) { if (!network_iface.isValid()) {
qDebug("Invalid network interface: %s", qPrintable(iface_name)); qDebug("Invalid network interface: %s", qPrintable(iface_name));
addConsoleMessage(tr("The network interface defined is invalid: %1").arg(iface_name), "red"); addConsoleMessage(tr("The network interface defined is invalid: %1").arg(iface_name), "red");
addConsoleMessage(tr("Trying any other network interface available instead."));
#if LIBTORRENT_VERSION_MINOR > 15
s->listen_on(ports, ec);
#else
s->listen_on(ports);
#endif
return; return;
} }
QString ip; QString ip;

Loading…
Cancel
Save