aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui/mainwindow.cpp')
-rw-r--r--qtmips_gui/mainwindow.cpp24
1 files changed, 21 insertions, 3 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); \
} \