From cb82ffbe209863ec9ce425a5f35dedc1bdf7aaa7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 17 Dec 2022 16:04:10 +0100 Subject: [PATCH] code: Small cleanups and fixes to lambda captures (#6191) Co-authored-by: v1993 Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> --- src/citra_qt/game_list_p.h | 6 ++++++ src/citra_qt/multiplayer/lobby.cpp | 4 ++-- src/citra_qt/updater/updater.cpp | 2 +- src/citra_qt/util/spinbox.cpp | 10 ++++++---- src/core/hle/service/soc_u.cpp | 1 + src/input_common/udp/client.cpp | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 19d04053d1..709aeff008 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -320,6 +320,12 @@ public: setData(type(), TypeRole); setData(size_bytes, SizeRole); } + explicit GameListItemSize(const QString& string) { + // This is required to avoid incorrect virtual function call in + // GameListItem's constructor + setText(string); + setData(string, SortRole); + } void setData(const QVariant& value, int role) override { // By specializing setData for SizeRole, we can ensure that the numerical and string diff --git a/src/citra_qt/multiplayer/lobby.cpp b/src/citra_qt/multiplayer/lobby.cpp index e335d5f851..d74bbf3abc 100644 --- a/src/citra_qt/multiplayer/lobby.cpp +++ b/src/citra_qt/multiplayer/lobby.cpp @@ -30,12 +30,12 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, ui->setupUi(this); // setup the watcher for background connections - watcher = new QFutureWatcher; + watcher = new QFutureWatcher(this); model = new QStandardItemModel(ui->room_list); // Create a proxy to the game list to get the list of games owned - game_list = new QStandardItemModel; + game_list = new QStandardItemModel(this); UpdateGameList(list); proxy = new LobbyFilterProxyModel(this, game_list); diff --git a/src/citra_qt/updater/updater.cpp b/src/citra_qt/updater/updater.cpp index 33d5c9da03..498ba986ca 100644 --- a/src/citra_qt/updater/updater.cpp +++ b/src/citra_qt/updater/updater.cpp @@ -156,7 +156,7 @@ void UpdaterPrivate::StopUpdateCheck(int delay, bool async) { QTimer* timer = new QTimer(this); timer->setSingleShot(true); - connect(timer, &QTimer::timeout, [=]() { + connect(timer, &QTimer::timeout, [this, timer]() { StopUpdateCheck(0, false); timer->deleteLater(); }); diff --git a/src/citra_qt/util/spinbox.cpp b/src/citra_qt/util/spinbox.cpp index 562138909e..b635c3a15a 100644 --- a/src/citra_qt/util/spinbox.cpp +++ b/src/citra_qt/util/spinbox.cpp @@ -76,10 +76,12 @@ void CSpinBox::stepBy(int steps) { }*/ // Increment "new_value" by "steps", and perform annoying overflow checks, too. - if (steps < 0 && new_value + steps > new_value) { - new_value = std::numeric_limits::min(); - } else if (steps > 0 && new_value + steps < new_value) { - new_value = std::numeric_limits::max(); + constexpr qint64 qint64_min = std::numeric_limits::min(); + constexpr qint64 qint64_max = std::numeric_limits::max(); + if (steps < 0 && new_value < qint64_min - steps) { + new_value = qint64_min; + } else if (steps > 0 && new_value > qint64_max - steps) { + new_value = qint64_max; } else { new_value += steps; } diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 5558299db3..42486f5712 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -1054,6 +1054,7 @@ void SOC_U::GetAddrInfoImpl(Kernel::HLERequestContext& ctx) { // if the buffer is not big enough. However the count returned is always correct. CTRAddrInfo ctr_addr = CTRAddrInfo::FromPlatform(*cur); std::memcpy(out_buff.data() + pos, &ctr_addr, sizeof(ctr_addr)); + pos += sizeof(ctr_addr); } cur = cur->ai_next; count++; diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index 9cc1977085..4d708afe06 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -233,7 +233,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( std::function status_callback, std::function data_callback) { - std::thread([=] { + std::thread([=, this] { constexpr u16 CALIBRATION_THRESHOLD = 100; u16 min_x{UINT16_MAX};