common,yuzu-qt: GCC warning silences

Fixes -Wshadow, -Wdeprecated, and catch by copy rather than by ref.
This commit is contained in:
lat9nq 2023-06-18 03:52:41 -04:00
parent 916c6cd1a0
commit ee32b17782
9 changed files with 37 additions and 34 deletions

View file

@ -178,7 +178,7 @@ public:
* *
* @returns The setting's category * @returns The setting's category
*/ */
[[nodiscard]] Category Category() const; [[nodiscard]] enum Category Category() const;
/** /**
* Returns the label this setting was created with. * Returns the label this setting was created with.

View file

@ -5,6 +5,7 @@
#include <map> #include <map>
#include <optional> #include <optional>
#include <stdexcept>
#include <string> #include <string>
#include <typeindex> #include <typeindex>
#include <typeinfo> #include <typeinfo>
@ -169,7 +170,7 @@ public:
} else { } else {
this->SetValue(static_cast<Type>(std::stoll(input))); this->SetValue(static_cast<Type>(std::stoll(input)));
} }
} catch (std::invalid_argument) { } catch (std::invalid_argument& e) {
this->SetValue(this->GetDefault()); this->SetValue(this->GetDefault());
} }
} }
@ -229,9 +230,10 @@ public:
* @param category_ Category of the setting AKA INI group * @param category_ Category of the setting AKA INI group
*/ */
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const std::string& name, 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) requires(!ranged)
: Setting<Type, false>{linkage, default_val, name, category, save, runtime_modifiable} { : Setting<Type, false>{linkage, default_val, name, category_, save_, runtime_modifiable_} {
linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); }); linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
} }
virtual ~SwitchableSetting() = default; virtual ~SwitchableSetting() = default;
@ -247,11 +249,11 @@ public:
* @param category_ Category of the setting AKA INI group * @param category_ Category of the setting AKA INI group
*/ */
explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val, explicit SwitchableSetting(Linkage& linkage, const Type& default_val, const Type& min_val,
const Type& max_val, const std::string& name, Category category, const Type& max_val, const std::string& name, Category category_,
bool save = true, bool runtime_modifiable = false) bool save_ = true, bool runtime_modifiable_ = false)
requires(ranged) requires(ranged)
: Setting<Type, true>{linkage, default_val, min_val, max_val, : Setting<Type, true>{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); }); linkage.restore_functions.emplace_back([this]() { this->SetGlobal(true); });
} }

View file

@ -18,10 +18,10 @@
ConfigureAudio::ConfigureAudio( ConfigureAudio::ConfigureAudio(
const Core::System& system_, const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: Tab(group, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_}, : Tab(group_, parent), ui(std::make_unique<Ui::ConfigureAudio>()), system{system_},
translations{translations_}, combobox_translations{combobox_translations_} { translations{translations_}, combobox_translations{combobox_translations_} {
ui->setupUi(this); ui->setupUi(this);
Setup(); Setup();

View file

@ -15,10 +15,10 @@
ConfigureCpu::ConfigureCpu( ConfigureCpu::ConfigureCpu(
const Core::System& system_, const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_}, : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureCpu>()}, system{system_},
translations{translations_}, combobox_translations{combobox_translations_} { translations{translations_}, combobox_translations{combobox_translations_} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -14,10 +14,10 @@
ConfigureGeneral::ConfigureGeneral( ConfigureGeneral::ConfigureGeneral(
const Core::System& system_, const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_}, : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGeneral>()}, system{system_},
translations{translations_}, combobox_translations{combobox_translations_} { translations{translations_}, combobox_translations{combobox_translations_} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -80,10 +80,10 @@ static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode)
ConfigureGraphics::ConfigureGraphics( ConfigureGraphics::ConfigureGraphics(
const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_, const Core::System& system_, std::vector<VkDeviceInfo::Record>& records_,
const std::function<void()>& expose_compute_option_, const std::function<void()>& expose_compute_option_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: ConfigurationShared::Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphics>()}, : ConfigurationShared::Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphics>()},
records{records_}, expose_compute_option{expose_compute_option_}, system{system_}, records{records_}, expose_compute_option{expose_compute_option_}, system{system_},
translations{translations_}, combobox_translations{combobox_translations_}, translations{translations_}, combobox_translations{combobox_translations_},
shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} { shader_mapping{combobox_translations.at(typeid(Settings::ShaderBackend))} {
@ -275,7 +275,7 @@ void ConfigureGraphics::Setup() {
if (!Settings::IsConfiguringGlobal()) { if (!Settings::IsConfiguringGlobal()) {
QObject::connect(api_restore_global_button, &QAbstractButton::clicked, QObject::connect(api_restore_global_button, &QAbstractButton::clicked,
[=](bool) { UpdateAPILayout(); }); [this](bool) { UpdateAPILayout(); });
// Detach API's restore button and place it where we want // 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 // Lets us put it on the side, and it will automatically scale if there's a

View file

@ -13,10 +13,10 @@
ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced( ConfigureGraphicsAdvanced::ConfigureGraphicsAdvanced(
const Core::System& system_, const Core::System& system_,
std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_}, : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureGraphicsAdvanced>()}, system{system_},
translations{translations_}, combobox_translations{combobox_translations_} { translations{translations_}, combobox_translations{combobox_translations_} {
ui->setupUi(this); ui->setupUi(this);

View file

@ -45,10 +45,10 @@ static bool IsValidLocale(u32 region_index, u32 language_index) {
} }
ConfigureSystem::ConfigureSystem( ConfigureSystem::ConfigureSystem(
Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group, Core::System& system_, std::shared_ptr<std::forward_list<ConfigurationShared::Tab*>> group_,
const ConfigurationShared::TranslationMap& translations_, const ConfigurationShared::TranslationMap& translations_,
const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent) const ConfigurationShared::ComboboxTranslationMap& combobox_translations_, QWidget* parent)
: Tab(group, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_}, : Tab(group_, parent), ui{std::make_unique<Ui::ConfigureSystem>()}, system{system_},
translations{translations_}, combobox_translations{combobox_translations_} { translations{translations_}, combobox_translations{combobox_translations_} {
ui->setupUi(this); ui->setupUi(this);
@ -128,7 +128,7 @@ void ConfigureSystem::Setup() {
} }
[[maybe_unused]] std::string label = setting->GetLabel(); [[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()) { if (setting->Id() == Settings::values.custom_rtc.Id()) {
// custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage // custom_rtc needs a DateTimeEdit (default is LineEdit), and a checkbox to manage
// it and custom_rtc_enabled // it and custom_rtc_enabled

View file

@ -276,7 +276,7 @@ QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer,
line_edit->setMaxLength(8); line_edit->setMaxLength(8);
line_edit->setValidator(regex); 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)); 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()); }; serializer = [this]() { return std::to_string(date_time_edit->dateTime().toSecsSinceEpoch()); };
if (!Settings::IsConfiguringGlobal()) { if (!Settings::IsConfiguringGlobal()) {
auto get_clear_val = [=]() { auto get_clear_val = [this, restrict, current_time]() {
return QDateTime::fromSecsSinceEpoch([=]() { return QDateTime::fromSecsSinceEpoch([this, restrict, current_time]() {
if (restrict && checkbox->checkState() == Qt::Checked) { if (restrict && checkbox->checkState() == Qt::Checked) {
return std::stoll(setting.ToStringGlobal()); 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, [=]() { QObject::connect(date_time_edit, &QDateTimeEdit::editingFinished,
if (date_time_edit->dateTime() != get_clear_val()) { [this, get_clear_val, touch]() {
touch(); if (date_time_edit->dateTime() != get_clear_val()) {
} touch();
}); }
});
} }
return date_time_edit; return date_time_edit;
@ -528,11 +529,11 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
this->setToolTip(tooltip); this->setToolTip(tooltip);
} }
Widget::Widget(Settings::BasicSetting* setting, const TranslationMap& translations, Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translations_,
const ComboboxTranslationMap& combobox_translations, QWidget* parent, const ComboboxTranslationMap& combobox_translations, QWidget* parent_,
bool runtime_lock, std::forward_list<std::function<void(bool)>>& apply_funcs_, bool runtime_lock_, std::forward_list<std::function<void(bool)>>& apply_funcs_,
Settings::BasicSetting* other_setting, RequestType request, const QString& string) 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) {} request, true, 1.0f, other_setting, string) {}
} // namespace ConfigurationShared } // namespace ConfigurationShared