From f8c3b9f26c7c85235b09842735ed4fa2a87ad7bd Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 23 Aug 2024 09:25:20 -0500 Subject: [PATCH 1/6] Fixed crash bug when right clicking on nothing and added 'Add group' and 'Add watch' to the empty context menu --- Source/GUI/MemWatcher/MemWatchModel.cpp | 4 +++- Source/GUI/MemWatcher/MemWatchWidget.cpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/GUI/MemWatcher/MemWatchModel.cpp b/Source/GUI/MemWatcher/MemWatchModel.cpp index bbe5004a..0a2c5616 100644 --- a/Source/GUI/MemWatcher/MemWatchModel.cpp +++ b/Source/GUI/MemWatcher/MemWatchModel.cpp @@ -119,7 +119,9 @@ void MemWatchModel::changeType(const QModelIndex& index, Common::MemType type, s MemWatchEntry* MemWatchModel::getEntryFromIndex(const QModelIndex& index) { MemWatchTreeNode* node = static_cast(index.internalPointer()); - return node->getEntry(); + if (node) + return node->getEntry(); + return nullptr; } void MemWatchModel::addNodes(const std::vector& nodes, diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 25b7e30a..616bae74 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -267,6 +267,17 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) contextMenu->addSeparator(); } + MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)}; + if (!entry) { + QAction* const addGroup{new QAction(tr("Add &group"), this)}; + connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup); + contextMenu->addAction(addGroup); + QAction* const addWatch{new QAction(tr("Add &watch"), this)}; + connect(addWatch, &QAction::triggered, this, &MemWatchWidget::onAddWatchEntry); + contextMenu->addAction(addWatch); + contextMenu->addSeparator(); + } + QAction* cut = new QAction(tr("Cu&t"), this); connect(cut, &QAction::triggered, this, [this] { cutSelectedWatchesToClipBoard(); }); contextMenu->addAction(cut); @@ -274,7 +285,6 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) connect(copy, &QAction::triggered, this, [this] { copySelectedWatchesToClipBoard(); }); contextMenu->addAction(copy); - MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)}; if (entry) { if (entry->isBoundToPointer()) From 1315a7da1cc4b8a8e519a723aa6d740b62271d7c Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Fri, 23 Aug 2024 10:38:17 -0500 Subject: [PATCH 2/6] Fix pointer level crash bug --- Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp b/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp index 337509dd..7d217f30 100644 --- a/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp +++ b/Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp @@ -193,6 +193,7 @@ void DlgAddWatchEntry::fillFields(MemWatchEntry* entry) void DlgAddWatchEntry::addPointerOffset() { int level = static_cast(m_entry->getPointerLevel()); + m_entry->addOffset(0); QLabel* lblLevel = new QLabel(QString::fromStdString("Level " + std::to_string(level + 1) + ":")); QLineEdit* txbOffset = new QLineEdit(); m_offsets.append(txbOffset); @@ -207,7 +208,7 @@ void DlgAddWatchEntry::addPointerOffset() m_offsetsLayout->addWidget(lblLevel, level, 0); m_offsetsLayout->addWidget(txbOffset, level, 1); m_offsetsLayout->addWidget(lblAddressOfPath, level, 2); - m_entry->addOffset(0); + connect(txbOffset, &QLineEdit::textEdited, this, &DlgAddWatchEntry::onOffsetChanged); if (m_entry->getPointerLevel() > 1) m_btnRemoveOffset->setEnabled(true); From 22c7baf474f3e010c7b9cf18a2cae3ecd943bf57 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 25 Aug 2024 00:09:24 -0500 Subject: [PATCH 3/6] Make it work for groups too --- Source/GUI/MemWatcher/MemWatchWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 616bae74..b2922b7d 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -268,7 +268,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) } MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)}; - if (!entry) { + if (!entry || node->isGroup()) { QAction* const addGroup{new QAction(tr("Add &group"), this)}; connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup); contextMenu->addAction(addGroup); From aa68881197bb4f33725dcf91324ad1fdaaddc7d3 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 25 Aug 2024 11:50:04 -0500 Subject: [PATCH 4/6] use node instead --- Source/GUI/MemWatcher/MemWatchWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index b2922b7d..9972fb8f 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -267,8 +267,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) contextMenu->addSeparator(); } - MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)}; - if (!entry || node->isGroup()) { + if (!node || node->isGroup()) { QAction* const addGroup{new QAction(tr("Add &group"), this)}; connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup); contextMenu->addAction(addGroup); @@ -285,6 +284,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) connect(copy, &QAction::triggered, this, [this] { copySelectedWatchesToClipBoard(); }); contextMenu->addAction(copy); + MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)}; if (entry) { if (entry->isBoundToPointer()) From 707787056f9f4ec3a7850f52be94ffda9dea1657 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:45:21 -0500 Subject: [PATCH 5/6] change the key thing --- Source/GUI/MemWatcher/MemWatchWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 9972fb8f..0c4944dc 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -268,7 +268,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) } if (!node || node->isGroup()) { - QAction* const addGroup{new QAction(tr("Add &group"), this)}; + QAction* const addGroup{new QAction(tr("Add gro&up"), this)}; connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup); contextMenu->addAction(addGroup); QAction* const addWatch{new QAction(tr("Add &watch"), this)}; From 56d9063362401ef4fb231a2b39d9131bd013bbd9 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Sun, 25 Aug 2024 14:46:05 -0500 Subject: [PATCH 6/6] make it format --- Source/GUI/MemWatcher/MemWatchWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/GUI/MemWatcher/MemWatchWidget.cpp b/Source/GUI/MemWatcher/MemWatchWidget.cpp index 0c4944dc..953568d5 100644 --- a/Source/GUI/MemWatcher/MemWatchWidget.cpp +++ b/Source/GUI/MemWatcher/MemWatchWidget.cpp @@ -267,7 +267,8 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos) contextMenu->addSeparator(); } - if (!node || node->isGroup()) { + if (!node || node->isGroup()) + { QAction* const addGroup{new QAction(tr("Add gro&up"), this)}; connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup); contextMenu->addAction(addGroup);