mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 03:16:10 +00:00
Replace DisassemblerGraphView::sent_seek with connect/disconnect
This commit is contained in:
parent
b857e724e8
commit
e642406192
@ -37,7 +37,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
|
|
||||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||||
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA)));
|
connectSeekChanged(false);
|
||||||
|
|
||||||
// Space to switch to disassembly
|
// Space to switch to disassembly
|
||||||
QShortcut *shortcut_disassembly = new QShortcut(QKeySequence(Qt::Key_Space), this);
|
QShortcut *shortcut_disassembly = new QShortcut(QKeySequence(Qt::Key_Space), this);
|
||||||
@ -103,6 +103,15 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
colorsUpdatedSlot();
|
colorsUpdatedSlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisassemblerGraphView::connectSeekChanged(bool disconnect)
|
||||||
|
{
|
||||||
|
if (disconnect) {
|
||||||
|
QObject::disconnect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA)));
|
||||||
|
} else {
|
||||||
|
connect(Core(), SIGNAL(seekChanged(RVA)), this, SLOT(onSeekChanged(RVA)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DisassemblerGraphView::~DisassemblerGraphView()
|
DisassemblerGraphView::~DisassemblerGraphView()
|
||||||
{
|
{
|
||||||
for (QShortcut *shortcut : shortcuts) {
|
for (QShortcut *shortcut : shortcuts) {
|
||||||
@ -232,6 +241,7 @@ void DisassemblerGraphView::loadCurrentGraph()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DisassemblerGraphView::prepareGraphNode(GraphBlock &block)
|
void DisassemblerGraphView::prepareGraphNode(GraphBlock &block)
|
||||||
{
|
{
|
||||||
DisassemblyBlock &db = disassembly_blocks[block.entry];
|
DisassemblyBlock &db = disassembly_blocks[block.entry];
|
||||||
@ -260,7 +270,6 @@ void DisassemblerGraphView::prepareGraphNode(GraphBlock &block)
|
|||||||
block.height = (height * charHeight) + extra;
|
block.height = (height * charHeight) + extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DisassemblerGraphView::initFont()
|
void DisassemblerGraphView::initFont()
|
||||||
{
|
{
|
||||||
setFont(Config()->getFont());
|
setFont(Config()->getFont());
|
||||||
@ -396,6 +405,7 @@ GraphView::EdgeConfiguration DisassemblerGraphView::edgeConfiguration(GraphView:
|
|||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RVA DisassemblerGraphView::getAddrForMouseEvent(GraphBlock &block, QPoint *point)
|
RVA DisassemblerGraphView::getAddrForMouseEvent(GraphBlock &block, QPoint *point)
|
||||||
{
|
{
|
||||||
DisassemblyBlock &db = disassembly_blocks[block.entry];
|
DisassemblyBlock &db = disassembly_blocks[block.entry];
|
||||||
@ -419,7 +429,6 @@ RVA DisassemblerGraphView::getAddrForMouseEvent(GraphBlock &block, QPoint *point
|
|||||||
return RVA_INVALID;
|
return RVA_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DisassemblerGraphView::Instr *DisassemblerGraphView::getInstrForMouseEvent(
|
DisassemblerGraphView::Instr *DisassemblerGraphView::getInstrForMouseEvent(
|
||||||
GraphView::GraphBlock &block, QPoint *point)
|
GraphView::GraphBlock &block, QPoint *point)
|
||||||
{
|
{
|
||||||
@ -485,26 +494,22 @@ DisassemblerGraphView::DisassemblyBlock *DisassemblerGraphView::blockForAddress(
|
|||||||
void DisassemblerGraphView::onSeekChanged(RVA addr)
|
void DisassemblerGraphView::onSeekChanged(RVA addr)
|
||||||
{
|
{
|
||||||
mMenu->setOffset(addr);
|
mMenu->setOffset(addr);
|
||||||
// If this seek was NOT done by us...
|
DisassemblyBlock *db = blockForAddress(addr);
|
||||||
if (!sent_seek) {
|
if (db) {
|
||||||
|
// This is a local address! We animated to it.
|
||||||
|
transition_dont_seek = true;
|
||||||
|
showBlock(&blocks[db->entry], true);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
refreshView();
|
||||||
DisassemblyBlock *db = blockForAddress(addr);
|
DisassemblyBlock *db = blockForAddress(addr);
|
||||||
if (db) {
|
if (db) {
|
||||||
// This is a local address! We animated to it.
|
// This is a local address! We animated to it.
|
||||||
transition_dont_seek = true;
|
transition_dont_seek = true;
|
||||||
showBlock(&blocks[db->entry], true);
|
showBlock(&blocks[db->entry], false);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
refreshView();
|
|
||||||
DisassemblyBlock *db = blockForAddress(addr);
|
|
||||||
if (db) {
|
|
||||||
// This is a local address! We animated to it.
|
|
||||||
transition_dont_seek = true;
|
|
||||||
showBlock(&blocks[db->entry], false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sent_seek = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisassemblerGraphView::zoomIn(QPoint mouse)
|
void DisassemblerGraphView::zoomIn(QPoint mouse)
|
||||||
@ -587,8 +592,9 @@ void DisassemblerGraphView::prevInstr()
|
|||||||
|
|
||||||
void DisassemblerGraphView::seek(RVA addr, bool update_viewport)
|
void DisassemblerGraphView::seek(RVA addr, bool update_viewport)
|
||||||
{
|
{
|
||||||
sent_seek = true;
|
connectSeekChanged(true);
|
||||||
Core()->seek(addr);
|
Core()->seek(addr);
|
||||||
|
connectSeekChanged(false);
|
||||||
if (update_viewport) {
|
if (update_viewport) {
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
}
|
}
|
||||||
@ -625,7 +631,6 @@ void DisassemblerGraphView::blockDoubleClicked(GraphView::GraphBlock &block, QMo
|
|||||||
}
|
}
|
||||||
QList<XrefDescription> refs = Core()->getXRefs(instr, false, false);
|
QList<XrefDescription> refs = Core()->getXRefs(instr, false, false);
|
||||||
if (refs.length()) {
|
if (refs.length()) {
|
||||||
sent_seek = false;
|
|
||||||
Core()->seek(refs.at(0).to);
|
Core()->seek(refs.at(0).to);
|
||||||
}
|
}
|
||||||
if (refs.length() > 1) {
|
if (refs.length() > 1) {
|
||||||
@ -665,6 +670,7 @@ void DisassemblerGraphView::blockTransitionedTo(GraphView::GraphBlock *to)
|
|||||||
seek(to->entry);
|
seek(to->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DisassemblerGraphView::on_actionExportGraph_triggered()
|
void DisassemblerGraphView::on_actionExportGraph_triggered()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
QString fileName = QFileDialog::getSaveFileName(this,
|
||||||
@ -677,8 +683,6 @@ void DisassemblerGraphView::on_actionExportGraph_triggered()
|
|||||||
QTextStream fileOut(&file);
|
QTextStream fileOut(&file);
|
||||||
fileOut << Core()->cmd("ag -");
|
fileOut << Core()->cmd("ag -");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DisassemblerGraphView::wheelEvent(QWheelEvent *event)
|
void DisassemblerGraphView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
// when CTRL is pressed, we zoom in/out with mouse wheel
|
// when CTRL is pressed, we zoom in/out with mouse wheel
|
||||||
|
@ -171,7 +171,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
bool first_draw = true;
|
bool first_draw = true;
|
||||||
bool transition_dont_seek = false;
|
bool transition_dont_seek = false;
|
||||||
bool sent_seek = false;
|
|
||||||
|
|
||||||
HighlightToken *highlight_token;
|
HighlightToken *highlight_token;
|
||||||
// Font data
|
// Font data
|
||||||
@ -183,6 +182,8 @@ private:
|
|||||||
|
|
||||||
DisassemblyContextMenu *mMenu;
|
DisassemblyContextMenu *mMenu;
|
||||||
|
|
||||||
|
void connectSeekChanged(bool disconnect);
|
||||||
|
|
||||||
void initFont();
|
void initFont();
|
||||||
void prepareGraphNode(GraphBlock &block);
|
void prepareGraphNode(GraphBlock &block);
|
||||||
RVA getAddrForMouseEvent(GraphBlock &block, QPoint *point);
|
RVA getAddrForMouseEvent(GraphBlock &block, QPoint *point);
|
||||||
|
Loading…
Reference in New Issue
Block a user