fix numeric unit conversion in widget

This commit is contained in:
AndreaRigoni
2026-03-27 15:17:54 +00:00
parent 038c6f99f4
commit e40cc77a5f

View File

@@ -45,7 +45,7 @@ double parseWithUnits(const QString& text, double* factorOut, QString* suffixOut
double num = match.captured(1).toDouble();
QString unit = match.captured(3);
double factor = 1.0;
double factor = factorOut ? *factorOut : 1.0;
if (!unit.isEmpty()) {
QString u = unit.startsWith('_') ? unit.mid(1) : unit;
@@ -101,10 +101,6 @@ void UnitLineEdit::onEditingFinished() {
double factor = m_Factor;
QString suffix = m_Suffix;
double parsedVal = parseWithUnits(text(), &factor, &suffix);
if (!suffix.isEmpty()) {
m_Suffix = suffix;
m_Factor = factor;
}
if (m_IsInteger) {
parsedVal = std::round(parsedVal);
}