summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp
diff options
context:
space:
mode:
authorTryTwo <taolas@gmail.com>2025-03-26 13:15:57 -0700
committerTryTwo <taolas@gmail.com>2025-03-26 13:15:57 -0700
commite5608c6ca5d594e1de25997b1b87d68287892661 (patch)
tree0cc3a097a6a49e204bea593da88a8097eb66eb66 /Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp
parent896b4bb1fa1919a7addb01cea1f7c6adb8e3715d (diff)
ConfigControl fix: Add invalid index check to ConfigComplexChoice. Resolve with a default index that can be set.
If more control is needed, it could be changed to allow multiple states to point to the same index.
Diffstat (limited to 'Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp
index 68592a1ce2..5db63dfc0e 100644
--- a/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp
+++ b/Source/Core/DolphinQt/Config/ConfigControls/ConfigChoice.cpp
@@ -153,13 +153,23 @@ void ConfigComplexChoice::UpdateComboIndex()
};
auto it = std::find_if(m_options.begin(), m_options.end(), is_correct_option);
- int index = static_cast<int>(std::distance(m_options.begin(), it));
+ int index;
+
+ if (it == m_options.end())
+ index = m_default_index;
+ else
+ index = static_cast<int>(std::distance(m_options.begin(), it));
// Will crash if not blocked
const QSignalBlocker blocker(this);
setCurrentIndex(index);
}
+void ConfigComplexChoice::SetDefault(int index)
+{
+ m_default_index = index;
+}
+
const std::pair<Config::Location, Config::Location> ConfigComplexChoice::GetLocation() const
{
auto visit = [](auto& v) { return v.GetLocation(); };