Set dontconnect temporary, completely avoiding saving

v0.6
Dmitri Bogomolov 3 years ago
parent df66277e2d
commit 24ae91ad0a
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
  1. 6
      src/bitmessageqt/settings.py
  2. 13
      src/bmconfigparser.py

@ -490,11 +490,11 @@ class SettingsDialog(QtGui.QDialog):
if self.net_restart_needed:
self.net_restart_needed = False
self.config.set('bitmessagesettings', 'dontconnect', 'true')
self.config.setTemp('bitmessagesettings', 'dontconnect', 'true')
self.timer.singleShot(
5000, lambda:
self.config.remove_option(
'bitmessagesettings', 'dontconnect')
self.config.setTemp(
'bitmessagesettings', 'dontconnect', 'false')
)
self.parent.updateStartOnLogon()

@ -46,6 +46,8 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
"""Singleton class inherited from ConfigParser.SafeConfigParser
with additional methods specific to bitmessage config."""
_temp = {}
def set(self, section, option, value=None):
if self._optcre is self.OPTCRE or value:
if not isinstance(value, basestring):
@ -59,6 +61,10 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
if section == "bitmessagesettings" and option == "timeformat":
return ConfigParser.ConfigParser.get(
self, section, option, raw, variables)
try:
return self._temp[section][option]
except KeyError:
pass
return ConfigParser.ConfigParser.get(
self, section, option, True, variables)
except ConfigParser.InterpolationError:
@ -70,6 +76,13 @@ class BMConfigParser(ConfigParser.SafeConfigParser):
except (KeyError, ValueError, AttributeError):
raise e
def setTemp(self, section, option, value=None):
"""Temporary set option to value, not saving."""
try:
self._temp[section][option] = value
except KeyError:
self._temp[section] = {option: value}
def safeGetBoolean(self, section, field):
try:
return self.getboolean(section, field)

Loading…
Cancel
Save