Skip to content

Commit

Permalink
Get rid of stale jump arrows in disassembly widget. (#3175)
Browse files Browse the repository at this point in the history
This commit clears arrows from edited instructions, in order to avoid
stale arrows to remain drawn.

closes #3114
  • Loading branch information
beauby authored and XVilka committed May 14, 2023
1 parent 9cbacff commit e523ac8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/widgets/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main)
connect(Core(), &CutterCore::functionRenamed, this, [this]() { refreshDisasm(); });
connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshDisasm()));
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshDisasm()));
connect(Core(), &CutterCore::instructionChanged, this, &DisassemblyWidget::refreshIfInRange);
connect(Core(), &CutterCore::instructionChanged, this, &DisassemblyWidget::instructionChanged);
connect(Core(), &CutterCore::breakpointsChanged, this, &DisassemblyWidget::refreshIfInRange);
connect(Core(), SIGNAL(refreshCodeViews()), this, SLOT(refreshDisasm()));

Expand Down Expand Up @@ -226,6 +226,12 @@ void DisassemblyWidget::refreshIfInRange(RVA offset)
}
}

void DisassemblyWidget::instructionChanged(RVA offset)
{
leftPanel->clearArrowFrom(offset);
refreshDisasm();
}

void DisassemblyWidget::refreshDisasm(RVA offset)
{
if (!disasmRefresh->attemptRefresh(offset == RVA_INVALID ? nullptr : new RVA(offset))) {
Expand Down Expand Up @@ -988,3 +994,12 @@ void DisassemblyLeftPanel::paintEvent(QPaintEvent *event)

lastBeginOffset = lines.first().offset;
}

void DisassemblyLeftPanel::clearArrowFrom(RVA offset)
{
auto it = std::find_if(arrows.begin(), arrows.end(),
[&](const Arrow &it) { return it.jmpFromOffset() == offset; });
if (it != arrows.end()) {
arrows.erase(it);
}
}
2 changes: 2 additions & 0 deletions src/widgets/DisassemblyWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public slots:
protected slots:
void on_seekChanged(RVA offset);
void refreshIfInRange(RVA offset);
void instructionChanged(RVA offset);
void refreshDisasm(RVA offset = RVA_INVALID);

bool updateMaxLines();
Expand Down Expand Up @@ -153,6 +154,7 @@ class DisassemblyLeftPanel : public QFrame
DisassemblyLeftPanel(DisassemblyWidget *disas);
void paintEvent(QPaintEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void clearArrowFrom(RVA offset);

private:
DisassemblyWidget *disas;
Expand Down

0 comments on commit e523ac8

Please sign in to comment.