From 6c1628f06eacaca82eea77d37c1a3663d260bbd2 Mon Sep 17 00:00:00 2001 From: Arignir Date: Thu, 17 Oct 2024 00:22:25 +0200 Subject: [PATCH] Fix a bug where the entries of the "Recent ROMS" menu could have the same ImGui ID. --- source/app/windows/menubar.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/app/windows/menubar.c b/source/app/windows/menubar.c index dde7721..4aeac1e 100644 --- a/source/app/windows/menubar.c +++ b/source/app/windows/menubar.c @@ -46,7 +46,18 @@ app_win_menubar_file( uint32_t x; for (x = 0; x < array_length(app->file.recent_roms) && app->file.recent_roms[x]; ++x) { - if (igMenuItem_Bool(hs_basename(app->file.recent_roms[x]), NULL, false, true)) { + char label[128]; + char const *basename; + + basename = hs_basename(app->file.recent_roms[x]); + + if (!strlen(basename)) { + continue; + } + + snprintf(label, sizeof(label), "%s##%u", basename, x); + + if (igMenuItem_Bool(label, NULL, false, true)) { char *path; // app->file.recent_roms[] is modified by `app_emulator_configure_and_run()` so we need to copy