mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-15 15:30:29 +02:00
Windows: Always detach request threads.
No point having a global if it's always detached after use.
This commit is contained in:
1 parent
f1834fcdde
commit
089580d09a
2 files changed
+11
-26
No files matched your search
+10
-24
@@ -111,9 +111,6 @@ static std::string restartArgs;
|
||||
|
||||
int g_activeWindow = 0;
|
||||
|
||||
// Used for all the system dialogs.
|
||||
static std::thread g_dialogThread;
|
||||
|
||||
WindowsInputManager g_inputManager;
|
||||
|
||||
int g_lastNumInstances = 0;
|
||||
@@ -496,24 +493,17 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
if (g_dialogThread.joinable())
|
||||
g_dialogThread.join();
|
||||
|
||||
g_dialogThread = std::thread([=] {
|
||||
std::thread([=] {
|
||||
std::string out;
|
||||
if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), param2, out)) {
|
||||
g_requestManager.PostSystemSuccess(requestId, out.c_str());
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
}
|
||||
});
|
||||
g_dialogThread.detach();
|
||||
}).detach();
|
||||
return true;
|
||||
case SystemRequestType::BROWSE_FOR_IMAGE:
|
||||
if (g_dialogThread.joinable())
|
||||
g_dialogThread.join();
|
||||
|
||||
g_dialogThread = std::thread([=] {
|
||||
std::thread([=] {
|
||||
std::string out;
|
||||
if (W32Util::BrowseForFileName(true, MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), nullptr,
|
||||
MakeFilter(L"All supported images (*.jpg *.jpeg *.png)|*.jpg;*.jpeg;*.png|All files (*.*)|*.*||").c_str(), L"jpg", out)) {
|
||||
@@ -521,8 +511,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
}
|
||||
});
|
||||
g_dialogThread.detach();
|
||||
}).detach();
|
||||
return true;
|
||||
case SystemRequestType::BROWSE_FOR_FILE:
|
||||
{
|
||||
@@ -545,28 +534,26 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
return false;
|
||||
}
|
||||
|
||||
g_dialogThread = std::thread([=] {
|
||||
std::thread([=] {
|
||||
std::string out;
|
||||
if (W32Util::BrowseForFileName(true, MainWindow::GetHWND(), ConvertUTF8ToWString(param1).c_str(), nullptr, filter.c_str(), L"", out)) {
|
||||
g_requestManager.PostSystemSuccess(requestId, out.c_str());
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
}
|
||||
});
|
||||
g_dialogThread.detach();
|
||||
}).detach();
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::BROWSE_FOR_FOLDER:
|
||||
{
|
||||
g_dialogThread = std::thread([=] {
|
||||
std::thread([=] {
|
||||
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), param1.c_str());
|
||||
if (folder.size()) {
|
||||
g_requestManager.PostSystemSuccess(requestId, folder.c_str());
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
}
|
||||
});
|
||||
g_dialogThread.detach();
|
||||
}).detach();
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::TOGGLE_FULLSCREEN_STATE:
|
||||
@@ -728,9 +715,8 @@ static void WinMainInit() {
|
||||
}
|
||||
|
||||
static void WinMainCleanup() {
|
||||
if (g_dialogThread.joinable()) {
|
||||
g_dialogThread.join();
|
||||
}
|
||||
// This will ensure no further callbacks are called, which may prevent crashing.
|
||||
g_requestManager.Clear();
|
||||
net::Shutdown();
|
||||
CoUninitialize();
|
||||
|
||||
|
||||
Reference in new issue
Block a user