Merge pull request #3275 from torusrxxx/patch000000fb

fix No such signal in graph view
This commit is contained in:
Duncan Ogilvie 2023-11-26 17:13:17 +01:00 committed by GitHub
commit 93ac4548f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 17 deletions

View File

@ -218,7 +218,7 @@ void DisassemblerGraphView::resizeEvent(QResizeEvent* event)
adjustSize(event->size().width(), event->size().height()); adjustSize(event->size().width(), event->size().height());
} }
duint DisassemblerGraphView::get_cursor_pos() duint DisassemblerGraphView::get_cursor_pos() const
{ {
if(this->cur_instr == 0) if(this->cur_instr == 0)
return this->function; return this->function;
@ -934,7 +934,7 @@ void DisassemblerGraphView::wheelEvent(QWheelEvent* event)
} }
} }
bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event) const
{ {
//Convert coordinates to system used in blocks //Convert coordinates to system used in blocks
int xofs = this->horizontalScrollBar()->value(); int xofs = this->horizontalScrollBar()->value();
@ -945,7 +945,7 @@ bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event)
// Check each block for hits // Check each block for hits
for(auto & blockIt : this->blocks) for(auto & blockIt : this->blocks)
{ {
DisassemblerBlock & block = blockIt.second; auto & block = blockIt.second;
//Compute coordinate relative to text area in block //Compute coordinate relative to text area in block
int blockx = x - (block.x + (2 * this->charWidth)); int blockx = x - (block.x + (2 * this->charWidth));
int blocky = y - (block.y + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth));
@ -959,7 +959,7 @@ bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event)
return false; return false;
} }
duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event) const
{ {
//Convert coordinates to system used in blocks //Convert coordinates to system used in blocks
int xofs = this->horizontalScrollBar()->value(); int xofs = this->horizontalScrollBar()->value();
@ -970,7 +970,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event)
//Check each block for hits //Check each block for hits
for(auto & blockIt : this->blocks) for(auto & blockIt : this->blocks)
{ {
DisassemblerBlock & block = blockIt.second; auto & block = blockIt.second;
//Compute coordinate relative to text area in block //Compute coordinate relative to text area in block
int blockx = x - (block.x + (2 * this->charWidth)); int blockx = x - (block.x + (2 * this->charWidth));
int blocky = y - (block.y + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth));
@ -985,7 +985,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event)
int cur_row = int(block.block.header_text.lines.size()); int cur_row = int(block.block.header_text.lines.size());
if(row < cur_row) if(row < cur_row)
return block.block.entry; return block.block.entry;
for(Instr & instr : block.block.instrs) for(auto & instr : block.block.instrs)
{ {
if(row < cur_row + int(instr.text.lines.size())) if(row < cur_row + int(instr.text.lines.size()))
return instr.addr; return instr.addr;
@ -995,7 +995,7 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event)
return 0; return 0;
} }
bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & tokenOut) bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & tokenOut) const
{ {
//Convert coordinates to system used in blocks //Convert coordinates to system used in blocks
int xofs = this->horizontalScrollBar()->value(); int xofs = this->horizontalScrollBar()->value();
@ -1006,7 +1006,7 @@ bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisToken
//Check each block for hits //Check each block for hits
for(auto & blockIt : this->blocks) for(auto & blockIt : this->blocks)
{ {
DisassemblerBlock & block = blockIt.second; auto & block = blockIt.second;
//Compute coordinate relative to text area in block //Compute coordinate relative to text area in block
int blockx = x - (block.x + (2 * this->charWidth)); int blockx = x - (block.x + (2 * this->charWidth));
int blocky = y - (block.y + (2 * this->charWidth)); int blocky = y - (block.y + (2 * this->charWidth));
@ -1064,12 +1064,16 @@ bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, ZydisToken
bool DisassemblerGraphView::find_instr(duint addr, Instr & instrOut) bool DisassemblerGraphView::find_instr(duint addr, Instr & instrOut)
{ {
for(auto & blockIt : this->blocks) for(auto & blockIt : this->blocks)
{
for(Instr & instr : blockIt.second.block.instrs) for(Instr & instr : blockIt.second.block.instrs)
{
if(instr.addr == addr) if(instr.addr == addr)
{ {
instrOut = instr; instrOut = instr;
return true; return true;
} }
}
}
return false; return false;
} }
@ -1358,7 +1362,7 @@ void DisassemblerGraphView::computeGraphLayout(DisassemblerBlock & block)
block.row_count = row_count; block.row_count = row_count;
} }
bool DisassemblerGraphView::isEdgeMarked(EdgesVector & edges, int row, int col, int index) bool DisassemblerGraphView::isEdgeMarked(EdgesVector & edges, int row, int col, int index) const
{ {
if(index >= int(edges[row][col].size())) if(index >= int(edges[row][col].size()))
return false; return false;
@ -2692,7 +2696,7 @@ void DisassemblerGraphView::copyHighlightedTokenValueSlot()
Bridge::CopyToClipboard(text); Bridge::CopyToClipboard(text);
} }
bool DisassemblerGraphView::getHighlightedTokenValueText(QString & text) bool DisassemblerGraphView::getHighlightedTokenValueText(QString & text) const
{ {
if(mHighlightToken.type <= ZydisTokenizer::TokenType::MnemonicUnusual) if(mHighlightToken.type <= ZydisTokenizer::TokenType::MnemonicUnusual)
return false; return false;

View File

@ -212,7 +212,7 @@ public:
void initFont(); void initFont();
void adjustSize(int viewportWidth, int viewportHeight, QPoint mousePosition = QPoint(0, 0), bool fitToWindow = false); void adjustSize(int viewportWidth, int viewportHeight, QPoint mousePosition = QPoint(0, 0), bool fitToWindow = false);
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
duint get_cursor_pos(); duint get_cursor_pos() const;
void set_cursor_pos(duint addr); void set_cursor_pos(duint addr);
std::tuple<duint, duint> get_selection_range(); std::tuple<duint, duint> get_selection_range();
void set_selection_range(std::tuple<duint, duint> range); void set_selection_range(std::tuple<duint, duint> range);
@ -220,9 +220,9 @@ public:
void paintNormal(QPainter & p, QRect & viewportRect, int xofs, int yofs); void paintNormal(QPainter & p, QRect & viewportRect, int xofs, int yofs);
void paintOverview(QPainter & p, QRect & viewportRect, int xofs, int yofs); void paintOverview(QPainter & p, QRect & viewportRect, int xofs, int yofs);
void paintEvent(QPaintEvent* event); void paintEvent(QPaintEvent* event);
bool isMouseEventInBlock(QMouseEvent* event); bool isMouseEventInBlock(QMouseEvent* event) const;
duint getInstrForMouseEvent(QMouseEvent* event); duint getInstrForMouseEvent(QMouseEvent* event) const;
bool getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & token); bool getTokenForMouseEvent(QMouseEvent* event, ZydisTokenizer::SingleToken & token) const;
bool find_instr(duint addr, Instr & instr); bool find_instr(duint addr, Instr & instr);
void mousePressEvent(QMouseEvent* event); void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event);
@ -236,7 +236,7 @@ public:
template<typename T> template<typename T>
using Matrix = std::vector<std::vector<T>>; using Matrix = std::vector<std::vector<T>>;
using EdgesVector = Matrix<std::vector<bool>>; using EdgesVector = Matrix<std::vector<bool>>;
bool isEdgeMarked(EdgesVector & edges, int row, int col, int index); bool isEdgeMarked(EdgesVector & edges, int row, int col, int index) const;
void markEdge(EdgesVector & edges, int row, int col, int index, bool used = true); void markEdge(EdgesVector & edges, int row, int col, int index, bool used = true);
int findHorizEdgeIndex(EdgesVector & edges, int row, int min_col, int max_col); int findHorizEdgeIndex(EdgesVector & edges, int row, int min_col, int max_col);
int findVertEdgeIndex(EdgesVector & edges, int col, int min_row, int max_row); int findVertEdgeIndex(EdgesVector & edges, int col, int min_row, int max_row);
@ -257,7 +257,7 @@ public:
VaHistory mHistory; VaHistory mHistory;
signals: signals:
void selectionChanged(dsint parVA); void selectionChanged(duint parVA);
void displayLogWidget(); void displayLogWidget();
void detachGraph(); void detachGraph();
@ -392,5 +392,5 @@ private:
XrefBrowseDialog* mXrefDlg = nullptr; XrefBrowseDialog* mXrefDlg = nullptr;
void addReferenceAction(QMenu* menu, duint addr, const QString & description); void addReferenceAction(QMenu* menu, duint addr, const QString & description);
bool getHighlightedTokenValueText(QString & text); bool getHighlightedTokenValueText(QString & text) const;
}; };