summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-26 16:38:07 -0400
committerbd <bdunahu@operationnull.com>2025-04-26 16:38:07 -0400
commitd449750f789076459de8d47c2960a1279e543c32 (patch)
tree7e2f5fd8f6f0ba267b7855ee4bb4bd181255c393 /gui
parent6382d595cf947eb54249ff5fea20d8eb073ef3c1 (diff)
Fix some issues in GUI looking for memory leak
Diffstat (limited to 'gui')
-rw-r--r--gui/gui.cc19
-rw-r--r--gui/gui.h4
-rw-r--r--gui/util.cc5
3 files changed, 16 insertions, 12 deletions
diff --git a/gui/gui.cc b/gui/gui.cc
index 2555435..7df1bfc 100644
--- a/gui/gui.cc
+++ b/gui/gui.cc
@@ -349,28 +349,31 @@ void GUI::make_tabs(int num)
ui->storage->clear();
- this->tab_boxes.clear();
qDeleteAll(this->tab_boxes);
+ this->tab_boxes.clear();
for (i = 0; i < num; ++i) {
if (i == 0) {
n = "Registers";
e = new StorageView(0, this);
- } else if (i == 1) {
+ } else if (i == num - 1) {
n = "DRAM";
- e = new StorageView(MEM_LINES, this);
+ e = new StorageView(4, this);
} else {
- n = QString("L%1").arg(i - 1);
+ n = QString("L%1").arg(i);
e = new StorageView(
- cache_size_mapper(this->curr_cache_levels, i), this);
+ // cache_size_mapper(this->curr_cache_levels-1, i-1)
+ 4, this);
}
+ std::cout << "total levels: " << num << ":"
+ << this->curr_cache_levels - 1 << " level: " << i
+ << std::endl;
- t = new QTableView;
+ t = new QTableView(ui->storage);
t->setModel(e);
d = new DigitLabelDelegate(t);
- connect(
- this, &GUI::hex_toggled, e, &StorageView::set_hex_display);
+ connect(this, &GUI::hex_toggled, e, &StorageView::set_hex_display);
connect(
this, &GUI::hex_toggled, d, &DigitLabelDelegate::set_hex_display);
diff --git a/gui/gui.h b/gui/gui.h
index 10c8f67..3db88ff 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -99,12 +99,12 @@ class GUI : public QMainWindow
/**
* Indicates if the program has been initialized.
*/
- bool ready;
+ bool ready = false;
/**
* The current number of cache levels.
*/
- int curr_cache_levels;
+ int curr_cache_levels = 0;
/**
* The list of storage displays.
diff --git a/gui/util.cc b/gui/util.cc
index 72c0d87..21bf0be 100644
--- a/gui/util.cc
+++ b/gui/util.cc
@@ -1,16 +1,17 @@
#include "util.h"
+#include "definitions.h"
#include <QString>
int cache_size_mapper(int total_levels, int level)
{
const int y_min = 4;
- const int y_max = 12;
+ const int y_max = MEM_LINES - 2;
double f, r;
if (total_levels <= 1)
return 8;
- f = level / total_levels;
+ f = level / (double)total_levels;
r = y_min + f * (y_max - y_min);
return r;