diff options
author | bd <bdunahu@operationnull.com> | 2025-04-26 16:38:07 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-26 16:38:07 -0400 |
commit | d449750f789076459de8d47c2960a1279e543c32 (patch) | |
tree | 7e2f5fd8f6f0ba267b7855ee4bb4bd181255c393 | |
parent | 6382d595cf947eb54249ff5fea20d8eb073ef3c1 (diff) |
Fix some issues in GUI looking for memory leak
-rw-r--r-- | gui/gui.cc | 19 | ||||
-rw-r--r-- | gui/gui.h | 4 | ||||
-rw-r--r-- | gui/util.cc | 5 |
3 files changed, 16 insertions, 12 deletions
@@ -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); @@ -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; |