Skip to content

Commit 3ae8817

Browse files
committed
Fix a bug in DictOptionDriver
1 parent c35a7a0 commit 3ae8817

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Fixed
1616

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

1920
## [0.1.2] - 2024-05-31
2021

src/libretro/drivers/options/dict.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ def get_variable(self, item: bytes) -> bytes | None:
6666
# For invalid keys, return None
6767
return None
6868

69-
if key not in self._variables:
70-
# For unset options, return the default value
71-
return string_at(self._options_us[key].default_value)
72-
73-
value = self._variables[key]
69+
if key in self._variables:
70+
# If we have a value for this option key...
71+
value = self._variables[key]
72+
else:
73+
# Otherwise get the default value and save it to the dict
74+
value = string_at(self._options_us[key].default_value)
75+
self._variables[key] = value
7476

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

0 commit comments

Comments
 (0)