Skip to content

Commit 188983d

Browse files
committed
Fix crash on emulator setings when no game data is set
1 parent 1a1ecec commit 188983d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scenes/config/GameEmulatorEditor.gd

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var game_data : RetroHubGameData: set = set_game_data
1313
func _ready():
1414
#warning-ignore:return_value_discarded
1515
RetroHubConfig.game_data_updated.connect(_on_game_data_updated)
16-
16+
1717
n_emulator_options.get_popup().max_size.y = RetroHubUI.max_popupmenu_height
1818

1919
func _on_game_data_updated(_game_data: RetroHubGameData):
@@ -22,12 +22,14 @@ func _on_game_data_updated(_game_data: RetroHubGameData):
2222

2323
func set_game_data(_game_data: RetroHubGameData) -> void:
2424
game_data = _game_data
25+
discard_changes()
26+
if not game_data: return
27+
2528
update_emulator_options()
2629
for idx in n_emulator_options.item_count:
2730
if n_emulator_options.get_item_metadata(idx) == game_data.emulator:
2831
n_emulator_options.selected = idx
2932
break
30-
discard_changes()
3133

3234
func update_emulator_options() -> void:
3335
n_emulator_options.clear()
@@ -49,8 +51,12 @@ func update_emulator_options() -> void:
4951
func discard_changes():
5052
if game_data:
5153
n_override_emulator.button_pressed = !game_data.emulator.is_empty()
54+
n_override_emulator.disabled = false
5255
else:
5356
n_override_emulator.button_pressed = false
57+
n_override_emulator.disabled = true
58+
n_emulator_options.disabled = true
59+
n_emulator_options.clear()
5460

5561

5662
func save_changes():
@@ -61,6 +67,8 @@ func save_changes():
6167
game_data.emulator = ""
6268

6369
func grab_focus():
70+
if not game_data: return
71+
6472
if RetroHubConfig.config.accessibility_screen_reader_enabled:
6573
n_intro_lbl.grab_focus()
6674
else:

0 commit comments

Comments
 (0)