From 7755b6c8952c349a86904f0e26eda5766e6e17a4 Mon Sep 17 00:00:00 2001 From: Torusrxxx Date: Thu, 18 Aug 2016 12:08:03 +0000 Subject: [PATCH] Fix when double-clicking on the dump when not debugging modify dialog would appear (#991) --- src/gui/Src/BasicView/HexDump.cpp | 4 ++-- src/gui/Src/BasicView/ReferenceView.cpp | 2 +- src/gui/Src/Gui/CPUDisassembly.cpp | 16 ++++++++++++++++ src/gui/Src/Gui/CPUDump.cpp | 2 +- src/gui/Src/Gui/CPUStack.cpp | 2 +- src/gui/Src/Gui/RegistersView.cpp | 10 +++------- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/gui/Src/BasicView/HexDump.cpp b/src/gui/Src/BasicView/HexDump.cpp index f940d1f2..b8d61a0a 100644 --- a/src/gui/Src/BasicView/HexDump.cpp +++ b/src/gui/Src/BasicView/HexDump.cpp @@ -185,7 +185,7 @@ QString HexDump::makeAddrText(duint va) } else *label = 0; - return addrText; + return std::move(addrText); } QString HexDump::makeCopyText() @@ -214,7 +214,7 @@ QString HexDump::makeCopyText() curRow += getBytePerRowCount(); result += "\n"; } - return result; + return std::move(result); } void HexDump::addVaToHistory(dsint parVa) diff --git a/src/gui/Src/BasicView/ReferenceView.cpp b/src/gui/Src/BasicView/ReferenceView.cpp index 5e32ace4..e0c186cd 100644 --- a/src/gui/Src/BasicView/ReferenceView.cpp +++ b/src/gui/Src/BasicView/ReferenceView.cpp @@ -240,7 +240,7 @@ void ReferenceView::followDumpAddress() void ReferenceView::followApiAddress() { dsint apiValue = apiAddressFromString(mCurList->getCellContent(mCurList->getInitialSelection(), 1)); - DbgCmdExecDirect(QString("disasm " + QString().sprintf("%p", apiValue)).toUtf8().constData()); + DbgCmdExecDirect(QString("disasm " + ToPtrString(apiValue)).toUtf8().constData()); emit showCpu(); } diff --git a/src/gui/Src/Gui/CPUDisassembly.cpp b/src/gui/Src/Gui/CPUDisassembly.cpp index 5fc635be..cd38abf6 100644 --- a/src/gui/Src/Gui/CPUDisassembly.cpp +++ b/src/gui/Src/Gui/CPUDisassembly.cpp @@ -1554,6 +1554,8 @@ void CPUDisassembly::editSoftBpActionSlot() void CPUDisassembly::ActionTraceRecordBitSlot() { + if(!DbgIsDebugging()) + return; duint base = mMemPage->getBase(); duint size = mMemPage->getSize(); for(duint i = base; i < base + size; i += 4096) @@ -1568,6 +1570,8 @@ void CPUDisassembly::ActionTraceRecordBitSlot() void CPUDisassembly::ActionTraceRecordByteSlot() { + if(!DbgIsDebugging()) + return; duint base = mMemPage->getBase(); duint size = mMemPage->getSize(); for(duint i = base; i < base + size; i += 4096) @@ -1582,6 +1586,8 @@ void CPUDisassembly::ActionTraceRecordByteSlot() void CPUDisassembly::ActionTraceRecordWordSlot() { + if(!DbgIsDebugging()) + return; duint base = mMemPage->getBase(); duint size = mMemPage->getSize(); for(duint i = base; i < base + size; i += 4096) @@ -1596,6 +1602,8 @@ void CPUDisassembly::ActionTraceRecordWordSlot() void CPUDisassembly::ActionTraceRecordDisableSlot() { + if(!DbgIsDebugging()) + return; duint base = mMemPage->getBase(); duint size = mMemPage->getSize(); for(duint i = base; i < base + size; i += 4096) @@ -1634,6 +1642,8 @@ void CPUDisassembly::analyzeSingleFunctionSlot() void CPUDisassembly::removeAnalysisSelectionSlot() { + if(!DbgIsDebugging()) + return; WordEditDialog mLineEdit(this); mLineEdit.setup(tr("Size"), getSelectionSize(), sizeof(duint)); if(mLineEdit.exec() != QDialog::Accepted || !mLineEdit.getVal()) @@ -1644,12 +1654,16 @@ void CPUDisassembly::removeAnalysisSelectionSlot() void CPUDisassembly::removeAnalysisModuleSlot() { + if(!DbgIsDebugging()) + return; mDisasm->getEncodeMap()->delSegment(rvaToVa(getSelectionStart())); GuiUpdateDisassemblyView(); } void CPUDisassembly::setEncodeTypeRangeSlot() { + if(!DbgIsDebugging()) + return; QAction* pAction = qobject_cast(sender()); WordEditDialog mLineEdit(this); mLineEdit.setup(tr("Size"), getSelectionSize(), sizeof(duint)); @@ -1661,6 +1675,8 @@ void CPUDisassembly::setEncodeTypeRangeSlot() void CPUDisassembly::setEncodeTypeSlot() { + if(!DbgIsDebugging()) + return; QAction* pAction = qobject_cast(sender()); mDisasm->getEncodeMap()->setDataType(rvaToVa(getSelectionStart()), (ENCODETYPE)pAction->data().toUInt()); GuiUpdateDisassemblyView(); diff --git a/src/gui/Src/Gui/CPUDump.cpp b/src/gui/Src/Gui/CPUDump.cpp index ec8c829f..53755fda 100644 --- a/src/gui/Src/Gui/CPUDump.cpp +++ b/src/gui/Src/Gui/CPUDump.cpp @@ -317,7 +317,7 @@ void CPUDump::contextMenuEvent(QContextMenuEvent* event) void CPUDump::mouseDoubleClickEvent(QMouseEvent* event) { - if(event->button() != Qt::LeftButton) + if(event->button() != Qt::LeftButton || !DbgIsDebugging()) return; switch(getColumnIndexFromX(event->x())) { diff --git a/src/gui/Src/Gui/CPUStack.cpp b/src/gui/Src/Gui/CPUStack.cpp index c06a2b7b..56ac4505 100644 --- a/src/gui/Src/Gui/CPUStack.cpp +++ b/src/gui/Src/Gui/CPUStack.cpp @@ -606,7 +606,7 @@ void CPUStack::contextMenuEvent(QContextMenuEvent* event) void CPUStack::mouseDoubleClickEvent(QMouseEvent* event) { - if(event->button() != Qt::LeftButton) + if(event->button() != Qt::LeftButton || !DbgIsDebugging()) return; switch(getColumnIndexFromX(event->x())) { diff --git a/src/gui/Src/Gui/RegistersView.cpp b/src/gui/Src/Gui/RegistersView.cpp index 20358490..49529dbd 100644 --- a/src/gui/Src/Gui/RegistersView.cpp +++ b/src/gui/Src/Gui/RegistersView.cpp @@ -1880,7 +1880,7 @@ void RegistersView::ModifyFields(QString title, STRING_VALUE_TABLE_t* table, SIZ setRegister(mSelected, (duint)value); } -#define MODIFY_FIELDS_DISPLAY(title, table) ModifyFields(QString("Edit ") + QString(title), (STRING_VALUE_TABLE_t *) & table, SIZE_TABLE(table) ) +#define MODIFY_FIELDS_DISPLAY(title, table) ModifyFields(tr("Edit") + QChar(' ') + QString(title), (STRING_VALUE_TABLE_t *) & table, SIZE_TABLE(table) ) /** * @brief This function displays the appropriate edit dialog according to selected register @@ -1983,11 +1983,7 @@ void RegistersView::displayEditDialog() { errorinput = true; - QMessageBox msg(QMessageBox::Warning, tr("ERROR CONVERTING TO HEX"), tr("ERROR CONVERTING TO HEX")); - msg.setWindowIcon(DIcon("compile-warning.png")); - msg.setParent(this, Qt::Dialog); - msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint)); - msg.exec(); + SimpleWarningBox(this, tr("ERROR CONVERTING TO HEX"), tr("ERROR CONVERTING TO HEX")); } else setRegister(mSelected, fpuvalue); @@ -2000,7 +1996,7 @@ void RegistersView::displayEditDialog() else { WordEditDialog wEditDial(this); - wEditDial.setup(QString("Edit"), (* ((duint*) registerValue(&wRegDumpStruct, mSelected))), sizeof(dsint)); + wEditDial.setup(tr("Edit"), (* ((duint*) registerValue(&wRegDumpStruct, mSelected))), sizeof(dsint)); if(wEditDial.exec() == QDialog::Accepted) //OK button clicked setRegister(mSelected, wEditDial.getVal()); }