Do not propose user to restart Bitmessage,
drop network connections instead
This commit is contained in:
parent
46b3f6b48b
commit
0c4d1b4e32
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
import defaults
|
import defaults
|
||||||
|
@ -29,6 +29,8 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.firstrun = firstrun
|
self.firstrun = firstrun
|
||||||
self.config = BMConfigParser()
|
self.config = BMConfigParser()
|
||||||
|
self.net_restart_needed = False
|
||||||
|
self.timer = QtCore.QTimer()
|
||||||
|
|
||||||
self.lineEditMaxOutboundConnections.setValidator(
|
self.lineEditMaxOutboundConnections.setValidator(
|
||||||
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
|
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
|
||||||
|
@ -284,16 +286,11 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
|
|
||||||
if int(self.config.get('bitmessagesettings', 'port')) != int(
|
if int(self.config.get('bitmessagesettings', 'port')) != int(
|
||||||
self.lineEditTCPPort.text()):
|
self.lineEditTCPPort.text()):
|
||||||
if not self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
|
||||||
QtGui.QMessageBox.about(
|
|
||||||
self, _translate("MainWindow", "Restart"),
|
|
||||||
_translate(
|
|
||||||
"MainWindow",
|
|
||||||
"You must restart Bitmessage for the port number"
|
|
||||||
" change to take effect.")
|
|
||||||
)
|
|
||||||
self.config.set(
|
self.config.set(
|
||||||
'bitmessagesettings', 'port', str(self.lineEditTCPPort.text()))
|
'bitmessagesettings', 'port', str(self.lineEditTCPPort.text()))
|
||||||
|
if not self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||||
|
self.net_restart_needed = True
|
||||||
|
|
||||||
if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean(
|
if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean(
|
||||||
'bitmessagesettings', 'upnp'):
|
'bitmessagesettings', 'upnp'):
|
||||||
self.config.set(
|
self.config.set(
|
||||||
|
@ -307,17 +304,10 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
if (
|
if (
|
||||||
self.config.get('bitmessagesettings', 'socksproxytype') ==
|
self.config.get('bitmessagesettings', 'socksproxytype') ==
|
||||||
'none' and
|
'none' and
|
||||||
self.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
|
self.comboBoxProxyType.currentText()[0:5] == 'SOCKS' and
|
||||||
|
shared.statusIconColor != 'red'
|
||||||
):
|
):
|
||||||
if shared.statusIconColor != 'red':
|
self.net_restart_needed = True
|
||||||
QtGui.QMessageBox.about(
|
|
||||||
self, _translate("MainWindow", "Restart"),
|
|
||||||
_translate(
|
|
||||||
"MainWindow",
|
|
||||||
"Bitmessage will use your proxy from now on but"
|
|
||||||
" you may want to manually restart Bitmessage now"
|
|
||||||
" to close existing connections (if any).")
|
|
||||||
)
|
|
||||||
if (
|
if (
|
||||||
self.config.get('bitmessagesettings', 'socksproxytype')[0:5] ==
|
self.config.get('bitmessagesettings', 'socksproxytype')[0:5] ==
|
||||||
'SOCKS' and self.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
|
'SOCKS' and self.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
|
||||||
|
@ -364,6 +354,15 @@ class SettingsDialog(QtGui.QDialog):
|
||||||
self.config.set('bitmessagesettings', 'maxoutboundconnections', str(
|
self.config.set('bitmessagesettings', 'maxoutboundconnections', str(
|
||||||
int(float(self.lineEditMaxOutboundConnections.text()))))
|
int(float(self.lineEditMaxOutboundConnections.text()))))
|
||||||
|
|
||||||
|
if self.net_restart_needed:
|
||||||
|
self.net_restart_needed = False
|
||||||
|
self.config.set('bitmessagesettings', 'dontconnect', 'true')
|
||||||
|
self.timer.singleShot(
|
||||||
|
5000, lambda:
|
||||||
|
self.config.remove_option(
|
||||||
|
'bitmessagesettings', 'dontconnect')
|
||||||
|
)
|
||||||
|
|
||||||
self.config.set(
|
self.config.set(
|
||||||
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
|
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
|
||||||
self.config.set('bitmessagesettings', 'namecoinrpchost', str(
|
self.config.set('bitmessagesettings', 'namecoinrpchost', str(
|
||||||
|
|
Reference in New Issue
Block a user