Skip to content

Commit

Permalink
Fix a bug in DictOptionDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTG committed Jun 2, 2024
1 parent c35a7a0 commit 3ae8817
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed a bug where logging invalid UTF-8 characters in `UnformattedLogDriver` would raise an exception.
- Fixed a bug where logging invalid UTF-8 characters in `UnformattedLogDriver` would raise an exception.
- Fixed a bug where fetching an unset option from a `DictOptionDriver` wouldn't register the default value for next time.

## [0.1.2] - 2024-05-31

Expand Down
12 changes: 7 additions & 5 deletions src/libretro/drivers/options/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ def get_variable(self, item: bytes) -> bytes | None:
# For invalid keys, return None
return None

if key not in self._variables:
# For unset options, return the default value
return string_at(self._options_us[key].default_value)

value = self._variables[key]
if key in self._variables:
# If we have a value for this option key...
value = self._variables[key]
else:
# Otherwise get the default value and save it to the dict
value = string_at(self._options_us[key].default_value)
self._variables[key] = value

if value not in (string_at(v.value) for v in self._options_us[key].values if v.value):
# For invalid values, return None
Expand Down

0 comments on commit 3ae8817

Please sign in to comment.