Skip to content

Commit 3d6c042

Browse files
committed
FullscreenUI: Fix missing lock for settings read
1 parent 93b4c34 commit 3d6c042

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

src/core/fullscreenui_settings.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ static void DrawFolderSetting(SettingsInterface* bsi, std::string_view title, co
172172
const std::string& runtime_var);
173173

174174
static void PopulateGraphicsAdapterList();
175-
static void PopulateGameListDirectoryCache(SettingsInterface* si);
175+
static void PopulateGameListDirectoryCache(const SettingsInterface& si);
176176
static void PopulatePatchesAndCheatsList();
177-
static void PopulatePostProcessingChain(SettingsInterface* si, const char* section);
177+
static void PopulatePostProcessingChain(const SettingsInterface& si, const char* section);
178178
static void BeginEffectBinding(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section,
179179
const char* key, std::string_view display_name);
180180
static void DrawInputBindingButton(SettingsInterface* bsi, InputBindingInfo::Type type, const char* section,
@@ -1580,21 +1580,20 @@ void FullscreenUI::SwitchToSettings()
15801580
{
15811581
s_settings_locals.game_settings_entry.reset();
15821582
s_settings_locals.game_settings_interface.reset();
1583+
s_settings_locals.settings_changed = false;
15831584
s_settings_locals.game_patch_list = {};
15841585
s_settings_locals.enabled_game_patch_cache = {};
15851586
s_settings_locals.game_cheats_list = {};
15861587
s_settings_locals.enabled_game_cheat_cache = {};
15871588
s_settings_locals.game_cheat_groups = {};
15881589

15891590
PopulateGraphicsAdapterList();
1590-
PopulatePostProcessingChain(GetEditingSettingsInterface(), PostProcessing::Config::DISPLAY_CHAIN_SECTION);
15911591
PopulateHotkeyList();
15921592

1593-
if (!IsEditingGameSettings(GetEditingSettingsInterface()))
1594-
{
1595-
auto lock = Host::GetSettingsLock();
1596-
PopulateGameListDirectoryCache(Host::Internal::GetBaseSettingsLayer());
1597-
}
1593+
const auto lock = Host::GetSettingsLock();
1594+
const SettingsInterface* const sif = GetEditingSettingsInterface();
1595+
PopulateGameListDirectoryCache(*sif);
1596+
PopulatePostProcessingChain(*sif, PostProcessing::Config::DISPLAY_CHAIN_SECTION);
15981597

15991598
SwitchToMainWindow(MainWindowType::Settings);
16001599
s_settings_locals.settings_page = SettingsPage::Interface;
@@ -1643,12 +1642,12 @@ void FullscreenUI::PopulateGraphicsAdapterList()
16431642
GPUDevice::GetAdapterListForAPI(Settings::GetRenderAPIForRenderer(renderer));
16441643
}
16451644

1646-
void FullscreenUI::PopulateGameListDirectoryCache(SettingsInterface* si)
1645+
void FullscreenUI::PopulateGameListDirectoryCache(const SettingsInterface& si)
16471646
{
16481647
s_settings_locals.game_list_directories_cache.clear();
1649-
for (std::string& dir : si->GetStringList("GameList", "Paths"))
1648+
for (std::string& dir : si.GetStringList("GameList", "Paths"))
16501649
s_settings_locals.game_list_directories_cache.emplace_back(std::move(dir), false);
1651-
for (std::string& dir : si->GetStringList("GameList", "RecursivePaths"))
1650+
for (std::string& dir : si.GetStringList("GameList", "RecursivePaths"))
16521651
s_settings_locals.game_list_directories_cache.emplace_back(std::move(dir), true);
16531652
}
16541653

@@ -2318,7 +2317,7 @@ void FullscreenUI::DrawGameListSettingsPage()
23182317
bsi->AddToStringList("GameList", "RecursivePaths", dir.c_str());
23192318
bsi->RemoveFromStringList("GameList", "Paths", dir.c_str());
23202319
SetSettingsChanged(bsi);
2321-
PopulateGameListDirectoryCache(bsi);
2320+
PopulateGameListDirectoryCache(*bsi);
23222321
Host::RefreshGameListAsync(false);
23232322
}
23242323
});
@@ -2363,7 +2362,7 @@ void FullscreenUI::DrawGameListSettingsPage()
23632362
}
23642363

23652364
SetSettingsChanged(bsi);
2366-
PopulateGameListDirectoryCache(bsi);
2365+
PopulateGameListDirectoryCache(*bsi);
23672366
}
23682367

23692368
Host::RefreshGameListAsync(false);
@@ -2376,7 +2375,7 @@ void FullscreenUI::DrawGameListSettingsPage()
23762375
bsi->RemoveFromStringList("GameList", "Paths", dir.c_str());
23772376
bsi->RemoveFromStringList("GameList", "RecursivePaths", dir.c_str());
23782377
SetSettingsChanged(bsi);
2379-
PopulateGameListDirectoryCache(bsi);
2378+
PopulateGameListDirectoryCache(*bsi);
23802379
Host::RefreshGameListAsync(false);
23812380
}
23822381
});
@@ -3980,16 +3979,16 @@ void FullscreenUI::DrawGraphicsSettingsPage()
39803979
EndMenuButtons();
39813980
}
39823981

3983-
void FullscreenUI::PopulatePostProcessingChain(SettingsInterface* si, const char* section)
3982+
void FullscreenUI::PopulatePostProcessingChain(const SettingsInterface& si, const char* section)
39843983
{
3985-
const u32 stages = PostProcessing::Config::GetStageCount(*si, section);
3984+
const u32 stages = PostProcessing::Config::GetStageCount(si, section);
39863985
s_settings_locals.postprocessing_stages.clear();
39873986
s_settings_locals.postprocessing_stages.reserve(stages);
39883987
for (u32 i = 0; i < stages; i++)
39893988
{
39903989
PostProcessingStageInfo psi;
3991-
psi.name = PostProcessing::Config::GetStageShaderName(*si, section, i);
3992-
psi.options = PostProcessing::Config::GetStageOptions(*si, section, i);
3990+
psi.name = PostProcessing::Config::GetStageShaderName(si, section, i);
3991+
psi.options = PostProcessing::Config::GetStageOptions(si, section, i);
39933992
s_settings_locals.postprocessing_stages.push_back(std::move(psi));
39943993
}
39953994
}
@@ -4062,7 +4061,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
40624061
{
40634062
ShowToast(std::string(), fmt::format(FSUI_FSTR("Shader {} added as stage {}."), title,
40644063
PostProcessing::Config::GetStageCount(*bsi, section)));
4065-
PopulatePostProcessingChain(bsi, section);
4064+
PopulatePostProcessingChain(*bsi, section);
40664065
SetSettingsChanged(bsi);
40674066
queue_reload();
40684067
}
@@ -4086,7 +4085,7 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
40864085

40874086
SettingsInterface* bsi = GetEditingSettingsInterface();
40884087
PostProcessing::Config::ClearStages(*bsi, section);
4089-
PopulatePostProcessingChain(bsi, section);
4088+
PopulatePostProcessingChain(*bsi, section);
40904089
SetSettingsChanged(bsi);
40914090
ShowToast(std::string(), FSUI_STR("Post-processing chain cleared."));
40924091
queue_reload();
@@ -4310,23 +4309,23 @@ void FullscreenUI::DrawPostProcessingSettingsPage()
43104309
ShowToast(std::string(),
43114310
fmt::format(FSUI_FSTR("Removed stage {} ({})."), postprocessing_action_index + 1, si.name));
43124311
PostProcessing::Config::RemoveStage(*bsi, section, postprocessing_action_index);
4313-
PopulatePostProcessingChain(bsi, section);
4312+
PopulatePostProcessingChain(*bsi, section);
43144313
SetSettingsChanged(bsi);
43154314
reload_pending = true;
43164315
}
43174316
break;
43184317
case POSTPROCESSING_ACTION_MOVE_UP:
43194318
{
43204319
PostProcessing::Config::MoveStageUp(*bsi, section, postprocessing_action_index);
4321-
PopulatePostProcessingChain(bsi, section);
4320+
PopulatePostProcessingChain(*bsi, section);
43224321
SetSettingsChanged(bsi);
43234322
reload_pending = true;
43244323
}
43254324
break;
43264325
case POSTPROCESSING_ACTION_MOVE_DOWN:
43274326
{
43284327
PostProcessing::Config::MoveStageDown(*bsi, section, postprocessing_action_index);
4329-
PopulatePostProcessingChain(bsi, section);
4328+
PopulatePostProcessingChain(*bsi, section);
43304329
SetSettingsChanged(bsi);
43314330
reload_pending = true;
43324331
}

0 commit comments

Comments
 (0)