From 8ca69ff5fc3b0e279d94926174ac62d48bbb2bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 30 Nov 2017 22:30:51 +0100 Subject: [PATCH] Correct update after rename X used here --- src/cutter.cpp | 15 +++++++++++++++ src/cutter.h | 5 +++++ src/menus/DisassemblyContextMenu.cpp | 17 ++++++++++++++++- src/widgets/DisassemblerGraphView.cpp | 3 +++ src/widgets/DisassemblyWidget.cpp | 2 ++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/cutter.cpp b/src/cutter.cpp index ca6354f5..09ccabc1 100644 --- a/src/cutter.cpp +++ b/src/cutter.cpp @@ -1253,6 +1253,21 @@ void CutterCore::addFlag(RVA offset, QString name, RVA size) emit flagsChanged(); } +void CutterCore::triggerFlagsChanged() +{ + emit flagsChanged(); +} + +void CutterCore::triggerVarsChanged() +{ + emit varsChanged(); +} + +void CutterCore::triggerFunctionRenamed(const QString &prevName, const QString &newName) +{ + emit functionRenamed(prevName, newName); +} + void CutterCore::loadPDB(const QString &file) { cmd("idp " + sanitizeStringForCommand(file)); diff --git a/src/cutter.h b/src/cutter.h index e47f9cc8..b72e8a5f 100644 --- a/src/cutter.h +++ b/src/cutter.h @@ -306,6 +306,10 @@ public: QList getXRefs(RVA addr, bool to, bool whole_function, const QString &filterType = QString::null); void addFlag(RVA offset, QString name, RVA size); + void triggerFlagsChanged(); + + void triggerVarsChanged(); + void triggerFunctionRenamed(const QString &prevName, const QString &newName); void triggerRefreshAll(); @@ -324,6 +328,7 @@ signals: void refreshAll(); void functionRenamed(QString prev_name, QString new_name); + void varsChanged(); void flagsChanged(); void commentsChanged(); void instructionChanged(RVA offset); diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index a3cf4a3b..891e2cba 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -314,6 +314,8 @@ void DisassemblyContextMenu::on_actionRenameUsedHere_triggered() RenameDialog *dialog = new RenameDialog(this); + QString oldName; + if (type == "address") { RVA offset = thingUsedHere["offset"].toVariant().toULongLong(); @@ -322,7 +324,7 @@ void DisassemblyContextMenu::on_actionRenameUsedHere_triggered() } else { - QString oldName = thingUsedHere.value("name").toString(); + oldName = thingUsedHere.value("name").toString(); dialog->setWindowTitle(tr("Rename %1").arg(oldName)); dialog->setName(oldName); } @@ -333,6 +335,19 @@ void DisassemblyContextMenu::on_actionRenameUsedHere_triggered() if (!newName.isEmpty()) { Core()->cmd("an " + newName + " @ " + QString::number(offset)); + + if (type == "address" || type == "flag") + { + Core()->triggerFlagsChanged(); + } + else if (type == "var") + { + Core()->triggerVarsChanged(); + } + else if (type == "function") + { + Core()->triggerFunctionRenamed(oldName, newName); + } } } } diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 25562f3e..595cce30 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -77,6 +77,9 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent) connect(Core(), SIGNAL(refreshAll()), this, SLOT(refreshView())); connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA))); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshView())); + connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshView())); + connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshView())); + connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshView())); connect(Core(), SIGNAL(instructionChanged(RVA)), this, SLOT(refreshView())); //connect(Bridge::getBridge(), SIGNAL(loadGraph(BridgeCFGraphList*, duint)), this, SLOT(loadGraphSlot(BridgeCFGraphList*, duint))); diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 605763fc..faef7f27 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -82,6 +82,8 @@ DisassemblyWidget::DisassemblyWidget(QWidget *parent) connect(Core(), SIGNAL(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType)), this, SLOT(raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType))); connect(Core(), SIGNAL(commentsChanged()), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(flagsChanged()), this, SLOT(refreshDisasm())); + connect(Core(), SIGNAL(functionRenamed(QString, QString)), this, SLOT(refreshDisasm())); + connect(Core(), SIGNAL(varsChanged()), this, SLOT(refreshDisasm())); connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshDisasm())); connect(Core(), &CutterCore::instructionChanged, this, [this](RVA offset) { if (offset >= topOffset && offset <= bottomOffset)