[Kernel] Fixed releasing XObject handles on title termination
This commit is contained in:
@@ -903,10 +903,7 @@ void KernelState::TerminateTitle() {
|
|||||||
|
|
||||||
// Third: Unload all user modules (including the executable).
|
// Third: Unload all user modules (including the executable).
|
||||||
for (size_t i = 0; i < user_modules_.size(); i++) {
|
for (size_t i = 0; i < user_modules_.size(); i++) {
|
||||||
X_STATUS status = user_modules_[i]->Unload();
|
user_modules_[i]->ReleaseHandle();
|
||||||
assert_true(XSUCCEEDED(status));
|
|
||||||
|
|
||||||
object_table_.RemoveHandle(user_modules_[i]->handle());
|
|
||||||
}
|
}
|
||||||
user_modules_.clear();
|
user_modules_.clear();
|
||||||
|
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ void ObjectTable::PurgeAllObjects() {
|
|||||||
auto& entry = table_[slot];
|
auto& entry = table_[slot];
|
||||||
if (entry.object) {
|
if (entry.object) {
|
||||||
entry.handle_ref_count = 0;
|
entry.handle_ref_count = 0;
|
||||||
entry.object->Release();
|
entry.object->ReleaseHandle();
|
||||||
|
|
||||||
entry.object = nullptr;
|
entry.object = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,27 +383,43 @@ void XamLoaderLaunchTitle_entry(lpstring_t raw_name_ptr, dword_t flags) {
|
|||||||
auto& loader_data = xam->loader_data();
|
auto& loader_data = xam->loader_data();
|
||||||
loader_data.launch_flags = flags;
|
loader_data.launch_flags = flags;
|
||||||
|
|
||||||
|
std::string title;
|
||||||
|
std::string message;
|
||||||
|
|
||||||
// Translate the launch path to a full path.
|
// Translate the launch path to a full path.
|
||||||
if (raw_name_ptr && !raw_name_ptr.value().empty()) {
|
if (raw_name_ptr && !raw_name_ptr.value().empty()) {
|
||||||
loader_data.launch_path = xe::path_to_utf8(raw_name_ptr.value());
|
loader_data.launch_path = xe::path_to_utf8(raw_name_ptr.value());
|
||||||
loader_data.launch_data_present = true;
|
loader_data.launch_data_present = true;
|
||||||
xam->SaveLoaderData();
|
xam->SaveLoaderData();
|
||||||
|
title = "Title was restarted";
|
||||||
auto display_window = kernel_state()->emulator()->display_window();
|
message =
|
||||||
auto imgui_drawer = kernel_state()->emulator()->imgui_drawer();
|
"Title closed with new launch data. \nPlease restart Xenia. "
|
||||||
|
"Game will be loaded automatically.";
|
||||||
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.");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
title = "Title terminated";
|
||||||
|
message = "Game requested exit to dashboard.";
|
||||||
assert_always("Game requested exit to dashboard via XamLoaderLaunchTitle");
|
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.
|
// This function does not return.
|
||||||
kernel_state()->TerminateTitle();
|
kernel_state()->TerminateTitle();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user