Skip to content

Commit

Permalink
Fix two crash bugs, add new context menu items (#175)
Browse files Browse the repository at this point in the history
* Add **Add group** and **Add watch** to the empty context menu or group entries
* Fix crash bug when right-clicking on nothing
* Fix pointer level crash bug
  • Loading branch information
camila314 authored Aug 25, 2024
1 parent bcb146f commit 090d19d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Source/GUI/MemWatcher/Dialogs/DlgAddWatchEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ void DlgAddWatchEntry::fillFields(MemWatchEntry* entry)
void DlgAddWatchEntry::addPointerOffset()
{
int level = static_cast<int>(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);
Expand All @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Source/GUI/MemWatcher/MemWatchModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ void MemWatchModel::changeType(const QModelIndex& index, Common::MemType type, s
MemWatchEntry* MemWatchModel::getEntryFromIndex(const QModelIndex& index)
{
MemWatchTreeNode* node = static_cast<MemWatchTreeNode*>(index.internalPointer());
return node->getEntry();
if (node)
return node->getEntry();
return nullptr;
}

void MemWatchModel::addNodes(const std::vector<MemWatchTreeNode*>& nodes,
Expand Down
11 changes: 11 additions & 0 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos)
contextMenu->addSeparator();
}

if (!node || node->isGroup())
{
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)};
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);
Expand Down

0 comments on commit 090d19d

Please sign in to comment.