aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-05 16:29:16 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-05 16:30:23 +0100
commitfac2c49643ee5122fbeffaeaebbac48e69381bf3 (patch)
tree0607f6f1770b40165f3ceb1e3c60a2d3512b66c7 /qtmips_gui
parentc06242f07721a7d86dc2d9795622d6646ae6c88f (diff)
downloadqtmips-fac2c49643ee5122fbeffaeaebbac48e69381bf3.tar.gz
qtmips-fac2c49643ee5122fbeffaeaebbac48e69381bf3.tar.bz2
qtmips-fac2c49643ee5122fbeffaeaebbac48e69381bf3.zip
Registers dock: clear data when nullptr passed to setup and cleanup
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/registersdock.cpp17
-rw-r--r--qtmips_gui/registersdock.h2
2 files changed, 13 insertions, 6 deletions
diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp
index 5d965ca..12690e2 100644
--- a/qtmips_gui/registersdock.cpp
+++ b/qtmips_gui/registersdock.cpp
@@ -1,8 +1,6 @@
#include "registersdock.h"
RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
- regs = nullptr;
-
scrollarea = new QScrollArea(this);
widg = new QWidget(scrollarea);
layout = new QFormLayout(widg);
@@ -29,14 +27,25 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
}
RegistersDock::~RegistersDock() {
- delete layout;
delete pc, hi, lo;
for (int i = 0; i < 32; i++)
delete gp[i];
+ delete layout;
+ delete widg;
+ delete scrollarea;
}
void RegistersDock::setup(machine::QtMipsMachine *machine) {
- regs = machine->registers();
+ if (machine == nullptr) {
+ // Reset data
+ pc->setText("");
+ hi->setText("");
+ lo->setText("");
+ for (int i = 0; i < 32; i++)
+ gp[i]->setText("");
+ }
+
+ const machine::Registers *regs = machine->registers();
connect(regs, SIGNAL(pc_update(std::uint32_t)), this, SLOT(pc_changed(std::uint32_t)));
connect(regs, SIGNAL(gp_update(std::uint8_t,std::uint32_t)), this, SLOT(gp_changed(std::uint8_t,std::uint32_t)));
connect(regs, SIGNAL(hi_lo_update(bool,std::uint32_t)), this, SLOT(hi_lo_changed(bool,std::uint32_t)));
diff --git a/qtmips_gui/registersdock.h b/qtmips_gui/registersdock.h
index 3504608..8e1de78 100644
--- a/qtmips_gui/registersdock.h
+++ b/qtmips_gui/registersdock.h
@@ -22,8 +22,6 @@ private slots:
void hi_lo_changed(bool hi, std::uint32_t val);
private:
- const machine::Registers *regs;
-
QWidget *widg;
QScrollArea *scrollarea;
QFormLayout *layout;