1
0
Fork 0

fixed a crash and enable user to dblclick on folding box (#1473)

* fixed a crash and enable user to dblclick on folding box

* fixed when eip is in the current function it cant select
This commit is contained in:
Torusrxxx 2017-02-21 18:33:58 +00:00 committed by Duncan Ogilvie
parent 2268d364a7
commit 54ac01ef66
3 changed files with 47 additions and 0 deletions

View File

@ -407,6 +407,34 @@ void CPUSideBar::mouseReleaseEvent(QMouseEvent* e)
}
}
void CPUSideBar::mouseDoubleClickEvent(QMouseEvent* event)
{
const int line = event->y() / fontHeight;
if(line >= mInstrBuffer->size())
return;
const bool CheckBoxPresent = isFoldingGraphicsPresent(line);
if(CheckBoxPresent)
{
if(event->x() > width() - fontHeight - mBulletXOffset - mBulletRadius && event->x() < width() - mBulletXOffset - mBulletRadius)
{
if(event->button() == Qt::LeftButton)
{
duint wVA = mInstrBuffer->at(line).rva + mDisas->getBase();
dsint start, end;
start = mCodeFoldingManager.getFoldBegin(wVA) - mDisas->getBase();
end = mCodeFoldingManager.getFoldEnd(wVA) - mDisas->getBase();
if(mCodeFoldingManager.isFolded(wVA) || (start <= regDump.regcontext.cip - mDisas->getBase() && end >= regDump.regcontext.cip - mDisas->getBase()))
{
mDisas->setSingleSelection(start);
mDisas->expandSelectionUpTo(end);
mDisas->setFocus();
}
}
}
}
}
void CPUSideBar::mouseMoveEvent(QMouseEvent* event)
{
if(!DbgIsDebugging() || !mInstrBuffer->size())

View File

@ -48,6 +48,7 @@ protected:
void paintEvent(QPaintEvent* event);
void mouseReleaseEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent* event);
void drawBullets(QPainter* painter, int line, bool ispb, bool isbpdisabled, bool isbookmark);
bool isJump(int i) const;

View File

@ -527,6 +527,8 @@ bool DisassemblerGraphView::find_instr(duint addr, Instr & instrOut)
void DisassemblerGraphView::mousePressEvent(QMouseEvent* event)
{
if(!DbgIsDebugging())
return;
if(drawOverview)
{
if(event->button() == Qt::LeftButton)
@ -1624,6 +1626,10 @@ void DisassemblerGraphView::setCommentSlot()
LineEditDialog mLineEdit(this);
QString addr_text = ToPtrString(wVA);
char comment_text[MAX_COMMENT_SIZE] = "";
if(!DbgIsDebugging())
return;
if(!DbgMemIsValidReadPtr(wVA))
return;
if(DbgGetCommentAt((duint)wVA, comment_text))
{
@ -1651,6 +1657,10 @@ void DisassemblerGraphView::setLabelSlot()
LineEditDialog mLineEdit(this);
QString addr_text = ToPtrString(wVA);
char label_text[MAX_LABEL_SIZE] = "";
if(!DbgIsDebugging())
return;
if(!DbgMemIsValidReadPtr(wVA))
return;
if(DbgGetLabelAt((duint)wVA, SEG_DEFAULT, label_text))
mLineEdit.setText(QString(label_text));
@ -1684,6 +1694,9 @@ void DisassemblerGraphView::xrefSlot()
XREF_INFO mXrefInfo;
if(!DbgIsDebugging())
return;
duint wVA = this->get_cursor_pos();
if(!DbgMemIsValidReadPtr(wVA))
return;
DbgXrefGet(this->get_cursor_pos(), &mXrefInfo);
if(!mXrefInfo.refcount)
return;
@ -1697,6 +1710,11 @@ void DisassemblerGraphView::decompileSlot()
{
std::vector<SnowmanRange> ranges;
ranges.reserve(currentGraph.nodes.size());
if(!DbgIsDebugging())
return;
if(currentGraph.nodes.empty())
return;
SnowmanRange r;
for(const auto & nodeIt : currentGraph.nodes)
{