Always get int settings as integers and static cast to unsigned
if we use .toUInt on a negative integer (which represents a hex value), conversion fails.
MODIFY
src/cachesim/cacheplotwidget.cpp
src/cachesim/cacheplotwidget.cpp
@@ -281,7 +281,7 @@ std::map<CachePlotWidget::Variable, QList<QPoint>> CachePlotWidget::gatherData(u
// Gather data up until the end of the trace or the maximum plotted cycles
unsigned cycles = ProcessorHandler::getProcessor()->getCycleCount();
- const unsigned maxCycles = RipesSettings::value(RIPES_SETTING_CACHE_MAXCYCLES).toUInt();
+ const unsigned maxCycles = RipesSettings::value(RIPES_SETTING_CACHE_MAXCYCLES).toInt();
if (fromCycle > maxCycles) {
return {};
}
@@ -472,7 +472,7 @@ void CachePlotWidget::updateRatioPlot() {
void CachePlotWidget::updatePlotWarningButton() {
m_ui->maxCyclesButton->setVisible(m_lastCyclePlotted >=
- RipesSettings::value(RIPES_SETTING_CACHE_MAXCYCLES).toUInt());
+ RipesSettings::value(RIPES_SETTING_CACHE_MAXCYCLES).toInt());
}
void CachePlotWidget::resetRatioPlot() {

MODIFY
src/editor/codeeditor.cpp
src/editor/codeeditor.cpp
@@ -102,7 +102,7 @@ static const QStringList c_closingBrackets = QStringList{")", "}", "]"};
static const QStringList c_indentStartCharacters = QStringList{":", "(", "{", "["};
void CodeEditor::keyPressEvent(QKeyEvent* e) {
- const unsigned indentAmt = RipesSettings::value(RIPES_SETTING_INDENTAMT).toUInt();
+ const unsigned indentAmt = RipesSettings::value(RIPES_SETTING_INDENTAMT).toInt();
const auto preCursorText = textCursor().block().text().left(textCursor().positionInBlock());
const auto postCursorText =

MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -106,7 +106,7 @@ EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent)
RipesSettings::setValue(RIPES_SETTING_INPUT_TYPE, m_currentSourceType);
});
- switch (RipesSettings::value(RIPES_SETTING_INPUT_TYPE).toUInt()) {
+ switch (RipesSettings::value(RIPES_SETTING_INPUT_TYPE).toInt()) {
case SourceType::Assembly: {
m_ui->setAssemblyInput->toggle();
break;

MODIFY
src/io/iomanager.cpp
src/io/iomanager.cpp
@@ -30,7 +30,7 @@ QString IOManager::cSymbolsHeaderpath() const {
AInt IOManager::nextPeripheralAddress() const {
AInt base = 0;
if (m_periphMMappings.empty()) {
- base = RipesSettings::value(RIPES_SETTING_PERIPHERALS_START).toUInt();
+ base = static_cast<unsigned>(RipesSettings::value(RIPES_SETTING_PERIPHERALS_START).toInt());
} else {
for (const auto& periph : m_periphMMappings) {
if (periph.second.end() > base) {

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -33,9 +33,9 @@ ProcessorHandler::ProcessorHandler() {
// The m_procStateChangeTimer limits maximum frequency of which the procStateChangedNonRun is emitted.
m_procStateChangeTimer.setSingleShot(true);
- m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
+ m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toInt());
connect(RipesSettings::getObserver(RIPES_SETTING_UIUPDATEPS), &SettingObserver::modified, this, [=] {
- m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
+ m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toInt());
});
connect(&m_procStateChangeTimer, &QTimer::timeout, this, [=] {
@@ -60,7 +60,7 @@ ProcessorHandler::ProcessorHandler() {
[=](const auto& size) { m_currentProcessor->setMaxReverseCycles(size.toUInt()); });
// Update VSRTL reverse stack size to reflect current settings
- m_currentProcessor->setMaxReverseCycles(RipesSettings::value(RIPES_SETTING_REWINDSTACKSIZE).toUInt());
+ m_currentProcessor->setMaxReverseCycles(RipesSettings::value(RIPES_SETTING_REWINDSTACKSIZE).toInt());
// Reset request handling
connect(RipesSettings::getObserver(RIPES_GLOBALSIGNAL_REQRESET), &SettingObserver::modified, this,

MODIFY
src/processorselectiondialog.cpp
src/processorselectiondialog.cpp
@@ -76,7 +76,7 @@ ProcessorSelectionDialog::ProcessorSelectionDialog(QWidget* parent)
if (selectedItem != nullptr) {
// Select the processor and layout which is currently active
m_ui->processors->setCurrentItem(selectedItem);
- unsigned layoutID = RipesSettings::value(RIPES_SETTING_PROCESSOR_LAYOUT_ID).toUInt();
+ unsigned layoutID = RipesSettings::value(RIPES_SETTING_PROCESSOR_LAYOUT_ID).toInt();
if (layoutID >= ProcessorRegistry::getDescription(ProcessorHandler::getID()).layouts.size()) {
layoutID = 0;
}

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -102,10 +102,10 @@ ProcessorTab::ProcessorTab(QToolBar* controlToolbar, QToolBar* additionalToolbar
// Setup statistics update timer - this timer is distinct from the ProcessorHandler's update timer, given that it
// needs to run during 'running' the processor.
m_statUpdateTimer = new QTimer(this);
- m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
+ m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toInt());
connect(m_statUpdateTimer, &QTimer::timeout, this, &ProcessorTab::updateStatistics);
connect(RipesSettings::getObserver(RIPES_SETTING_UIUPDATEPS), &SettingObserver::modified,
- [=] { m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt()); });
+ [=] { m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toInt()); });
// Connect changes in VSRTL reversible stack size to checking whether the simulator is reversible
connect(RipesSettings::getObserver(RIPES_SETTING_REWINDSTACKSIZE), &SettingObserver::modified,

MODIFY
src/settingsdialog.cpp
src/settingsdialog.cpp
@@ -53,7 +53,9 @@ std::pair<QLabel*, T_TriggerWidget*> createSettingsWidgets(const QString& settin
widget->connect(widget, QOverload<int>::of(&QSpinBox::valueChanged), settingObserver,
&SettingObserver::setValue);
} else if constexpr (std::is_same<T_EditWidget, HexSpinBox>()) {
- widget->setValue(settingObserver->value().toUInt());
+ // The hex value is stored as an int, so get the int and static cast it to unsigned.
+ unsigned uValue = static_cast<unsigned>(settingObserver->value().toInt());
+ widget->setValue(uValue);
widget->connect(widget, QOverload<int>::of(&QSpinBox::valueChanged), settingObserver,
&SettingObserver::setValue);
} else if constexpr (std::is_same<T_EditWidget, QLineEdit>()) {

Always get int settings as integers and static cast to unsigned

if we use .toUInt on a negative integer (which represents a hex value), conversion fails.