Do not propose user to restart Bitmessage,

drop network connections instead
This commit is contained in:
Dmitri Bogomolov 2018-11-20 16:53:25 +02:00
parent 46b3f6b48b
commit 0c4d1b4e32
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

View File

@ -1,7 +1,7 @@
import os
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore, QtGui
import debug
import defaults
@ -29,6 +29,8 @@ class SettingsDialog(QtGui.QDialog):
self.parent = parent
self.firstrun = firstrun
self.config = BMConfigParser()
self.net_restart_needed = False
self.timer = QtCore.QTimer()
self.lineEditMaxOutboundConnections.setValidator(
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
@ -284,16 +286,11 @@ class SettingsDialog(QtGui.QDialog):
if int(self.config.get('bitmessagesettings', 'port')) != int(
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(
'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(
'bitmessagesettings', 'upnp'):
self.config.set(
@ -307,17 +304,10 @@ class SettingsDialog(QtGui.QDialog):
if (
self.config.get('bitmessagesettings', 'socksproxytype') ==
'none' and
self.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
self.comboBoxProxyType.currentText()[0:5] == 'SOCKS' and
shared.statusIconColor != 'red'
):
if shared.statusIconColor != 'red':
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).")
)
self.net_restart_needed = True
if (
self.config.get('bitmessagesettings', 'socksproxytype')[0:5] ==
'SOCKS' and self.comboBoxProxyType.currentText()[0:5] != 'SOCKS'
@ -364,6 +354,15 @@ class SettingsDialog(QtGui.QDialog):
self.config.set('bitmessagesettings', 'maxoutboundconnections', str(
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(
'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType())
self.config.set('bitmessagesettings', 'namecoinrpchost', str(