mirror of
https://github.com/lutris/lutris
synced 2024-09-15 22:09:55 +00:00
Prevent a crash when non dict values are passed to the editable grid widget (Closes #2513)
This commit is contained in:
parent
f5322387f5
commit
327b7b76a9
|
@ -430,17 +430,23 @@ class ConfigBox(VBox):
|
|||
|
||||
# Editable grid
|
||||
def generate_editable_grid(self, option_name, label, value=None):
|
||||
"""Adds an editable grid widget"""
|
||||
value = value or {}
|
||||
value = list(value.items())
|
||||
try:
|
||||
value = list(value.items())
|
||||
except AttributeError:
|
||||
logger.error("Invalid value of type %s passed to grid widget: %s", type(value), value)
|
||||
value = {}
|
||||
label = Label(label)
|
||||
|
||||
grid = EditableGrid(value, columns=["Key", "Value"])
|
||||
grid.connect("changed", self.on_grid_changed, option_name)
|
||||
grid.connect("changed", self._on_grid_changed, option_name)
|
||||
self.wrapper.pack_start(label, False, False, 0)
|
||||
self.wrapper.pack_start(grid, True, True, 0)
|
||||
self.option_widget = grid
|
||||
return grid
|
||||
|
||||
def on_grid_changed(self, grid, option):
|
||||
def _on_grid_changed(self, grid, option):
|
||||
values = dict(grid.get_data())
|
||||
self.option_changed(grid, option, values)
|
||||
|
||||
|
|
Loading…
Reference in a new issue