Get rid of stale jump arrows in disassembly widget. (#3175)

This commit clears arrows from edited instructions, in order to avoid
stale arrows to remain drawn.

closes #3114
This commit is contained in:
Lucas Hosseini 2023-05-14 06:59:13 +02:00 committed by Anton Kochkov
parent 9cbacff329
commit e523ac8365
2 changed files with 18 additions and 1 deletions

View File

@ -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()));
@ -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))) {
@ -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);
}
}

View File

@ -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();
@ -153,6 +154,7 @@ public:
DisassemblyLeftPanel(DisassemblyWidget *disas);
void paintEvent(QPaintEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void clearArrowFrom(RVA offset);
private:
DisassemblyWidget *disas;