mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Windows: Always detach request threads.
No point having a global if it's always detached after use.
This commit is contained in:
parent
f1834fcdde
commit
089580d09a
@ -541,8 +541,7 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn GameBrowser::BrowseClick(UI::EventParams &e) {
|
||||
auto mm = GetI18NCategory("MainMenu");
|
||||
System_BrowseForFolder(mm->T("Choose folder"), [this](const std::string &value, int) {
|
||||
std::string filename = value;
|
||||
System_BrowseForFolder(mm->T("Choose folder"), [this](const std::string &filename, int) {
|
||||
this->SetPath(Path(filename));
|
||||
});
|
||||
return UI::EVENT_DONE;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user