[Kernel] Fixed releasing XObject handles on title termination

This commit is contained in:
Adrian
2026-04-12 22:44:48 +01:00
committed by Radosław Gliński
parent e91faca1c4
commit 68d409ebba
3 changed files with 30 additions and 17 deletions

View File

@@ -903,10 +903,7 @@ void KernelState::TerminateTitle() {
// Third: Unload all user modules (including the executable).
for (size_t i = 0; i < user_modules_.size(); i++) {
X_STATUS status = user_modules_[i]->Unload();
assert_true(XSUCCEEDED(status));
object_table_.RemoveHandle(user_modules_[i]->handle());
user_modules_[i]->ReleaseHandle();
}
user_modules_.clear();

View File

@@ -276,7 +276,7 @@ void ObjectTable::PurgeAllObjects() {
auto& entry = table_[slot];
if (entry.object) {
entry.handle_ref_count = 0;
entry.object->Release();
entry.object->ReleaseHandle();
entry.object = nullptr;
}

View File

@@ -383,27 +383,43 @@ void XamLoaderLaunchTitle_entry(lpstring_t raw_name_ptr, dword_t flags) {
auto& loader_data = xam->loader_data();
loader_data.launch_flags = flags;
std::string title;
std::string message;
// Translate the launch path to a full path.
if (raw_name_ptr && !raw_name_ptr.value().empty()) {
loader_data.launch_path = xe::path_to_utf8(raw_name_ptr.value());
loader_data.launch_data_present = true;
xam->SaveLoaderData();
auto display_window = kernel_state()->emulator()->display_window();
auto imgui_drawer = kernel_state()->emulator()->imgui_drawer();
if (display_window && imgui_drawer) {
display_window->app_context().CallInUIThreadSynchronous([imgui_drawer]() {
xe::ui::ImGuiDialog::ShowMessageBox(
imgui_drawer, "Title was restarted",
"Title closed with new launch data. \nPlease restart Xenia. "
"Game will be loaded automatically.");
});
}
title = "Title was restarted";
message =
"Title closed with new launch data. \nPlease restart Xenia. "
"Game will be loaded automatically.";
} else {
title = "Title terminated";
message = "Game requested exit to dashboard.";
assert_always("Game requested exit to dashboard via XamLoaderLaunchTitle");
}
auto display_window = kernel_state()->emulator()->display_window();
auto imgui_drawer = kernel_state()->emulator()->imgui_drawer();
if (display_window && imgui_drawer) {
display_window->app_context().CallInUIThreadSynchronous(
[imgui_drawer, title, message]() {
auto dialog = xe::ui::ImGuiDialog::ShowMessageBox(
imgui_drawer, title.c_str(), message.c_str());
std::jthread([dialog]() {
while (!dialog->IsClosing()) {
std::this_thread::yield();
}
std::quick_exit(0);
}).detach();
});
}
// This function does not return.
kernel_state()->TerminateTitle();
}