Skip to content

Commit

Permalink
Merge pull request #120 from cristian64/cpp20
Browse files Browse the repository at this point in the history
Compile with C++20.
  • Loading branch information
dreamsyntax authored Apr 26, 2024
2 parents a99ea25 + a0bb1a4 commit 02f35d7
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/MemCopy/DlgCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/MemScanner/MemScanWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Source/GUI/MemViewer/MemViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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..."));
Expand All @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/MemViewer/MemViewerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions Source/GUI/MemWatcher/MemWatchModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,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 =
Expand All @@ -548,7 +548,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())
Expand All @@ -563,7 +563,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())
Expand All @@ -580,7 +580,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())
Expand All @@ -595,7 +595,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())
Expand Down
42 changes: 22 additions & 20 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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;
});
Expand All @@ -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();
}
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/Settings/DlgSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 02f35d7

Please sign in to comment.