Merge pull request #14565 from SuperSamus/cpp-argument-move-reference

Improve usage of std::move and const references parameters
This commit is contained in:
JosJuice
2026-04-18 21:02:30 +02:00
committed by GitHub
140 changed files with 318 additions and 277 deletions
@@ -34,7 +34,7 @@ AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
m_event_hook = AchievementManager::GetInstance().update_event.Register(
[this](AchievementManager::UpdatedItems updated_items) {
QueueOnObject(this, [this, updated_items = std::move(updated_items)] {
AchievementsWindow::UpdateData(std::move(updated_items));
AchievementsWindow::UpdateData(updated_items);
});
});
UpdateData(AchievementManager::UpdatedItems{.all = true});
@@ -80,7 +80,7 @@ void AchievementsWindow::ConnectWidgets()
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
}
void AchievementsWindow::UpdateData(AchievementManager::UpdatedItems updated_items)
void AchievementsWindow::UpdateData(const AchievementManager::UpdatedItems& updated_items)
{
m_settings_widget->UpdateData(updated_items.failed_login_code);
if (updated_items.all)
@@ -22,7 +22,7 @@ class AchievementsWindow : public QDialog
Q_OBJECT
public:
explicit AchievementsWindow(QWidget* parent);
void UpdateData(AchievementManager::UpdatedItems updated_items);
void UpdateData(const AchievementManager::UpdatedItems& updated_items);
void ForceSettingsTab();
private:
@@ -3,6 +3,8 @@
#include "DolphinQt/Config/CheatWarningWidget.h"
#include <utility>
#include <QHBoxLayout>
#include <QLabel>
#include <QPixmap>
@@ -16,9 +18,8 @@
#include "DolphinQt/QtUtils/QtUtils.h"
#include "DolphinQt/Settings.h"
CheatWarningWidget::CheatWarningWidget(const std::string& game_id, bool restart_required,
QWidget* parent)
: QWidget(parent), m_game_id(game_id), m_restart_required(restart_required)
CheatWarningWidget::CheatWarningWidget(std::string game_id, bool restart_required, QWidget* parent)
: QWidget(parent), m_game_id(std::move(game_id)), m_restart_required(restart_required)
{
CreateWidgets();
ConnectWidgets();
@@ -14,7 +14,7 @@ class CheatWarningWidget : public QWidget
{
Q_OBJECT
public:
explicit CheatWarningWidget(const std::string& game_id, bool restart_required, QWidget* parent);
explicit CheatWarningWidget(std::string game_id, bool restart_required, QWidget* parent);
signals:
void OpenCheatEnableSettings();
@@ -91,7 +91,7 @@ void ConfigStringChoice::OnConfigChanged()
Load();
}
ConfigComplexChoice::ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
ConfigComplexChoice::ConfigComplexChoice(const InfoVariant& setting1, const InfoVariant& setting2,
Config::Layer* layer)
: m_layer(layer), m_setting1(setting1), m_setting2(setting2)
{
@@ -109,7 +109,7 @@ class ConfigComplexChoice final : public ToolTipComboBox
using OptionVariant = std::variant<Config::DefaultState, u32, int, bool>;
public:
ConfigComplexChoice(const InfoVariant setting1, const InfoVariant setting2,
ConfigComplexChoice(const InfoVariant& setting1, const InfoVariant& setting2,
Config::Layer* layer = nullptr);
void Add(const QString& name, const OptionVariant option1, const OptionVariant option2);
@@ -101,7 +101,8 @@ void VerifyWidget::CreateWidgets()
m_verify_button = new QPushButton(tr("Verify Integrity"), this);
}
std::pair<QCheckBox*, QLineEdit*> VerifyWidget::AddHashLine(QFormLayout* layout, QString text)
std::pair<QCheckBox*, QLineEdit*> VerifyWidget::AddHashLine(QFormLayout* layout,
const QString& text)
{
QLineEdit* line_edit = new QLineEdit(this);
line_edit->setReadOnly(true);
@@ -225,7 +226,7 @@ void VerifyWidget::Verify()
m_redump_line_edit->setText(QString::fromStdString(result->redump.message));
}
void VerifyWidget::SetProblemCellText(int row, int column, QString text)
void VerifyWidget::SetProblemCellText(int row, int column, const QString& text)
{
QLabel* label = new QLabel(text);
label->setTextInteractionFlags(Qt::TextSelectableByMouse);
+2 -2
View File
@@ -32,13 +32,13 @@ public:
private:
void OnEmulationStateChanged(Core::State state);
void CreateWidgets();
std::pair<QCheckBox*, QLineEdit*> AddHashLine(QFormLayout* layout, QString text);
std::pair<QCheckBox*, QLineEdit*> AddHashLine(QFormLayout* layout, const QString& text);
void ConnectWidgets();
bool CanVerifyRedump() const;
void UpdateRedumpEnabled();
void Verify();
void SetProblemCellText(int row, int column, QString text);
void SetProblemCellText(int row, int column, const QString& text);
std::shared_ptr<DiscIO::Volume> m_volume;
QTableWidget* m_problems;
@@ -9,6 +9,7 @@
#include <QToolTip>
#include <filesystem>
#include <utility>
#include "Common/StringUtil.h"
#include "DolphinQt/Debugger/GekkoSyntaxHighlight.h"
@@ -23,8 +24,8 @@ void AsmEditor::LineNumberArea::paintEvent(QPaintEvent* event)
asm_editor->LineNumberAreaPaintEvent(event);
}
AsmEditor::AsmEditor(const QString& path, int editor_num, bool dark_scheme, QWidget* parent)
: QPlainTextEdit(parent), m_path(path), m_base_address(QStringLiteral("0")),
AsmEditor::AsmEditor(QString path, int editor_num, bool dark_scheme, QWidget* parent)
: QPlainTextEdit(parent), m_path(std::move(path)), m_base_address(QStringLiteral("0")),
m_editor_num(editor_num), m_dirty(false), m_dark_scheme(dark_scheme)
{
if (!m_path.isEmpty())
@@ -18,7 +18,7 @@ class AsmEditor : public QPlainTextEdit
Q_OBJECT;
public:
AsmEditor(const QString& file_path, int editor_num, bool dark_scheme, QWidget* parent = nullptr);
AsmEditor(QString file_path, int editor_num, bool dark_scheme, QWidget* parent = nullptr);
void LineNumberAreaPaintEvent(QPaintEvent* event);
int LineNumberAreaWidth();
const QString& Path() const { return m_path; }
@@ -5,6 +5,8 @@
#include "Common/Assembler/GekkoParser.h"
#include <utility>
#include <QLabel>
#include <QPalette>
@@ -189,7 +191,7 @@ void GekkoSyntaxHighlight::highlightBlock(const QString& text)
GekkoSyntaxHighlight::GekkoSyntaxHighlight(QTextDocument* document, QTextCharFormat base_format,
bool dark_scheme)
: QSyntaxHighlighter(document), m_base_format(base_format)
: QSyntaxHighlighter(document), m_base_format(std::move(base_format))
{
QPalette base_scheme;
m_theme_idx = dark_scheme ? 1 : 0;
@@ -517,8 +517,9 @@ void RegisterWidget::PopulateTable()
m_table->resizeColumnsToContents();
}
void RegisterWidget::AddRegister(int row, int column, RegisterType type, std::string register_name,
std::function<u64()> get_reg, std::function<void(u64)> set_reg)
void RegisterWidget::AddRegister(int row, int column, RegisterType type,
const std::string& register_name, std::function<u64()> get_reg,
std::function<void(u64)> set_reg)
{
auto* value = new RegisterColumn(type, std::move(get_reg), std::move(set_reg));
@@ -48,7 +48,7 @@ private:
void OnItemChanged(QTableWidgetItem* item);
void OnDebugFontChanged(const QFont& font);
void AddRegister(int row, int column, RegisterType type, std::string register_name,
void AddRegister(int row, int column, RegisterType type, const std::string& register_name,
std::function<u64()> get_reg, std::function<void(u64)> set_reg);
void AutoStep(const std::string& reg) const;
@@ -518,7 +518,7 @@ void WatchWidget::ShowInMemory(int row)
emit ShowMemory(m_system.GetPowerPC().GetDebugInterface().GetWatch(row).address);
}
void WatchWidget::AddWatch(QString name, u32 addr)
void WatchWidget::AddWatch(const QString& name, u32 addr)
{
m_system.GetPowerPC().GetDebugInterface().SetWatch(addr, name.toStdString());
Update();
+1 -1
View File
@@ -27,7 +27,7 @@ public:
explicit WatchWidget(QWidget* parent = nullptr);
~WatchWidget() override;
void AddWatch(QString name, u32 addr);
void AddWatch(const QString& name, u32 addr);
signals:
void RequestMemoryBreakpoint(u32 addr);
void ShowMemory(u32 addr);
+1 -1
View File
@@ -327,7 +327,7 @@ void GCMemcardManager::UpdateActions()
m_fix_checksums_button->setEnabled(have_memcard);
}
void GCMemcardManager::SetSlotFile(Slot slot, QString path)
void GCMemcardManager::SetSlotFile(Slot slot, const QString& path)
{
auto [error_code, memcard] = Memcard::GCMemcard::Open(path.toStdString());
+1 -1
View File
@@ -55,7 +55,7 @@ private:
void UpdateActions();
void UpdateSlotTable(ExpansionInterface::Slot slot);
void SetSlotFile(ExpansionInterface::Slot slot, QString path);
void SetSlotFile(ExpansionInterface::Slot slot, const QString& path);
void SetSlotFileInteractive(ExpansionInterface::Slot slot);
void SetActiveSlot(ExpansionInterface::Slot slot);
+1 -1
View File
@@ -56,7 +56,7 @@ signals:
void GameCountUpdated(int total_games, int visible_games) const;
void OnStartWithRiivolution(const UICommon::GameFile& game);
void NetPlayHost(const UICommon::GameFile& game);
void SelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file);
void SelectionChanged(const std::shared_ptr<const UICommon::GameFile>& game_file);
void OpenGeneralSettings();
void OpenGraphicsSettings();
#ifdef USE_RETRO_ACHIEVEMENTS
@@ -54,7 +54,7 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
connect(&Settings::Instance(), &Settings::MetadataRefreshRequested, this,
[this] { m_load_thread.EmplaceItem(Command{CommandType::UpdateMetadata, {}}); });
m_load_thread.Reset("GameList Tracker", [this](Command command) {
m_load_thread.Reset("GameList Tracker", [this](const Command& command) {
switch (command.type)
{
case CommandType::LoadCache:
@@ -356,7 +356,7 @@ void GameTracker::LoadGame(const QString& path)
bool cache_changed = false;
auto game = m_cache.AddOrGet(converted_path, &cache_changed);
if (game)
emit GameLoaded(std::move(game));
emit GameLoaded(game);
if (cache_changed && !m_refresh_in_progress)
m_cache.Save();
}
+1 -1
View File
@@ -76,7 +76,7 @@ void Host::SetMainWindowHandle(void* handle)
m_main_window_handle = handle;
}
static void RunWithGPUThreadInactive(std::function<void()> f)
static void RunWithGPUThreadInactive(const std::function<void()>& f)
{
// Potentially any thread which shows panic alerts can be blocked on this returning.
// This means that, in order to avoid deadlocks, we need to be careful with how we
@@ -106,7 +106,8 @@ void InfinityBaseWindow::CreateMainWindow()
setLayout(main_layout);
}
void InfinityBaseWindow::AddFigureSlot(QVBoxLayout* vbox_group, QString name, FigureUIPosition slot)
void InfinityBaseWindow::AddFigureSlot(QVBoxLayout* vbox_group, const QString& name,
FigureUIPosition slot)
{
auto* hbox_infinity = new QHBoxLayout();
@@ -37,7 +37,8 @@ protected:
private:
void CreateMainWindow();
void AddFigureSlot(QVBoxLayout* vbox_group, QString name, IOS::HLE::USB::FigureUIPosition slot);
void AddFigureSlot(QVBoxLayout* vbox_group, const QString& name,
IOS::HLE::USB::FigureUIPosition slot);
void OnEmulationStateChanged(Core::State state);
void EmulateBase(bool emulate);
void ClearFigure(IOS::HLE::USB::FigureUIPosition slot);
+3 -2
View File
@@ -22,6 +22,7 @@
#include <future>
#include <optional>
#include <utility>
#include <variant>
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
@@ -201,7 +202,7 @@ static WindowSystemInfo GetWindowSystemInfo(QWindow* window)
return wsi;
}
static std::vector<std::string> StringListToStdVector(QStringList list)
static std::vector<std::string> StringListToStdVector(const QStringList& list)
{
std::vector<std::string> result;
result.reserve(list.size());
@@ -474,7 +475,7 @@ void MainWindow::CreateComponents()
m_code_widget = new CodeWidget(this);
m_assembler_widget = new AssemblerWidget(this);
const auto request_watch = [this](QString name, u32 addr) {
const auto request_watch = [this](const QString& name, u32 addr) {
m_watch_widget->AddWatch(name, addr);
};
const auto request_breakpoint = [this](u32 addr) { m_breakpoint_widget->AddBP(addr); };
+1 -1
View File
@@ -1419,7 +1419,7 @@ void MenuBar::NANDExtractCertificates()
}
}
void MenuBar::OnSelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file)
void MenuBar::OnSelectionChanged(const std::shared_ptr<const UICommon::GameFile>& game_file)
{
m_game_selected = !!game_file;
+2 -2
View File
@@ -131,7 +131,7 @@ signals:
void ExportRecording();
void ShowTASInput();
void SelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file);
void SelectionChanged(const std::shared_ptr<const UICommon::GameFile>& game_file);
void RecordingStatusChanged(bool recording);
void ReadOnlyModeChanged(bool read_only);
@@ -195,7 +195,7 @@ private:
void LogInstructions();
void SearchInstruction();
void OnSelectionChanged(std::shared_ptr<const UICommon::GameFile> game_file);
void OnSelectionChanged(const std::shared_ptr<const UICommon::GameFile>& game_file);
void OnRecordingStatusChanged(bool recording);
void OnReadOnlyModeChanged(bool read_only);
void OnDebugModeToggled(bool enabled);
@@ -23,6 +23,7 @@
#include <QTextBrowser>
#include <algorithm>
#include <utility>
#ifdef HAS_LIBMGBA
#include <fmt/ranges.h>
@@ -500,7 +501,7 @@ void NetPlayDialog::reject()
void NetPlayDialog::show(std::string nickname, bool use_traversal)
{
m_nickname = nickname;
m_nickname = std::move(nickname);
m_use_traversal = use_traversal;
m_buffer_size = 0;
m_old_player_count = 0;
@@ -19,7 +19,7 @@ ModalMessageBox::ModalMessageBox(QWidget* parent, Qt::WindowModality modality)
static inline int ExecMessageBox(ModalMessageBox::Icon icon, QWidget* parent, const QString& title,
const QString& text, ModalMessageBox::StandardButtons buttons,
ModalMessageBox::StandardButton default_button,
Qt::WindowModality modality, QString detailed_text)
Qt::WindowModality modality, const QString& detailed_text)
{
ModalMessageBox msg(parent, modality);
msg.setIcon(icon);
+2 -2
View File
@@ -552,7 +552,7 @@ QString Settings::GetDefaultGame() const
return QString::fromStdString(Config::Get(Config::MAIN_DEFAULT_ISO));
}
void Settings::SetDefaultGame(QString path)
void Settings::SetDefaultGame(const QString& path)
{
if (GetDefaultGame() != path)
{
@@ -851,7 +851,7 @@ void Settings::RefreshWidgetVisibility()
emit GameCountVisibilityChanged(IsGameCountVisible());
}
void Settings::SetDebugFont(QFont font)
void Settings::SetDebugFont(const QFont& font)
{
if (GetDebugFont() != font)
{
+2 -2
View File
@@ -102,7 +102,7 @@ public:
bool GetPreferredView() const;
void SetPreferredView(bool list);
QString GetDefaultGame() const;
void SetDefaultGame(QString path);
void SetDefaultGame(const QString& path);
void RefreshGameList();
void NotifyRefreshGameListStarted();
void NotifyRefreshGameListComplete();
@@ -175,7 +175,7 @@ public:
void SetAssemblerVisible(bool enabled);
bool IsAssemblerVisible() const;
QFont GetDebugFont() const;
void SetDebugFont(QFont font);
void SetDebugFont(const QFont& font);
// Auto-Update
QString GetAutoUpdateTrack() const;
@@ -336,11 +336,12 @@ void AdvancedPane::ConnectLayout()
Update();
});
connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged, [this](QDateTime date_time) {
Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE,
static_cast<u32>(date_time.toSecsSinceEpoch()));
Update();
});
connect(m_custom_rtc_datetime, &QDateTimeEdit::dateTimeChanged,
[this](const QDateTime& date_time) {
Config::SetBaseOrCurrent(Config::MAIN_CUSTOM_RTC_VALUE,
static_cast<u32>(date_time.toSecsSinceEpoch()));
Update();
});
}
void AdvancedPane::Update()
+3 -3
View File
@@ -166,8 +166,8 @@ QGridLayout* TASInputWindow::CreateSliderValuePairLayout(
TASSpinBox* TASInputWindow::CreateSliderValuePair(
std::string_view group_name, std::string_view control_name, InputOverrider* overrider,
QGridLayout* layout, int zero, int default_, int min, int max,
QKeySequence shortcut_key_sequence, Qt::Orientation orientation, QWidget* shortcut_widget,
std::optional<ControlState> scale)
const QKeySequence& shortcut_key_sequence, Qt::Orientation orientation,
QWidget* shortcut_widget, std::optional<ControlState> scale)
{
TASSpinBox* value = CreateSliderValuePair(layout, default_, max, shortcut_key_sequence,
orientation, shortcut_widget);
@@ -194,7 +194,7 @@ TASSpinBox* TASInputWindow::CreateSliderValuePair(
// The shortcut_widget argument needs to specify the container widget that will be hidden/shown.
// This is done to avoid ambiguous shortcuts
TASSpinBox* TASInputWindow::CreateSliderValuePair(QGridLayout* layout, int default_, int max,
QKeySequence shortcut_key_sequence,
const QKeySequence& shortcut_key_sequence,
Qt::Orientation orientation,
QWidget* shortcut_widget)
{
+4 -4
View File
@@ -64,12 +64,12 @@ protected:
TASSpinBox* CreateSliderValuePair(std::string_view group_name, std::string_view control_name,
InputOverrider* overrider, QGridLayout* layout, int zero,
int default_, int min, int max,
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
QWidget* shortcut_widget,
const QKeySequence& shortcut_key_sequence,
Qt::Orientation orientation, QWidget* shortcut_widget,
std::optional<ControlState> scale = {});
TASSpinBox* CreateSliderValuePair(QGridLayout* layout, int default_, int max,
QKeySequence shortcut_key_sequence, Qt::Orientation orientation,
QWidget* shortcut_widget);
const QKeySequence& shortcut_key_sequence,
Qt::Orientation orientation, QWidget* shortcut_widget);
void SetupScrollArea(QLayout* layout);