From 60d1822206632d4f6120296a7ce84ed000e24e43 Mon Sep 17 00:00:00 2001 From: Valentin Vanelslande Date: Sat, 29 Dec 2018 08:39:30 -0500 Subject: [PATCH] if to clamp --- src/citra_qt/configuration/config.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 68e58e63b6..21a0bd1d80 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include #include "citra_qt/configuration/config.h" @@ -102,15 +103,15 @@ void Config::ReadValues() { qt_config->endArray(); - if (Settings::values.current_input_profile_index <= num_input_profiles) { - Settings::values.current_input_profile_index = 0; - } - // create a input profile if no input profiles exist, with the default or old settings if (num_input_profiles == 0) { append_profile(); } + // ensure that the current input profile index is valid. + Settings::values.current_input_profile_index = + std::clamp(Settings::values.current_input_profile_index, 0, num_input_profiles - 1); + Settings::LoadProfile(Settings::values.current_input_profile_index); qt_config->endGroup();