From e1aa69e07afc39fa7afeb9ba2b3c821416ab1020 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Fri, 26 Apr 2024 17:16:43 +0100 Subject: [PATCH 1/2] Drop use of implicit captures (`[=]`) in lambda expressions. In C++20, implicit captures are deprecated: ``` .../Source/GUI/MemCopy/DlgCopy.cpp: In lambda function: .../Source/GUI/MemCopy/DlgCopy.cpp:62:11: warning: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Wdeprecated] 62 | [=](const QString& string) { updateMemoryText(); }); | ^ .../Source/GUI/MemCopy/DlgCopy.cpp:62:11: note: add explicit 'this' or '*this' capture ``` --- Source/GUI/MemCopy/DlgCopy.cpp | 2 +- Source/GUI/MemScanner/MemScanWidget.cpp | 2 +- Source/GUI/MemViewer/MemViewer.cpp | 8 ++--- Source/GUI/MemViewer/MemViewerWidget.cpp | 2 +- Source/GUI/MemWatcher/MemWatchModel.cpp | 10 +++--- Source/GUI/MemWatcher/MemWatchWidget.cpp | 42 +++++++++++++----------- Source/GUI/Settings/DlgSettings.cpp | 2 +- 7 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Source/GUI/MemCopy/DlgCopy.cpp b/Source/GUI/MemCopy/DlgCopy.cpp index 68fdcdca..2b65a4f9 100644 --- a/Source/GUI/MemCopy/DlgCopy.cpp +++ b/Source/GUI/MemCopy/DlgCopy.cpp @@ -59,7 +59,7 @@ DlgCopy::DlgCopy(QWidget* parent) : QDialog(parent) }); connect(m_cmbViewerBytesSeparator, &QComboBox::currentTextChanged, this, - [=](const QString& string) { updateMemoryText(); }); + [this](const QString& string) { updateMemoryText(); }); QVBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addWidget(grbCopySettings); diff --git a/Source/GUI/MemScanner/MemScanWidget.cpp b/Source/GUI/MemScanner/MemScanWidget.cpp index bdc5eb3b..c43dcb0d 100644 --- a/Source/GUI/MemScanner/MemScanWidget.cpp +++ b/Source/GUI/MemScanner/MemScanWidget.cpp @@ -69,7 +69,7 @@ void MemScanWidget::initialiseWidgets() connect(m_btnUndoScan, &QPushButton::clicked, this, &MemScanWidget::onUndoScan); QShortcut* scanShortcut = new QShortcut(QKeySequence(Qt::Key::Key_Enter), this); - connect(scanShortcut, &QShortcut::activated, this, [=] { + connect(scanShortcut, &QShortcut::activated, this, [this] { if (m_memScanner->hasScanStarted()) onNextScan(); else diff --git a/Source/GUI/MemViewer/MemViewer.cpp b/Source/GUI/MemViewer/MemViewer.cpp index 5f1dc9a9..7e845ca8 100644 --- a/Source/GUI/MemViewer/MemViewer.cpp +++ b/Source/GUI/MemViewer/MemViewer.cpp @@ -34,7 +34,7 @@ MemViewer::MemViewer(QWidget* parent) : QAbstractScrollArea(parent) m_copyShortcut = new QShortcut(QKeySequence(Qt::Modifier::CTRL | Qt::Key::Key_C), parent); connect(m_copyShortcut, &QShortcut::activated, this, - [=]() { copySelection(Common::MemType::type_byteArray); }); + [this]() { copySelection(Common::MemType::type_byteArray); }); // The viewport is implicitly updated at the constructor's end } @@ -322,12 +322,12 @@ void MemViewer::contextMenuEvent(QContextMenuEvent* event) { QAction* copyBytesAction = new QAction(tr("&Copy selection as bytes")); connect(copyBytesAction, &QAction::triggered, this, - [=]() { copySelection(Common::MemType::type_byteArray); }); + [this]() { copySelection(Common::MemType::type_byteArray); }); contextMenu->addAction(copyBytesAction); QAction* copyStringAction = new QAction(tr("&Copy selection as ASCII string")); connect(copyStringAction, &QAction::triggered, this, - [=]() { copySelection(Common::MemType::type_string); }); + [this]() { copySelection(Common::MemType::type_string); }); contextMenu->addAction(copyStringAction); QAction* editAction = new QAction(tr("&Edit all selection...")); @@ -342,7 +342,7 @@ void MemViewer::contextMenuEvent(QContextMenuEvent* event) QAction* addSingleWatchAction = new QAction(tr("&Add a watch to this address...")); connect(addSingleWatchAction, &QAction::triggered, this, - [=]() { addByteIndexAsWatch(indexMouse); }); + [this, indexMouse]() { addByteIndexAsWatch(indexMouse); }); contextMenu->addAction(addSingleWatchAction); contextMenu->popup(viewport()->mapToGlobal(event->pos())); diff --git a/Source/GUI/MemViewer/MemViewerWidget.cpp b/Source/GUI/MemViewer/MemViewerWidget.cpp index c4573131..ff3b2e82 100644 --- a/Source/GUI/MemViewer/MemViewerWidget.cpp +++ b/Source/GUI/MemViewer/MemViewerWidget.cpp @@ -14,7 +14,7 @@ MemViewerWidget::MemViewerWidget(QWidget* parent, u32 consoleAddress) : QWidget( makeLayouts(); connect(m_memViewer, &MemViewer::addWatch, this, - [=](MemWatchEntry* entry) { emit addWatchRequested(entry); }); + [this](MemWatchEntry* entry) { emit addWatchRequested(entry); }); } MemViewerWidget::~MemViewerWidget() diff --git a/Source/GUI/MemWatcher/MemWatchModel.cpp b/Source/GUI/MemWatcher/MemWatchModel.cpp index c571075c..a6127452 100644 --- a/Source/GUI/MemWatcher/MemWatchModel.cpp +++ b/Source/GUI/MemWatcher/MemWatchModel.cpp @@ -529,7 +529,7 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN case WATCH_COL_LABEL: { std::sort( - children.begin(), children.end(), [=](MemWatchTreeNode* left, MemWatchTreeNode* right) { + children.begin(), children.end(), [order](MemWatchTreeNode* left, MemWatchTreeNode* right) { if (left->isGroup() && right->isGroup()) { int compareResult = @@ -550,7 +550,7 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN case WATCH_COL_TYPE: { std::sort(children.begin(), children.end(), - [=](MemWatchTreeNode* left, MemWatchTreeNode* right) { + [order](MemWatchTreeNode* left, MemWatchTreeNode* right) { if (left->isGroup()) return true; else if (right->isGroup()) @@ -565,7 +565,7 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN case WATCH_COL_ADDRESS: { std::sort(children.begin(), children.end(), - [=](MemWatchTreeNode* left, MemWatchTreeNode* right) { + [order](MemWatchTreeNode* left, MemWatchTreeNode* right) { if (left->isGroup()) return true; else if (right->isGroup()) @@ -582,7 +582,7 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN case WATCH_COL_LOCK: { std::sort(children.begin(), children.end(), - [=](MemWatchTreeNode* left, MemWatchTreeNode* right) { + [order](MemWatchTreeNode* left, MemWatchTreeNode* right) { if (left->isGroup()) return true; else if (right->isGroup()) @@ -597,7 +597,7 @@ void MemWatchModel::sortRecursive(int column, Qt::SortOrder order, MemWatchTreeN case WATCH_COL_VALUE: { std::sort( - children.begin(), children.end(), [=](MemWatchTreeNode* left, MemWatchTreeNode* right) { + children.begin(), children.end(), [order](MemWatchTreeNode* left, MemWatchTreeNode* right) { if (left->isGroup() && right->isGroup()) return false; else if (left->isGroup()) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 873d00c4..0d0761d8 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -85,7 +85,7 @@ void MemWatchWidget::initialiseWidgets() QShortcut* pasteWatchShortcut = new QShortcut(QKeySequence(Qt::Modifier::CTRL | Qt::Key::Key_V), m_watchView); - connect(pasteWatchShortcut, &QShortcut::activated, this, [=] { + connect(pasteWatchShortcut, &QShortcut::activated, this, [this] { pasteWatchFromClipBoard( m_watchModel->getTreeNodeFromIndex(m_watchView->selectionModel()->currentIndex()), m_watchView->selectionModel()->currentIndex().row() + 1); @@ -141,7 +141,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) QMenu* memViewerSubMenu = contextMenu->addMenu(tr("Browse &memory at")); QAction* showPointerInViewer = new QAction(tr("The &pointer address..."), this); connect(showPointerInViewer, &QAction::triggered, this, - [=] { emit goToAddressInViewer(entry->getConsoleAddress()); }); + [this, entry] { emit goToAddressInViewer(entry->getConsoleAddress()); }); memViewerSubMenu->addAction(showPointerInViewer); for (int i = 0; i < entry->getPointerLevel(); ++i) { @@ -150,20 +150,21 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) break; QAction* showAddressOfPathInViewer = new QAction( tr("The pointed address at &level %1...").arg(QString::number(i + 1)), this); - connect(showAddressOfPathInViewer, &QAction::triggered, this, - [=] { emit goToAddressInViewer(entry->getAddressForPointerLevel(i + 1)); }); + connect(showAddressOfPathInViewer, &QAction::triggered, this, [this, entry, i] { + emit goToAddressInViewer(entry->getAddressForPointerLevel(i + 1)); + }); memViewerSubMenu->addAction(showAddressOfPathInViewer); } QAction* showInViewer = new QAction(tr("Browse memory at this &address..."), this); connect(showInViewer, &QAction::triggered, this, - [=] { emit goToAddressInViewer(entry->getConsoleAddress()); }); + [this, entry] { emit goToAddressInViewer(entry->getConsoleAddress()); }); } else { QAction* showInViewer = new QAction(tr("Browse memory at this &address..."), this); connect(showInViewer, &QAction::triggered, this, - [=] { emit goToAddressInViewer(entry->getConsoleAddress()); }); + [this, entry] { emit goToAddressInViewer(entry->getConsoleAddress()); }); contextMenu->addAction(showInViewer); } @@ -177,13 +178,14 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) QAction* viewBin = new QAction(tr("View as &Binary"), this); connect(viewDec, &QAction::triggered, m_watchModel, - [=] { setSelectedWatchesBase(entry, Common::MemBase::base_decimal); }); - connect(viewHex, &QAction::triggered, m_watchModel, - [=] { setSelectedWatchesBase(entry, Common::MemBase::base_hexadecimal); }); + [this, entry] { setSelectedWatchesBase(entry, Common::MemBase::base_decimal); }); + connect(viewHex, &QAction::triggered, m_watchModel, [this, entry] { + setSelectedWatchesBase(entry, Common::MemBase::base_hexadecimal); + }); connect(viewOct, &QAction::triggered, m_watchModel, - [=] { setSelectedWatchesBase(entry, Common::MemBase::base_octal); }); + [this, entry] { setSelectedWatchesBase(entry, Common::MemBase::base_octal); }); connect(viewBin, &QAction::triggered, m_watchModel, - [=] { setSelectedWatchesBase(entry, Common::MemBase::base_binary); }); + [this, entry] { setSelectedWatchesBase(entry, Common::MemBase::base_binary); }); contextMenu->addAction(viewDec); contextMenu->addAction(viewHex); @@ -200,11 +202,11 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) QAction* viewSigned = new QAction(tr("View as &Signed"), this); QAction* viewUnsigned = new QAction(tr("View as &Unsigned"), this); - connect(viewSigned, &QAction::triggered, m_watchModel, [=] { + connect(viewSigned, &QAction::triggered, m_watchModel, [this, entry] { entry->setSignedUnsigned(false); m_hasUnsavedChanges = true; }); - connect(viewUnsigned, &QAction::triggered, m_watchModel, [=] { + connect(viewUnsigned, &QAction::triggered, m_watchModel, [this, entry] { entry->setSignedUnsigned(true); m_hasUnsavedChanges = true; }); @@ -228,14 +230,14 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) } contextMenu->addSeparator(); QAction* lockSelection = new QAction(tr("Lock"), this); - connect(lockSelection, &QAction::triggered, this, [=] { onLockSelection(true); }); + connect(lockSelection, &QAction::triggered, this, [this] { onLockSelection(true); }); contextMenu->addAction(lockSelection); QAction* unlockSelection = new QAction(tr("Unlock"), this); - connect(unlockSelection, &QAction::triggered, this, [=] { onLockSelection(false); }); + connect(unlockSelection, &QAction::triggered, this, [this] { onLockSelection(false); }); contextMenu->addAction(unlockSelection); contextMenu->addSeparator(); QAction* const editValue{new QAction(tr("Edit Value"), this)}; - connect(editValue, &QAction::triggered, this, [=]() { m_watchView->edit(index); }); + connect(editValue, &QAction::triggered, this, [this, index]() { m_watchView->edit(index); }); contextMenu->addAction(editValue); contextMenu->addSeparator(); } @@ -246,21 +248,21 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) } QAction* cut = new QAction(tr("Cu&t"), this); - connect(cut, &QAction::triggered, this, [=] { cutSelectedWatchesToClipBoard(); }); + connect(cut, &QAction::triggered, this, [this] { cutSelectedWatchesToClipBoard(); }); contextMenu->addAction(cut); QAction* copy = new QAction(tr("&Copy"), this); - connect(copy, &QAction::triggered, this, [=] { copySelectedWatchesToClipBoard(); }); + connect(copy, &QAction::triggered, this, [this] { copySelectedWatchesToClipBoard(); }); contextMenu->addAction(copy); QAction* paste = new QAction(tr("&Paste"), this); - connect(paste, &QAction::triggered, this, [=] { + connect(paste, &QAction::triggered, this, [this, node] { pasteWatchFromClipBoard(node, m_watchView->selectionModel()->currentIndex().row() + 1); }); contextMenu->addAction(paste); contextMenu->addSeparator(); QAction* deleteSelection = new QAction(tr("&Delete"), this); - connect(deleteSelection, &QAction::triggered, this, [=] { onDeleteSelection(); }); + connect(deleteSelection, &QAction::triggered, this, [this] { onDeleteSelection(); }); contextMenu->addAction(deleteSelection); QModelIndexList selection = m_watchView->selectionModel()->selectedRows(); diff --git a/Source/GUI/Settings/DlgSettings.cpp b/Source/GUI/Settings/DlgSettings.cpp index 70f29990..8d2a6f89 100644 --- a/Source/GUI/Settings/DlgSettings.cpp +++ b/Source/GUI/Settings/DlgSettings.cpp @@ -89,7 +89,7 @@ DlgSettings::DlgSettings(QWidget* parent) : QDialog(parent) m_buttonsDlg = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(m_buttonsDlg, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(m_buttonsDlg, &QDialogButtonBox::clicked, this, [=](QAbstractButton* button) { + connect(m_buttonsDlg, &QDialogButtonBox::clicked, this, [this](QAbstractButton* button) { if (m_buttonsDlg->buttonRole(button) == QDialogButtonBox::AcceptRole) { saveSettings(); From a0bb1a4b86d19ddc10b6b543bf3a3b15203f092e Mon Sep 17 00:00:00 2001 From: cristian64 Date: Fri, 26 Apr 2024 17:18:57 +0100 Subject: [PATCH 2/2] Compile with C++20. --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9be426ff..ce7f5f12 100755 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.13) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(GCC_min_version 10) project(dolphin-memory-engine)