Only clear preset combobox when user manually edits config state
MODIFY
src/cachesim/cacheconfigwidget.cpp
src/cachesim/cacheconfigwidget.cpp
@@ -99,7 +99,7 @@ void CacheConfigWidget::setupPresets() {
connect(m_ui->presets, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index) {
const CacheSim::CachePreset preset = qvariant_cast<CacheSim::CachePreset>(m_ui->presets->itemData(index));
-
+ m_justSetPreset = true;
m_cache->setPreset(preset);
});
}
@@ -116,7 +116,10 @@ void CacheConfigWidget::handleConfigurationChanged() {
setEnumIndex(m_ui->wrMiss, m_cache->getWriteAllocPolicy());
setEnumIndex(m_ui->replacementPolicy, m_cache->getReplacementPolicy());
+ if (!m_justSetPreset) {
m_ui->presets->setCurrentIndex(-1);
+ }
+ m_justSetPreset = false;
std::for_each(m_configItems.begin(), m_configItems.end(), [](QObject* o) { o->blockSignals(false); });

MODIFY
src/cachesim/cacheconfigwidget.h
src/cachesim/cacheconfigwidget.h
@@ -34,6 +34,14 @@ private:
CacheSim* m_cache;
Ui::CacheConfigWidget* m_ui = nullptr;
std::vector<QObject*> m_configItems;
+
+ /**
+ * @brief m_justSetPreset
+ * Small helper flag for not erasing the text displaying the currently set preset. When false, this ensures that the
+ * preset combo box is cleared when the user makes changes to the current cache configuration; such that we do not
+ * give the impression that the preset is still in effect after a configuration change.
+ */
+ bool m_justSetPreset = false;
};
} // namespace Ripes

Only clear preset combobox when user manually edits config state