Avoid doing unnecessary UI work during shutdown, add a sanity check

This commit is contained in:
Henrik Rydgård committed 2025-05-13 13:56:01 +02:00
1 parent c817a0755c
commit 37712734e2
2 files changed
+30 -12

No files matched your search

+29 -11
View File
@@ -210,8 +210,9 @@ void EmuScreen::ProcessGameBoot(const Path &filename) {
return;
}
if (Achievements::IsBlockingExecution()) {
// Keep waiting.
if (!root_) {
// Views not created yet, wait until they are. Not sure if this can actually happen
// but crash reports seem to indicate it.
return;
}
@@ -220,6 +221,11 @@ void EmuScreen::ProcessGameBoot(const Path &filename) {
return;
}
if (Achievements::IsBlockingExecution()) {
// Keep waiting.
return;
}
std::string error_string = "(unknown error)";
BootState state = PSP_InitUpdate(&error_string);
@@ -456,11 +462,17 @@ EmuScreen::~EmuScreen() {
}
void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
if (std::string_view(dialog->tag()) == "TextEditPopup") {
std::string_view tag = dialog->tag();
if (tag == "TextEditPopup") {
// Chat message finished.
return;
}
// Returning to the PauseScreen, unless we're stepping, means we should go back to controls.
if (Core_IsActive()) {
UI::EnableFocusMovement(false);
}
// TODO: improve the way with which we got commands from PauseMenu.
// DR_CANCEL/DR_BACK means clicked on "continue", DR_OK means clicked on "back to menu",
// DR_YES means a message sent to PauseMenu by System_PostUIMessage.
@@ -468,11 +480,10 @@ void EmuScreen::dialogFinished(const Screen *dialog, DialogResult result) {
_dbg_assert_(!bootPending_);
screenManager()->switchScreen(new MainScreen());
quit_ = false;
} else {
RecreateViews();
}
// Returning to the PauseScreen, unless we're stepping, means we should go back to controls.
if (Core_IsActive())
UI::EnableFocusMovement(false);
RecreateViews();
SetExtraAssertInfo(extraAssertInfoStr_.c_str());
// Make sure we re-enable keyboard mode if it was disabled by the dialog, and if needed.
@@ -523,7 +534,6 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
}
PSP_Shutdown(true);
Achievements::UnloadGame();
bootPending_ = false;
System_Notify(SystemNotification::DISASSEMBLY);
} else if (message == UIMessage::REQUEST_GAME_RESET) {
if (bootPending_) {
@@ -532,7 +542,10 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
}
PSP_Shutdown(true);
Achievements::UnloadGame();
// Restart the boot process
bootPending_ = true;
RecreateViews();
_dbg_assert_(coreState == CORE_POWERDOWN);
if (!PSP_InitStart(PSP_CoreParameter())) {
ERROR_LOG(Log::Loader, "Error resetting");
@@ -602,6 +615,10 @@ void EmuScreen::sendMessage(UIMessage message, const char *value) {
UI::EventParams e{};
OnChatMenu.Trigger(e);
}
} else if (!g_Config.bEnableNetworkChat) {
if (chatButton_) {
RecreateViews();
}
}
} else if (message == UIMessage::APP_RESUMED && screenManager()->topScreen() == this) {
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
@@ -1222,6 +1239,8 @@ void EmuScreen::CreateViews() {
cardboardDisableButton_->SetVisibility(V_GONE);
cardboardDisableButton_->SetScale(0.65f); // make it smaller - this button can be in the way otherwise.
chatButton_ = nullptr;
chatMenu_ = nullptr;
if (g_Config.bEnableNetworkChat) {
if (g_Config.iChatButtonPosition != 8) {
auto n = GetI18NCategory(I18NCat::NETWORKING);
@@ -1232,9 +1251,6 @@ void EmuScreen::CreateViews() {
}
chatMenu_ = root_->Add(new ChatMenu(GetRequesterToken(), screenManager()->getUIContext()->GetBounds(), screenManager(), new LayoutParams(FILL_PARENT, FILL_PARENT)));
chatMenu_->SetVisibility(UI::V_GONE);
} else {
chatButton_ = nullptr;
chatMenu_ = nullptr;
}
saveStatePreview_ = new AsyncImageFileView(Path(), IS_FIXED, new AnchorLayoutParams(bounds.centerX(), 100, NONE, NONE, true));
@@ -1339,7 +1355,9 @@ int GetChatMessageCount();
void EmuScreen::update() {
using namespace UI;
// This is where views are recreated.
UIScreen::update();
resumeButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR && Memory::MemFault_MayBeResumable() ? V_VISIBLE : V_GONE);
resetButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR ? V_VISIBLE : V_GONE);
backButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR ? V_VISIBLE : V_GONE);
+1 -1
View File
@@ -603,7 +603,7 @@ void GamePauseScreen::dialogFinished(const Screen *dialog, DialogResult dr) {
} else {
if (tag == "Game") {
g_BackgroundAudio.SetGame(Path());
} else if (tag != "ContextMenuPopup") {
} else if (tag != "Prompt" && tag != "ContextMenuPopup") {
// There may have been changes to our savestates, so let's recreate.
RecreateViews();
}