diff options
author | Karel Kočí <cynerd@email.cz> | 2018-01-05 17:36:44 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2018-01-05 17:36:44 +0100 |
commit | cfe13fdc741ae02b473cb30b36f94e3b01f1dad2 (patch) | |
tree | 023bffc77c1dc9e1234b0af5eacf545dae6c7342 /qtmips_gui | |
parent | 11d6ad2a4574e55e6d9aed43d452dcef822a9247 (diff) | |
download | qtmips-cfe13fdc741ae02b473cb30b36f94e3b01f1dad2.tar.gz qtmips-cfe13fdc741ae02b473cb30b36f94e3b01f1dad2.tar.bz2 qtmips-cfe13fdc741ae02b473cb30b36f94e3b01f1dad2.zip |
Implement machine reload
Also this commit changes how we pass machine configuration around in
gui.
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/mainwindow.cpp | 24 | ||||
-rw-r--r-- | qtmips_gui/mainwindow.h | 3 | ||||
-rw-r--r-- | qtmips_gui/newdialog.cpp | 13 |
3 files changed, 28 insertions, 12 deletions
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 65e6469..a476290 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { // Connect signals from menu connect(ui->actionExit, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionNew, SIGNAL(triggered(bool)), this, SLOT(new_machine())); + connect(ui->actionReload, SIGNAL(triggered(bool)), this, SLOT(machine_reload())); connect(ui->actionRegisters, SIGNAL(triggered(bool)), this, SLOT(show_registers())); connect(ui->actionProgram_memory, SIGNAL(triggered(bool)), this, SLOT(show_program())); connect(ui->actionMemory, SIGNAL(triggered(bool)), this, SLOT(show_memory())); @@ -74,12 +75,15 @@ void MainWindow::start() { ndialog->show(); } -void MainWindow::create_core(machine::MachineConfig *config) { +void MainWindow::create_core(const machine::MachineConfig &config) { + // Create machine + machine::QtMipsMachine *new_machine = new machine::QtMipsMachine(&config); + // Remove old machine if (machine != nullptr) delete machine; - // Create machine - machine = new machine::QtMipsMachine(config); + machine = new_machine; + // Create machine view if (corescene != nullptr) delete corescene; @@ -112,6 +116,20 @@ void MainWindow::new_machine() { ndialog->show(); } +void MainWindow::machine_reload() { + machine::MachineConfig cnf(&machine->config()); // We have to make local copy as create_core will delete current machine + try { + create_core(cnf); + } catch (const machine::QtMipsExceptionInput &e) { + QMessageBox msg(this); + msg.setText(e.msg(false)); + msg.setIcon(QMessageBox::Critical); + msg.setDetailedText(e.msg(true)); + msg.setWindowTitle("Error while initializing new machine"); + msg.exec(); + } +} + #define SHOW_HANDLER(NAME) void MainWindow::show_##NAME() { \ show_dockwidget(NAME); \ } \ diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 9431515..1389f21 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -23,13 +23,14 @@ public: ~MainWindow(); void start(); - void create_core(machine::MachineConfig *config); + void create_core(const machine::MachineConfig &config); bool configured(); public slots: // Actions signals void new_machine(); + void machine_reload(); void show_registers(); void show_program(); void show_memory(); diff --git a/qtmips_gui/newdialog.cpp b/qtmips_gui/newdialog.cpp index 062eb2d..cc23e2f 100644 --- a/qtmips_gui/newdialog.cpp +++ b/qtmips_gui/newdialog.cpp @@ -41,9 +41,9 @@ void NewDialog::cancel() { void NewDialog::create() { MainWindow *prnt = (MainWindow*)parent(); - machine::MachineConfig *mc = new machine::MachineConfig(); - mc->set_elf(ui->elf_file->text()); - mc->set_pipelined(ui->pipelined->isChecked()); + machine::MachineConfig mc; + mc.set_elf(ui->elf_file->text()); + mc.set_pipelined(ui->pipelined->isChecked()); // TODO other settings try { @@ -52,18 +52,15 @@ void NewDialog::create() { QMessageBox msg(this); msg.setText(e.msg(false)); msg.setIcon(QMessageBox::Critical); - msg.setToolTip("Please check that ELF executable realy exists and is in correct format."); + msg.setToolTip("Please check that ELF executable really exists and is in correct format."); msg.setDetailedText(e.msg(true)); msg.setWindowTitle("Error while initializing new machine"); msg.exec(); - goto cleanup; + return; } store_settings(); // Save to settings this->close(); - -cleanup: - delete mc; } void NewDialog::browse_elf() { |