apt: Fix exiting to game list on application close. (#6353)

This commit is contained in:
Steveice10 2023-03-21 09:07:49 -07:00 committed by GitHub
parent 794d051f0c
commit fbf53686c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 11 deletions

View File

@ -108,8 +108,9 @@ void Thread::Stop() {
u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::CITRA_PAGE_SIZE; u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::CITRA_PAGE_SIZE;
u32 tls_slot = u32 tls_slot =
((tls_address - Memory::TLS_AREA_VADDR) % Memory::CITRA_PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; ((tls_address - Memory::TLS_AREA_VADDR) % Memory::CITRA_PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
ASSERT(owner_process.lock()); if (auto process = owner_process.lock()) {
owner_process.lock()->tls_slots[tls_page].reset(tls_slot); process->tls_slots[tls_page].reset(tls_slot);
}
} }
void ThreadManager::SwitchContext(Thread* new_thread) { void ThreadManager::SwitchContext(Thread* new_thread) {

View File

@ -882,7 +882,12 @@ ResultCode AppletManager::PrepareToCloseApplication(bool return_to_sys) {
} }
if (application_close_target == AppletSlot::HomeMenu) { if (application_close_target == AppletSlot::HomeMenu) {
EnsureHomeMenuLoaded(); // Real APT would make sure home menu is loaded here. However, this is only really
// needed if the home menu wasn't loaded in the first place. Since we want to
// preserve normal behavior when the user loaded the game directly without going
// through home menu, we skip this. Then, later we just close to the game list
// when the application finishes closing.
// EnsureHomeMenuLoaded();
} }
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -896,6 +901,11 @@ ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> objec
GetAppletSlot(AppletSlot::Application)->Reset(); GetAppletSlot(AppletSlot::Application)->Reset();
if (application_close_target != AppletSlot::Error) { if (application_close_target != AppletSlot::Error) {
// If exiting to the home menu and it is not loaded, exit to game list.
if (application_close_target == AppletSlot::HomeMenu &&
!GetAppletSlot(application_close_target)->registered) {
system.RequestShutdown();
} else {
active_slot = application_close_target; active_slot = application_close_target;
CancelAndSendParameter({ CancelAndSendParameter({
@ -906,6 +916,7 @@ ResultCode AppletManager::CloseApplication(std::shared_ptr<Kernel::Object> objec
.buffer = buffer, .buffer = buffer,
}); });
} }
}
// TODO: Terminate the application process. // TODO: Terminate the application process.
return RESULT_SUCCESS; return RESULT_SUCCESS;