From d449750f789076459de8d47c2960a1279e543c32 Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 26 Apr 2025 16:38:07 -0400 Subject: Fix some issues in GUI looking for memory leak --- gui/gui.cc | 19 +++++++++++-------- gui/gui.h | 4 ++-- gui/util.cc | 5 +++-- 3 files changed, 16 insertions(+), 12 deletions(-) (limited to 'gui') 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 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; -- cgit v1.2.3