Skip to content

Commit 4205c2e

Browse files
committed
gfx: fix Graphics Widgets toggle wedging after the first use
The notification-toggle handler gated its gfx_widgets init/deinit on the INITED flag, but the menu (and everything else) reads the *active* flag via gfx_widgets_ready(). drivers_init() sets DISPGFX_WIDGET_FLAG_PERSISTING at startup, so the handler's gfx_widgets_deinit(persisting) never called gfx_widgets_free() and thus never cleared INITED. After the first toggle-off INITED stayed set, so the next toggle-on failed its "!inited" guard, the init branch never ran, active stayed false, and the menu stopped updating -- the toggle worked exactly once. Gate the state machine on p_dispwidget->active (the state the menu reads and that the handler sets directly), and deinit with persisting=false so a real user toggle-off fully tears down and a later toggle-on re-inits cleanly. The double change_handler invocation per toggle is now idempotent too, since the second pass sees the already-updated active state. Compile-verified. This targets the specific "works once then stops" latch; the runtime widget lifecycle still warrants an on-device confirmation. Signed-off-by: LibretroAdmin <LibretroAdmin@users.noreply.github.com>
1 parent bacf70d commit 4205c2e

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

retroarch.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,9 +3979,12 @@ bool command_event(enum event_command cmd, void *data)
39793979
* only the widget lifecycle needs adjusting. Mirrors the enable
39803980
* decision in drivers_init() and the threaded deinit barrier in
39813981
* driver_uninit(). */
3982+
/* Gate on the *active* state -- what gfx_widgets_ready() and the
3983+
* menu read -- not the INITED flag. A persisting deinit leaves
3984+
* INITED set, which would wedge the toggle after the first use
3985+
* (toggle worked once, then the menu stopped updating). */
39823986
dispgfx_widget_t *p_dispwidget = dispwidget_get_ptr();
3983-
bool widgets_inited =
3984-
(p_dispwidget->flags & DISPGFX_WIDGET_FLAG_INITED) != 0;
3987+
bool widgets_active = p_dispwidget->active;
39853988
bool want_widgets =
39863989
settings->bools.video_font_enable
39873990
&& settings->bools.menu_enable_widgets
@@ -3990,7 +3993,7 @@ bool command_event(enum event_command cmd, void *data)
39903993
&& video_st->current_video->gfx_widgets_enabled(
39913994
video_st->data);
39923995

3993-
if (want_widgets && !widgets_inited)
3996+
if (want_widgets && !widgets_active)
39943997
{
39953998
bool force_fs = (video_st->flags &
39963999
VIDEO_FLAG_FORCE_FULLSCREEN) ? true : false;
@@ -4008,7 +4011,7 @@ bool command_event(enum event_command cmd, void *data)
40084011
settings->paths.directory_assets,
40094012
settings->paths.path_font);
40104013
}
4011-
else if (!want_widgets && widgets_inited)
4014+
else if (!want_widgets && widgets_active)
40124015
{
40134016
#ifdef HAVE_THREADS
40144017
/* Same barrier as driver_uninit(): never free widget GPU
@@ -4017,8 +4020,9 @@ bool command_event(enum event_command cmd, void *data)
40174020
&& (video_st->flags & VIDEO_FLAG_THREAD_WRAPPER_ACTIVE))
40184021
video_thread_wait_idle();
40194022
#endif
4020-
gfx_widgets_deinit(p_dispwidget->flags &
4021-
DISPGFX_WIDGET_FLAG_PERSISTING);
4023+
/* Full teardown (not persisting): a real user toggle-off
4024+
* must clear INITED so a later toggle-on re-inits cleanly. */
4025+
gfx_widgets_deinit(false);
40224026
p_dispwidget->active = false;
40234027
}
40244028
}

0 commit comments

Comments
 (0)