pyqtconfig
pyqtconfig copied to clipboard
Getting stuck with corrupt setting data for QButtonGroup in QSettingsManager
Just had the rare case of having corrupt data in one of my settings. In this specific case it was the mapping of QButtonGroup where the default value is something like [[0, True], [1, False], [2, False]]
. But somehow I managed to save [None, [None]]
as my settings value. Now everytime I try to add the handler for my ButtonGroup I get following error:
Traceback (most recent call last):
File "C:/Users/Lehmann/data/python/python34/jsonwatchqt/run_jsonwatchqt.pyw", line 31, in <module>
w = MainWindow()
File "C:\Users\Lehmann\data\python\python34\jsonwatchqt\jsonwatchqt\mainwindow.py", line 87, in __init__
self.plotsettings = PlotSettingsWidget(self.settings, self)
File "C:\Users\Lehmann\data\python\python34\jsonwatchqt\jsonwatchqt\plotsettings.py", line 89, in __init__
self.autoscaleButtonGroup)
File "c:\users\lehmann\data\python\python34\pyqtconfig\pyqtconfig\config.py", line 824, in add_handler
handler.setter(self._get(key))
File "c:\users\lehmann\data\python\python34\pyqtconfig\pyqtconfig\config.py", line 568, in _set_QButtonGroup
for idx, state in v:
TypeError: 'NoneType' object is not iterable
The only way I could help myself was to use another name for the setting. As the exception occurs in _set_QButtonGroup I thought about wrapping it in a try ... except
right there.
def _set_QButtonGroup(self, v):
"""
Set the states for all buttons in a group from a list of (index, checked) tuples
"""
try:
for idx, state in v:
self.buttons()[idx].setChecked(state)
except TypeError:
pass