Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two crash bugs, add new context menu items #175

Merged
merged 6 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 11 additions & 1 deletion Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,24 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos)
contextMenu->addSeparator();
}

MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)};
if (!entry || node->isGroup()) {
cristian64 marked this conversation as resolved.
Show resolved Hide resolved
QAction* const addGroup{new QAction(tr("Add &group"), this)};
camila314 marked this conversation as resolved.
Show resolved Hide resolved
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);
QAction* copy = new QAction(tr("&Copy"), this);
connect(copy, &QAction::triggered, this, [this] { copySelectedWatchesToClipBoard(); });
contextMenu->addAction(copy);

MemWatchEntry* const entry{MemWatchModel::getEntryFromIndex(index)};
if (entry)
{
if (entry->isBoundToPointer())
Expand Down
Loading