Skip to content

Commit

Permalink
gui_settings.py: Handle saving values of None
Browse files Browse the repository at this point in the history
  • Loading branch information
khronokernel committed Oct 5, 2024
1 parent a8f76af commit 6a58ef1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions opencore_legacy_patcher/support/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ def _load_gui_defaults(self) -> None:
continue

constants_key = key.replace("GUI:", "")

if plist[key] == "PYTHON_NONE_VALUE":
plist[key] = None

if hasattr(self.constants, constants_key):
logging.info(f"Setting {constants_key} to {plist[key]}")
setattr(self.constants, constants_key, plist[key])
14 changes: 8 additions & 6 deletions opencore_legacy_patcher/wx_gui/gui_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,14 @@ def on_spinctrl(self, event: wx.Event, label: str) -> None:
def _update_setting(self, variable, value):
logging.info(f"Updating Local Setting: {variable} = {value}")
setattr(self.constants, variable, value)
global_settings.GlobalEnviromentSettings().write_property(f"GUI:{variable}", value)
tmp_value = value or "PYTHON_NONE_VALUE"
global_settings.GlobalEnviromentSettings().write_property(f"GUI:{variable}", tmp_value)


def _update_global_settings(self, variable, value, global_setting = None):
logging.info(f"Updating Global Setting: {variable} = {value}")
global_settings.GlobalEnviromentSettings().write_property(variable, value)
tmp_value = value or "PYTHON_NONE_VALUE"
global_settings.GlobalEnviromentSettings().write_property(variable, tmp_value)
if global_setting is not None:
self._update_setting(global_setting, value)

Expand Down Expand Up @@ -1161,12 +1163,12 @@ def on_sip_value(self, event: wx.Event) -> None:
if hex(self.sip_value) == "0x0":
self.constants.custom_sip_value = None
self.constants.sip_status = True
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", None)
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", "PYTHON_NONE_VALUE")
global_settings.GlobalEnviromentSettings().write_property("GUI:sip_status", True)
elif hex(self.sip_value) == "0x803":
self.constants.custom_sip_value = None
self.constants.sip_status = False
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", None)
global_settings.GlobalEnviromentSettings().write_property("GUI:custom_sip_value", "PYTHON_NONE_VALUE")
global_settings.GlobalEnviromentSettings().write_property("GUI:sip_status", False)
else:
self.constants.custom_sip_value = hex(self.sip_value)
Expand Down Expand Up @@ -1228,7 +1230,7 @@ def fu_selection_click(self, event: wx.Event) -> None:
self.constants.fu_status = True
self.constants.fu_arguments = None
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_status", True)
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "")
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "PYTHON_NONE_VALUE")
return

if value == "Partial":
Expand All @@ -1243,7 +1245,7 @@ def fu_selection_click(self, event: wx.Event) -> None:
self.constants.fu_status = False
self.constants.fu_arguments = None
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_status", False)
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "")
global_settings.GlobalEnviromentSettings().write_property("GUI:fu_arguments", "PYTHON_NONE_VALUE")


def _populate_graphics_override(self, panel: wx.Panel) -> None:
Expand Down

0 comments on commit 6a58ef1

Please sign in to comment.