aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-05 17:34:25 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-05 17:34:25 +0100
commit11d6ad2a4574e55e6d9aed43d452dcef822a9247 (patch)
tree5c94370e50bf2c4038d0016ea113cf1b85de7913
parent8025ccc2091228f9d089532852a2380f5f5a80b1 (diff)
downloadqtmips-11d6ad2a4574e55e6d9aed43d452dcef822a9247.tar.gz
qtmips-11d6ad2a4574e55e6d9aed43d452dcef822a9247.tar.bz2
qtmips-11d6ad2a4574e55e6d9aed43d452dcef822a9247.zip
Remove old scene in more appropriate place
Previous implementation was pretty confusing. There was no delete on level where variable override was happening. The object removal was implemented inside constructor. Very nasty.
-rw-r--r--qtmips_gui/coreview.cpp5
-rw-r--r--qtmips_gui/mainwindow.cpp3
2 files changed, 3 insertions, 5 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 1750cc1..7210f1c 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -36,9 +36,4 @@ CoreViewScene::CoreViewScene(CoreView *view, machine::QtMipsMachine *machine) :
alu->setPos(200, 100);
pc_multiplexer->setPos(60, 100);
pc_multiplexer->set(2);
-
- QGraphicsScene *old_scene = view->scene();
- view->setScene(this);
- if (old_scene != nullptr)
- delete old_scene;
}
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index a286f0d..65e6469 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -81,7 +81,10 @@ void MainWindow::create_core(machine::MachineConfig *config) {
// Create machine
machine = new machine::QtMipsMachine(config);
// Create machine view
+ if (corescene != nullptr)
+ delete corescene;
corescene = new CoreViewScene(coreview, machine);
+ coreview->setScene(corescene);
set_speed(); // Update machine speed to current settings