From ee32b177823b9b8499c9fd188a571884f00cf655 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 18 Jun 2023 03:52:41 -0400 Subject: [PATCH] common,yuzu-qt: GCC warning silences Fixes -Wshadow, -Wdeprecated, and catch by copy rather than by ref. --- src/common/settings_common.h | 2 +- src/common/settings_setting.h | 14 +++++----- src/yuzu/configuration/configure_audio.cpp | 4 +-- src/yuzu/configuration/configure_cpu.cpp | 4 +-- src/yuzu/configuration/configure_general.cpp | 4 +-- src/yuzu/configuration/configure_graphics.cpp | 6 ++--- .../configure_graphics_advanced.cpp | 4 +-- src/yuzu/configuration/configure_system.cpp | 6 ++--- src/yuzu/configuration/shared_widget.cpp | 27 ++++++++++--------- 9 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/common/settings_common.h b/src/common/settings_common.h index 4d6d3021e..2b5c72f41 100644 --- a/src/common/settings_common.h +++ b/src/common/settings_common.h @@ -178,7 +178,7 @@ public: * * @returns The setting's category */ - [[nodiscard]] Category Category() const; + [[nodiscard]] enum Category Category() const; /** * Returns the label this setting was created with. diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h index 658b6328d..f803e4e6e 100644 --- a/src/common/settings_setting.h +++ b/src/common/settings_setting.h @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -169,7 +170,7 @@ public: } else { this->SetValue(static_cast(std::stoll(input))); } - } catch (std::invalid_argument) { + } catch (std::invalid_argument& e) { this->SetValue(this->GetDefault()); } } @@ -229,9 +230,10 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, - Category category, bool save = true, bool runtime_modifiable = false) + Category category_, bool save_ = true, + bool runtime_modifiable_ = false) requires(!ranged) - : Setting{linkage, default_val, name, category, save, runtime_modifiable} { + : Setting{linkage, default_val, name, category_, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } virtual ~SwitchableSetting() = default; @@ -247,11 +249,11 @@ public: * @param category_ Category of the setting AKA INI group */ explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, - const Type& max_val, const std::string& name, Category category, - bool save = true, bool runtime_modifiable = false) + const Type& max_val, const std::string& name, Category category_, + bool save_ = true, bool runtime_modifiable_ = false) requires(ranged) : Setting{linkage, default_val, min_val, max_val, - name, category, save, runtime_modifiable} { + name, category_, save_, runtime_modifiable_} { linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); } diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index c90316725..8c5378925 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -18,10 +18,10 @@ ConfigureAudio::ConfigureAudio( const Core::System& system_, - std::shared_ptr> group, + std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui(std::make_unique()), system{system_}, + : Tab(group_, parent), ui(std::make_unique()), system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); Setup(); diff --git a/src/yuzu/configuration/configure_cpu.cpp b/src/yuzu/configuration/configure_cpu.cpp index f4bec1155..210af146d 100644 --- a/src/yuzu/configuration/configure_cpu.cpp +++ b/src/yuzu/configuration/configure_cpu.cpp @@ -15,10 +15,10 @@ ConfigureCpu::ConfigureCpu( const Core::System& system_, - std::shared_ptr> group, + std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_}, + : Tab(group_, parent), ui{std::make_unique()}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index 625dd75dd..ca5b92bc0 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp @@ -14,10 +14,10 @@ ConfigureGeneral::ConfigureGeneral( const Core::System& system_, - std::shared_ptr> group, + std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_}, + : Tab(group_, parent), ui{std::make_unique()}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 62d74d12b..5537118ef 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -80,10 +80,10 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) ConfigureGraphics::ConfigureGraphics( const Core::System& system_, std::vector& records_, const std::function& expose_compute_option_, - std::shared_ptr> group, + std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : ConfigurationShared::Tab(group, parent), ui{std::make_unique()}, + : ConfigurationShared::Tab(group_, parent), ui{std::make_unique()}, records{records_}, expose_compute_option{expose_compute_option_}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_}, shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} { @@ -275,7 +275,7 @@ void ConfigureGraphics::Setup() { if (!Settings::IsConfiguringGlobal()) { QObject::connect(api_restore_global_button, &QAbstractButton::clicked, - [=](bool) { UpdateAPILayout(); }); + [this](bool) { UpdateAPILayout(); }); // Detach API's restore button and place it where we want // Lets us put it on the side, and it will automatically scale if there's a diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 20ca3fa96..e2f7d284d 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -13,10 +13,10 @@ ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( const Core::System& system_, - std::shared_ptr> group, + std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_}, + : Tab(group_, parent), ui{std::make_unique()}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index f78ed7c24..51b0629a6 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp @@ -45,10 +45,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) { } ConfigureSystem::ConfigureSystem( - Core::System& system_, std::shared_ptr> group, + Core::System& system_, std::shared_ptr> group_, const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) - : Tab(group, parent), ui{std::make_unique()}, system{system_}, + : Tab(group_, parent), ui{std::make_unique()}, system{system_}, translations{translations_}, combobox_translations{combobox_translations_} { ui->setupUi(this); @@ -128,7 +128,7 @@ void ConfigureSystem::Setup() { } [[maybe_unused]] std::string label = setting->GetLabel(); - ConfigurationShared::Widget* widget = [=]() { + ConfigurationShared::Widget* widget = [this, setting, runtime_lock]() { if (setting->Id() == Settings::values.custom_rtc.Id()) { // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage // it and custom_rtc_enabled diff --git a/src/yuzu/configuration/shared_widget.cpp b/src/yuzu/configuration/shared_widget.cpp index a855559b6..882cd9eda 100644 --- a/src/yuzu/configuration/shared_widget.cpp +++ b/src/yuzu/configuration/shared_widget.cpp @@ -276,7 +276,7 @@ QWidget* Widget::CreateHexEdit(std::function& serializer, line_edit->setMaxLength(8); line_edit->setValidator(regex); - auto hex_to_dec = [=]() -> std::string { + auto hex_to_dec = [this]() -> std::string { return std::to_string(std::stoul(line_edit->text().toStdString(), nullptr, 16)); }; @@ -307,8 +307,8 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict, serializer = [this]() { return std::to_string(date_time_edit->dateTime().toSecsSinceEpoch()); }; if (!Settings::IsConfiguringGlobal()) { - auto get_clear_val = [=]() { - return QDateTime::fromSecsSinceEpoch([=]() { + auto get_clear_val = [this, restrict, current_time]() { + return QDateTime::fromSecsSinceEpoch([this, restrict, current_time]() { if (restrict && checkbox->checkState() == Qt::Checked) { return std::stoll(setting.ToStringGlobal()); } @@ -316,13 +316,14 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict, }()); }; - restore_func = [=]() { date_time_edit->setDateTime(get_clear_val()); }; + restore_func = [this, get_clear_val]() { date_time_edit->setDateTime(get_clear_val()); }; - QObject::connect(date_time_edit, &QDateTimeEdit::editingFinished, [=]() { - if (date_time_edit->dateTime() != get_clear_val()) { - touch(); - } - }); + QObject::connect(date_time_edit, &QDateTimeEdit::editingFinished, + [this, get_clear_val, touch]() { + if (date_time_edit->dateTime() != get_clear_val()) { + touch(); + } + }); } return date_time_edit; @@ -528,11 +529,11 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati this->setToolTip(tooltip); } -Widget::Widget(Settings::BasicSetting* setting, const TranslationMap& translations, - const ComboboxTranslationMap& combobox_translations, QWidget* parent, - bool runtime_lock, std::forward_list>& apply_funcs_, +Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_, + const ComboboxTranslationMap& combobox_translations, QWidget* parent_, + bool runtime_lock_, std::forward_list>& apply_funcs_, Settings::BasicSetting* other_setting, RequestType request, const QString& string) - : Widget(setting, translations, combobox_translations, parent, runtime_lock, apply_funcs_, + : Widget(setting_, translations_, combobox_translations, parent_, runtime_lock_, apply_funcs_, request, true, 1.0f, other_setting, string) {} } // namespace ConfigurationShared