UI: Forget the views' pending requests when recreating them

WipeRequesterToken() only reset the screen's token, after CreateViews() had
already handed it to the new views, so nothing was ever forgotten - not even
in ~Screen(), which saw a token of -1. A text input dialog open across a
RecreateViews() (on the RetroAchievements screen, a slow login failing) would
then write through a deleted PopupTextInputChoice, possibly into the field
that took its place: #21708.

Requests made while creating views now get their own token, forgotten
before the views are deleted. Screen-level requests keep the screen's token.

RequestManager: ForgetRequestsWithToken() now locks, and also drops
responses that arrived but weren't processed yet. ProcessRequests() calls
the callbacks one at a time without holding the lock, so a callback that
closes a screen drops the rest of that screen's responses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-11 21:29:47 +02:00
1 parent c55fff6b7d
commit e2cda3d8f0
6 files changed
+119 -44

No files matched your search

+5 -3
View File
@@ -39,9 +39,14 @@ void UIScreen::DoRecreateViews() {
root_->PersistData(UI::PERSIST_SAVE, "root", persisted);
}
// Pending requests from the views (like an open text input dialog) would call back into deleted views.
ForgetViewRequests();
delete root_;
root_ = nullptr;
SetCreatingViews(true);
CreateViews();
SetCreatingViews(false);
UI::View *defaultView = root_ ? root_->GetDefaultFocusView() : nullptr;
if (defaultView && defaultView->GetVisibility() == UI::V_VISIBLE) {
defaultView->SetFocus(UI::FocusFlags::CAUSE_OTHER);
@@ -59,9 +64,6 @@ void UIScreen::DoRecreateViews() {
root_->SubviewFocused(focused);
}
}
// NOTE: We also wipe the requester token. It's possible that views were created with the old token, so any pending requests from them must be invalidated.
WipeRequesterToken();
}
bool UIScreen::touch(const TouchInput &touch) {