mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Keep graph priority if the graph is empty (#734)
This commit is contained in:
parent
1c69d62f4e
commit
c3d029e5aa
@ -1229,6 +1229,16 @@ QString CutterCore::getSimpleGraph(QString function)
|
||||
return dot;
|
||||
}
|
||||
|
||||
void CutterCore::setGraphEmpty(bool empty)
|
||||
{
|
||||
emptyGraph = empty;
|
||||
}
|
||||
|
||||
bool CutterCore::isGraphEmpty()
|
||||
{
|
||||
return emptyGraph;
|
||||
}
|
||||
|
||||
void CutterCore::getOpcodes()
|
||||
{
|
||||
QString opcodes = cmd("?O");
|
||||
|
@ -538,6 +538,8 @@ public:
|
||||
QJsonDocument getFileVersionInfo();
|
||||
QStringList getStats();
|
||||
QString getSimpleGraph(QString function);
|
||||
void setGraphEmpty(bool empty);
|
||||
bool isGraphEmpty();
|
||||
|
||||
void getOpcodes();
|
||||
QList<QString> opcodes;
|
||||
@ -661,6 +663,8 @@ private:
|
||||
RVA offsetPriorDebugging = RVA_INVALID;
|
||||
QErrorMessage msgBox;
|
||||
|
||||
bool emptyGraph = false;
|
||||
|
||||
QList<CutterPlugin*> plugins;
|
||||
};
|
||||
|
||||
|
@ -19,8 +19,7 @@ void CutterSeekableWidget::seek(RVA addr)
|
||||
{
|
||||
if (isInSyncWithCore) {
|
||||
Core()->seek(addr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
prevIdenpendentOffset = independentOffset;
|
||||
independentOffset = addr;
|
||||
emit seekChanged(addr);
|
||||
@ -32,8 +31,7 @@ RVA CutterSeekableWidget::getOffset()
|
||||
RVA addr;
|
||||
if (isInSyncWithCore) {
|
||||
addr = Core()->getOffset();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr = independentOffset;
|
||||
}
|
||||
return addr;
|
||||
@ -64,4 +62,4 @@ void CutterSeekableWidget::setIndependentOffset(RVA addr)
|
||||
independentOffset = addr;
|
||||
}
|
||||
|
||||
CutterSeekableWidget::~CutterSeekableWidget() {}
|
||||
CutterSeekableWidget::~CutterSeekableWidget() {}
|
||||
|
@ -168,10 +168,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
||||
|
||||
bool emptyGraph = functions.isEmpty();
|
||||
if (emptyGraph) {
|
||||
// If there's no function to print, just move to disassembly and add a message
|
||||
if (Core()->getMemoryWidgetPriority() == CutterCore::MemoryWidgetType::Graph) {
|
||||
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
||||
}
|
||||
// If there's no function to print, just add a message
|
||||
if (!emptyText) {
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
emptyText = new QLabel(this);
|
||||
@ -184,6 +181,8 @@ void DisassemblerGraphView::loadCurrentGraph()
|
||||
} else if (emptyText) {
|
||||
emptyText->setVisible(false);
|
||||
}
|
||||
// Refresh global "empty graph" variable so other widget know there is nothing to show here
|
||||
Core()->setGraphEmpty(emptyGraph);
|
||||
|
||||
Analysis anal;
|
||||
anal.ready = true;
|
||||
@ -707,7 +706,7 @@ void DisassemblerGraphView::seekInstruction(bool previous_instr)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Found the instructon. Check if a next one exists
|
||||
// Found the instruction. Check if a next one exists
|
||||
if (!previous_instr && (i < db->instrs.size() - 1)) {
|
||||
seekable->seek(db->instrs[i + 1].addr);
|
||||
} else if (previous_instr && (i > 0)) {
|
||||
|
@ -108,7 +108,7 @@ class DisassemblerGraphView : public GraphView
|
||||
|
||||
public:
|
||||
DisassemblerGraphView(QWidget *parent);
|
||||
~DisassemblerGraphView();
|
||||
~DisassemblerGraphView() override;
|
||||
std::unordered_map<ut64, DisassemblyBlock> disassembly_blocks;
|
||||
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block) override;
|
||||
virtual void blockClicked(GraphView::GraphBlock &block, QMouseEvent *event, QPoint pos) override;
|
||||
@ -122,7 +122,7 @@ public:
|
||||
|
||||
void loadCurrentGraph();
|
||||
QString windowTitle;
|
||||
// bool navigate(ut64 addr);
|
||||
bool isGraphEmpty();
|
||||
|
||||
public slots:
|
||||
void refreshView();
|
||||
@ -160,6 +160,7 @@ private:
|
||||
int charHeight;
|
||||
int charOffset;
|
||||
int baseline;
|
||||
bool emptyGraph;
|
||||
|
||||
DisassemblyContextMenu *mMenu;
|
||||
|
||||
|
@ -125,7 +125,8 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||
|
||||
connect(this, &QDockWidget::visibilityChanged, this, [](bool visibility) {
|
||||
if (visibility) {
|
||||
bool emptyGraph = (Core()->getMemoryWidgetPriority() == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty());
|
||||
if (visibility && !emptyGraph) {
|
||||
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
||||
}
|
||||
});
|
||||
@ -623,7 +624,8 @@ void DisassemblyWidget::on_seekChanged(RVA offset)
|
||||
|
||||
void DisassemblyWidget::raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type)
|
||||
{
|
||||
if (type == CutterCore::MemoryWidgetType::Disassembly) {
|
||||
bool emptyGraph = (type == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty());
|
||||
if (type == CutterCore::MemoryWidgetType::Disassembly || emptyGraph) {
|
||||
raise();
|
||||
setFocus();
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
|
||||
|
||||
connect(Core(), &CutterCore::raisePrioritizedMemoryWidget,
|
||||
this, [ = ](CutterCore::MemoryWidgetType type) {
|
||||
if (type == CutterCore::MemoryWidgetType::Graph) {
|
||||
bool emptyGraph = (type == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty());
|
||||
if (type == CutterCore::MemoryWidgetType::Graph && !emptyGraph) {
|
||||
this->raise();
|
||||
this->graphView->setFocus();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user