Configtool: try to repair broken value-#defines.

Previously, #defines requiring a value, but configured as boolean,
broke GUI code. While Configtool its self should never write such
broken #defines, they can happen with manual config file edits.

IMHO it's fine to do such repair attempts as long as it doesn't
hobble other functionality. Whatever was broken at read time will
end up disabled at write time, unless the user changes that value
in the GUI.
This commit is contained in:
Markus Hitter 2016-06-01 21:52:21 +02:00
parent 490e58a43c
commit 776b3dec94
2 changed files with 12 additions and 2 deletions

View File

@ -396,7 +396,12 @@ class BoardPanel(wx.Panel):
m = reDefBool.search(ln)
if m:
t = m.groups()
if len(t) == 1 and (t[0] in self.cfgNames):
# Accept booleans, but not those for which a value exists already.
# Booleans already existing as values are most likely misconfigured
# manual edits (or result of a bug).
if len(t) == 1 and t[0] in self.cfgNames \
and not (t[0] in self.cfgValues \
and isinstance(self.cfgValues[t[0]], tuple)):
if reDefBoolBL.search(ln):
self.cfgValues[t[0]] = True
else:

View File

@ -322,7 +322,12 @@ class PrinterPanel(wx.Panel):
m = reDefBool.search(ln)
if m:
t = m.groups()
if len(t) == 1 and (t[0] in self.cfgNames):
# Accept booleans, but not those for which a value exists already.
# Booleans already existing as values are most likely misconfigured
# manual edits (or result of a bug).
if len(t) == 1 and t[0] in self.cfgNames \
and not (t[0] in self.cfgValues \
and isinstance(self.cfgValues[t[0]], tuple)):
if reDefBoolBL.search(ln):
self.cfgValues[t[0]] = True
else: