From b6819de9285df451c41f55857b74dcd6e6469187 Mon Sep 17 00:00:00 2001 From: pynickle <2330458484@qq.com> Date: Thu, 21 May 2026 22:49:49 +0800 Subject: [PATCH] Avoid stale versions in switch-instance popup Filter the popup source list against the repository before creating GameItem rows so a version removed during asynchronous deletion is not rendered from an outdated UI cache. Constraint: Issue #6099 occurs while repository state and the main page cached version list are briefly out of sync during deletion. Rejected: Catching VersionNotFoundException in icon lookup | preserves repository lookup semantics and fixes the stale UI source instead. Confidence: high Scope-risk: narrow Directive: Keep popup item creation aligned with current repository membership when using cached version lists. Tested: ./gradlew -g .gradle-user-home :HMCL:compileJava; ./gradlew -g .gradle-user-home :HMCL:checkstyleMain; git diff --check Not-tested: Manual JavaFX reproduction of issue #6099. --- .../org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java index 703ef2f97a5..fba5f724375 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/GameListPopupMenu.java @@ -53,7 +53,10 @@ public static void show(Node owner, JFXPopup.PopupVPosition vAlign, JFXPopup.Pop double initOffsetX, double initOffsetY, Profile profile, List versions) { GameListPopupMenu menu = new GameListPopupMenu(); - menu.getItems().setAll(versions.stream().map(it -> new GameItem(profile, it.getId())).toList()); + menu.getItems().setAll(versions.stream() + .filter(it -> profile.getRepository().hasVersion(it.getId())) + .map(it -> new GameItem(profile, it.getId())) + .toList()); JFXPopup popup = new JFXPopup(menu); popup.show(owner, vAlign, hAlign, initOffsetX, initOffsetY); }