Merge pull request #11864 from iwubcode/graphics_mod_action_check

VideoCommon: check for successful graphics mod action creation before adding targets
This commit is contained in:
Admiral H. Curtiss 2023-05-30 17:28:43 +02:00 committed by GitHub
commit d847c364bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 8 deletions

View File

@ -255,34 +255,39 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config)
target);
};
const auto add_action = [&](GraphicsModConfig mod_config) {
const auto add_action = [&](GraphicsModConfig mod_config) -> bool {
auto action = create_action(feature.m_action, feature.m_action_data, std::move(mod_config));
if (action == nullptr)
{
WARN_LOG_FMT(VIDEO, "Failed to create action '{}' for group '{}'.", feature.m_action,
feature.m_group);
return;
return false;
}
m_actions.push_back(std::move(action));
return true;
};
// Prefer groups in the pack over groups from another pack
if (const auto local_it = group_to_targets.find(internal_group);
local_it != group_to_targets.end())
{
add_action(mod);
for (const GraphicsTargetConfig& target : local_it->second)
if (add_action(mod))
{
add_target(target);
for (const GraphicsTargetConfig& target : local_it->second)
{
add_target(target);
}
}
}
else if (const auto global_it = group_to_targets.find(feature.m_group);
global_it != group_to_targets.end())
{
add_action(mod);
for (const GraphicsTargetConfig& target : global_it->second)
if (add_action(mod))
{
add_target(target);
for (const GraphicsTargetConfig& target : global_it->second)
{
add_target(target);
}
}
}
else