From 3d00beb9d58508b03ac8d22c9da4b8bcba89f692 Mon Sep 17 00:00:00 2001
From: Valentin Vanelslande <valentinvanelslandeacnl@gmail.com>
Date: Sat, 29 Dec 2018 09:19:45 -0500
Subject: [PATCH] add a comment, rename old index

---
 .../configuration/configure_input.cpp         | 49 ++++++++++---------
 src/citra_qt/main.cpp                         |  4 +-
 2 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp
index a3cf53a75c..437bc13b71 100644
--- a/src/citra_qt/configuration/configure_input.cpp
+++ b/src/citra_qt/configuration/configure_input.cpp
@@ -97,6 +97,8 @@ ConfigureInput::ConfigureInput(QWidget* parent)
     : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()),
       timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) {
 
+    // If the user closes the dialog, the changes are reverted in `GMainWindow::OnConfigure()`
+
     ui->setupUi(this);
     setFocusPolicy(Qt::ClickFocus);
 
@@ -136,13 +138,14 @@ ConfigureInput::ConfigureInput(QWidget* parent)
             continue;
         button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
         connect(button_map[button_id], &QPushButton::released, [=]() {
-            handleClick(button_map[button_id],
-                        [=](const Common::ParamPackage& params) {
-                            buttons_param[button_id] = params;
-                            applyConfiguration();
-                            Settings::SaveProfile(ui->profile->currentIndex());
-                        },
-                        InputCommon::Polling::DeviceType::Button);
+            handleClick(
+                button_map[button_id],
+                [=](const Common::ParamPackage& params) {
+                    buttons_param[button_id] = params;
+                    applyConfiguration();
+                    Settings::SaveProfile(ui->profile->currentIndex());
+                },
+                InputCommon::Polling::DeviceType::Button);
         });
         connect(button_map[button_id], &QPushButton::customContextMenuRequested,
                 [=](const QPoint& menu_location) {
@@ -171,14 +174,15 @@ ConfigureInput::ConfigureInput(QWidget* parent)
             analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(
                 Qt::CustomContextMenu);
             connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
-                handleClick(analog_map_buttons[analog_id][sub_button_id],
-                            [=](const Common::ParamPackage& params) {
-                                SetAnalogButton(params, analogs_param[analog_id],
-                                                analog_sub_buttons[sub_button_id]);
-                                applyConfiguration();
-                                Settings::SaveProfile(ui->profile->currentIndex());
-                            },
-                            InputCommon::Polling::DeviceType::Button);
+                handleClick(
+                    analog_map_buttons[analog_id][sub_button_id],
+                    [=](const Common::ParamPackage& params) {
+                        SetAnalogButton(params, analogs_param[analog_id],
+                                        analog_sub_buttons[sub_button_id]);
+                        applyConfiguration();
+                        Settings::SaveProfile(ui->profile->currentIndex());
+                    },
+                    InputCommon::Polling::DeviceType::Button);
             });
             connect(analog_map_buttons[analog_id][sub_button_id],
                     &QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
@@ -207,13 +211,14 @@ ConfigureInput::ConfigureInput(QWidget* parent)
             QMessageBox::information(this, tr("Information"),
                                      tr("After pressing OK, first move your joystick horizontally, "
                                         "and then vertically."));
-            handleClick(analog_map_stick[analog_id],
-                        [=](const Common::ParamPackage& params) {
-                            analogs_param[analog_id] = params;
-                            applyConfiguration();
-                            Settings::SaveProfile(ui->profile->currentIndex());
-                        },
-                        InputCommon::Polling::DeviceType::Analog);
+            handleClick(
+                analog_map_stick[analog_id],
+                [=](const Common::ParamPackage& params) {
+                    analogs_param[analog_id] = params;
+                    applyConfiguration();
+                    Settings::SaveProfile(ui->profile->currentIndex());
+                },
+                InputCommon::Polling::DeviceType::Analog);
         });
     }
 
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 245b1b4043..a62e232600 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -1326,7 +1326,7 @@ void GMainWindow::OnConfigure() {
     connect(&configureDialog, &ConfigureDialog::languageChanged, this,
             &GMainWindow::OnLanguageChanged);
     auto old_theme = UISettings::values.theme;
-    const int old_input_profile = Settings::values.current_input_profile_index;
+    const int old_input_profile_index = Settings::values.current_input_profile_index;
     const auto old_input_profiles = Settings::values.input_profiles;
     const bool old_discord_presence = UISettings::values.enable_discord_presence;
     auto result = configureDialog.exec();
@@ -1342,7 +1342,7 @@ void GMainWindow::OnConfigure() {
         config->Save();
     } else {
         Settings::values.input_profiles = old_input_profiles;
-        Settings::LoadProfile(old_input_profile);
+        Settings::LoadProfile(old_input_profile_index);
     }
 }