mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Fix a particular type of race condition in file dialog requests
It seems to be possible for a user to back out of a screen before receiving the "dialog completed" callback on Android, in which case things pointed to by the callback might be gone. In this case, it's better to simply not call the callback, rather than crashing. This is accomplished by assigning "Tokens" to screens that cause requests, and in ~Screen, invalidate any pending requests belonging to that token.
This commit is contained in:
1 parent
b4122ef1f4
commit
1304d04161
24 files changed
+174
-124
No files matched your search
@@ -321,7 +321,7 @@ namespace MainWindow {
|
||||
|
||||
void BrowseAndBootDone(std::string filename);
|
||||
|
||||
void BrowseAndBoot(std::string defaultPath, bool browseDirectory) {
|
||||
void BrowseAndBoot(RequesterToken token, std::string defaultPath, bool browseDirectory) {
|
||||
browsePauseAfter = false;
|
||||
if (GetUIState() == UISTATE_INGAME) {
|
||||
browsePauseAfter = Core_IsStepping();
|
||||
@@ -333,11 +333,11 @@ namespace MainWindow {
|
||||
W32Util::MakeTopMost(GetHWND(), false);
|
||||
|
||||
if (browseDirectory) {
|
||||
System_BrowseForFolder(mm->T("Load"), [](const std::string &value, int) {
|
||||
System_BrowseForFolder(token, mm->T("Load"), [](const std::string &value, int) {
|
||||
BrowseAndBootDone(value);
|
||||
});
|
||||
} else {
|
||||
System_BrowseForFile(mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
|
||||
System_BrowseForFile(token, mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
|
||||
BrowseAndBootDone(value);
|
||||
});
|
||||
}
|
||||
@@ -352,9 +352,9 @@ namespace MainWindow {
|
||||
W32Util::MakeTopMost(GetHWND(), g_Config.bTopMost);
|
||||
}
|
||||
|
||||
static void UmdSwitchAction() {
|
||||
static void UmdSwitchAction(RequesterToken token) {
|
||||
auto mm = GetI18NCategory(I18NCat::MAINMENU);
|
||||
System_BrowseForFile(mm->T("Switch UMD"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
|
||||
System_BrowseForFile(token, mm->T("Switch UMD"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
|
||||
__UmdReplace(Path(value));
|
||||
});
|
||||
}
|
||||
@@ -441,15 +441,15 @@ namespace MainWindow {
|
||||
// Parse the menu selections:
|
||||
switch (wmId) {
|
||||
case ID_FILE_LOAD:
|
||||
BrowseAndBoot("", false);
|
||||
BrowseAndBoot(NON_EPHEMERAL_TOKEN, "", false);
|
||||
break;
|
||||
|
||||
case ID_FILE_LOAD_DIR:
|
||||
BrowseAndBoot("", true);
|
||||
BrowseAndBoot(NON_EPHEMERAL_TOKEN, "", true);
|
||||
break;
|
||||
|
||||
case ID_FILE_LOAD_MEMSTICK:
|
||||
BrowseAndBoot(GetSysDirectory(DIRECTORY_GAME).ToString());
|
||||
BrowseAndBoot(NON_EPHEMERAL_TOKEN, GetSysDirectory(DIRECTORY_GAME).ToString());
|
||||
break;
|
||||
|
||||
case ID_FILE_OPEN_NEW_INSTANCE:
|
||||
@@ -500,7 +500,7 @@ namespace MainWindow {
|
||||
break;
|
||||
|
||||
case ID_EMULATION_SWITCH_UMD:
|
||||
UmdSwitchAction();
|
||||
UmdSwitchAction(NON_EPHEMERAL_TOKEN);
|
||||
break;
|
||||
|
||||
case ID_EMULATION_ROTATION_H: g_Config.iInternalScreenRotation = ROTATION_LOCKED_HORIZONTAL; break;
|
||||
|
||||
Reference in new issue
Block a user