new fix for selecting random port when system starts up

This commit is contained in:
tungnian lee 2012-09-15 15:28:58 -07:00 committed by sledgehammer999
parent 2de8b9112d
commit 9913484f68
3 changed files with 16 additions and 18 deletions

View File

@ -262,16 +262,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRandomPort">
<property name="text">
<string>Use random port to communicate</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_7">
<property name="font">
@ -1108,6 +1098,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRandomPort">
<property name="text">
<string>Use random port to communicate</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -133,13 +133,12 @@ options_imp::options_imp(QWidget *parent):
// Connect signals / slots
connect(comboProxyType, SIGNAL(currentIndexChanged(int)),this, SLOT(enableProxy(int)));
connect(checkAnonymousMode, SIGNAL(toggled(bool)), this, SLOT(toggleAnonymousMode(bool)));
connect(checkRandomPort, SIGNAL(toggled(bool)), spinPort, SLOT(setDisabled(bool)));
// Apply button is activated when a value is changed
// General tab
connect(comboI18n, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(checkAltRowColors, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
// add checkbox for random port
connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkShowSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkCloseToSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMinimizeToSysTray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -186,6 +185,7 @@ options_imp::options_imp(QWidget *parent):
connect(autoRun_txt, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
// Connection tab
connect(spinPort, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkRandomPort, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkUPnP, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
@ -369,8 +369,6 @@ void options_imp::saveOptions() {
// General preferences
pref.setLocale(locale);
pref.setAlternatingRowColors(checkAltRowColors->isChecked());
// set random port
pref.setRandomPort(checkRandomPort->isChecked());
pref.setSystrayIntegration(systrayIntegration());
pref.setTrayIconStyle(TrayIcon::Style(comboTrayIcon->currentIndex()));
pref.setCloseToTray(closeToTray());
@ -428,6 +426,7 @@ void options_imp::saveOptions() {
// End Downloads preferences
// Connection preferences
pref.setSessionPort(getPort());
pref.setRandomPort(checkRandomPort->isChecked());
pref.setUPnPEnabled(isUPnPEnabled());
const QPair<int, int> down_up_limit = getGlobalBandwidthLimits();
pref.setGlobalDownloadLimit(down_up_limit.first);
@ -544,8 +543,6 @@ void options_imp::loadOptions() {
const Preferences pref;
setLocale(pref.getLocale());
checkAltRowColors->setChecked(pref.useAlternatingRowColors());
// get random port
checkRandomPort->setChecked(pref.useRandomPort());
checkShowSystray->setChecked(pref.systrayIntegration());
checkShowSplash->setChecked(!pref.isSlashScreenDisabled());
if (checkShowSystray->isChecked()) {
@ -632,6 +629,7 @@ void options_imp::loadOptions() {
// Connection preferences
spinPort->setValue(pref.getSessionPort());
checkUPnP->setChecked(pref.isUPnPEnabled());
checkRandomPort->setChecked(pref.useRandomPort());
intValue = pref.getGlobalDownloadLimit();
if (intValue > 0) {
// Enabled

View File

@ -1532,7 +1532,7 @@ void QBtSession::loadSessionState() {
// bdecode
lazy_entry e;
#if LIBTORRENT_VERSION_NUM >= 001600
error_code ec;
libtorrent::error_code ec;
lazy_bdecode(&in[0], &in[0] + in.size(), e, ec);
if (!ec) {
#else
@ -1916,7 +1916,7 @@ void QBtSession::setListeningPort(int port) {
Preferences pref;
std::pair<int,int> ports(port, port);
#if LIBTORRENT_VERSION_NUM >= 001600
error_code ec;
libtorrent::error_code ec;
#endif
const QString iface_name = pref.getNetworkInterface();
if (iface_name.isEmpty()) {