Fix issue #103: refresh disam on CTRL+r

Adds a QShortcut to refresh the disasm editor. To make this work the
default parameter of the slot MemoryWidget::refreshDisasm() had to be
defined in the header/at declaration point, else the connect failed.
This commit is contained in:
ballessay 2017-04-09 17:37:54 +02:00 committed by Duncan Ogilvie
parent fa62c667ca
commit aa01212053
2 changed files with 10 additions and 5 deletions

View File

@ -171,6 +171,11 @@ MemoryWidget::MemoryWidget(MainWindow *main) :
connect(back_shortcut, SIGNAL(activated()), this, SLOT(seek_back()));
back_shortcut->setContext(Qt::WidgetShortcut);
// CTRL + R to refresh the disasm
QShortcut* refresh_shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), ui->disasTextEdit_2);
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshDisasm()));
refresh_shortcut->setContext(Qt::WidgetShortcut);
// Control Disasm and Hex scroll to add more contents
connect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
connect(this->hexASCIIText->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(hexScrolled()));
@ -449,8 +454,8 @@ void MemoryWidget::disasmScrolled()
connect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
}
void MemoryWidget::refreshDisasm(QString off = "") {
void MemoryWidget::refreshDisasm(const QString &offset)
{
// we must store those ranges somewhere, to handle scroll
ut64 addr = this->main->core->core->offset;
int length = this->main->core->core->num->value;
@ -459,8 +464,8 @@ void MemoryWidget::refreshDisasm(QString off = "") {
disconnect(this->disasTextEdit->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(disasmScrolled()));
// Get disas at offset
if (off != "") {
this->main->core->cmd("s " + off);
if (!offset.isEmpty()) {
this->main->core->cmd("s " + offset);
} else {
// Get current offset
QTextCursor tc = this->disasTextEdit->textCursor();

View File

@ -56,7 +56,7 @@ public slots:
void replaceTextDisasm(QString txt);
void refreshDisasm(QString off);
void refreshDisasm(const QString &offset = QString());
void refreshHexdump(QString where=0);