From 50361206f7fdccc911ae9dc8095f6304fcb9bc95 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Mon, 25 Mar 2019 20:59:38 +0100 Subject: Do not save program view start address when changed due to program executed. Signed-off-by: Pavel Pisa --- qtmips_gui/mainwindow.cpp | 2 +- qtmips_gui/programdock.cpp | 2 ++ qtmips_gui/programdock.h | 1 + qtmips_gui/programtableview.cpp | 24 +++++++++++++++++++----- qtmips_gui/programtableview.h | 3 +++ 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 2c9883d..cf63871 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -259,7 +259,7 @@ void MainWindow::show_symbol_dialog(){ QStringList *symnames = machine->symbol_table()->names(); GoToSymbolDialog *gotosyboldialog = new GoToSymbolDialog(this, *symnames); connect(gotosyboldialog, SIGNAL(program_focus_addr(std::uint32_t)), - program, SIGNAL(focus_addr(std::uint32_t))); + program, SIGNAL(focus_addr_with_save(std::uint32_t))); connect(gotosyboldialog, SIGNAL(memory_focus_addr(std::uint32_t)), memory, SIGNAL(focus_addr(std::uint32_t))); connect(gotosyboldialog, SIGNAL(obtain_value_for_name(std::uint32_t&,QString)), diff --git a/qtmips_gui/programdock.cpp b/qtmips_gui/programdock.cpp index 0466cc2..60a23b0 100644 --- a/qtmips_gui/programdock.cpp +++ b/qtmips_gui/programdock.cpp @@ -97,6 +97,8 @@ ProgramDock::ProgramDock(QWidget *parent, QSettings *settings) : Super(parent) { this, SLOT(set_follow_inst(int))); connect(this, SIGNAL(focus_addr(std::uint32_t)), program_content, SLOT(focus_address(std::uint32_t))); + connect(this, SIGNAL(focus_addr_with_save(std::uint32_t)), + program_content, SLOT(focus_address_with_save(std::uint32_t))); connect(program_content, SIGNAL(doubleClicked(QModelIndex)), program_model, SLOT(toggle_hw_break(QModelIndex))); } diff --git a/qtmips_gui/programdock.h b/qtmips_gui/programdock.h index 56fb1b7..356666f 100644 --- a/qtmips_gui/programdock.h +++ b/qtmips_gui/programdock.h @@ -56,6 +56,7 @@ signals: void machine_setup(machine::QtMipsMachine *machine); void jump_to_pc(std::uint32_t); void focus_addr(std::uint32_t); + void focus_addr_with_save(std::uint32_t); public slots: void set_follow_inst(int); void fetch_inst_addr(std::uint32_t addr); diff --git a/qtmips_gui/programtableview.cpp b/qtmips_gui/programtableview.cpp index b6259dc..a1b7fd2 100644 --- a/qtmips_gui/programtableview.cpp +++ b/qtmips_gui/programtableview.cpp @@ -52,10 +52,12 @@ ProgramTableView::ProgramTableView(QWidget *parent, QSettings *settings) : Super this->settings = settings; initial_address = settings->value("ProgramViewAddr0", 0).toULongLong(); adjust_scroll_pos_in_progress = false; + need_addr0_save = false; } void ProgramTableView::addr0_save_change(std::uint32_t val) { - settings->setValue("ProgramViewAddr0", val); + need_addr0_save = false; + settings->setValue("ProgramViewAddr0", val); } void ProgramTableView::adjustColumnCount() { @@ -148,7 +150,8 @@ void ProgramTableView::adjust_scroll_pos_process() { emit m->update_all(); } while(0); m->get_row_address(address, rowAt(0)); - addr0_save_change(address); + if (need_addr0_save) + addr0_save_change(address); emit address_changed(address); } @@ -172,7 +175,7 @@ void ProgramTableView::resizeEvent(QResizeEvent *event) { } } -void ProgramTableView:: go_to_address(std::uint32_t address) { +void ProgramTableView::go_to_address_priv(std::uint32_t address) { ProgramModel *m = dynamic_cast(model()); int row; if (m == nullptr) @@ -181,22 +184,33 @@ void ProgramTableView:: go_to_address(std::uint32_t address) { scrollTo(m->index(row, 0), QAbstractItemView::PositionAtTop); setCurrentIndex(m->index(row, 1)); - addr0_save_change(address); + if (need_addr0_save) + addr0_save_change(address); emit m->update_all(); } +void ProgramTableView::go_to_address(std::uint32_t address) { + need_addr0_save = true; + go_to_address_priv(address); +} + void ProgramTableView::focus_address(std::uint32_t address) { int row; ProgramModel *m = dynamic_cast(model()); if (m == nullptr) return; if (!m->get_row_for_address(row, address)) - go_to_address(address); + go_to_address_priv(address); if (!m->get_row_for_address(row, address)) return; setCurrentIndex(m->index(row, 3)); } +void ProgramTableView::focus_address_with_save(std::uint32_t address) { + need_addr0_save = true; + focus_address(address); +} + void ProgramTableView::keyPressEvent(QKeyEvent *event) { if(event->matches(QKeySequence::Copy)) { QString text; diff --git a/qtmips_gui/programtableview.h b/qtmips_gui/programtableview.h index 6298d89..f9e0474 100644 --- a/qtmips_gui/programtableview.h +++ b/qtmips_gui/programtableview.h @@ -57,18 +57,21 @@ signals: public slots: void go_to_address(std::uint32_t address); void focus_address(std::uint32_t address); + void focus_address_with_save(std::uint32_t address); protected: void keyPressEvent(QKeyEvent *event); private slots: void adjust_scroll_pos_check(); void adjust_scroll_pos_process(); private: + void go_to_address_priv(std::uint32_t address); void addr0_save_change(std::uint32_t val); void adjustColumnCount(); QSettings *settings; std::uint32_t initial_address; bool adjust_scroll_pos_in_progress; + bool need_addr0_save; }; #endif // PROGRAMTABLEVIEW_H -- cgit v1.2.3