Read the default conductor width from the settings as a decimal

ConductorProperties::toSettings() writes the conductor width with
QString::number(cond_size), e.g. "1.4", and fromSettings() read it back
with toInt(), which is 0 for any value that is not a whole number. A
default width of 1.4 set in the configuration became 0 on the next
start, so every new conductor was drawn with a pen of width 0.

Read it with toDouble(), and fall back to 1 when the stored value is
not a positive finite number (a hand-edited or truncated settings
file), as the other fallbacks in fromSettings() do.

No file-format change: this is the settings file only; the project
file's condsize attribute was already read with toDouble().

Tests: tst_conductorsizesetting compiles conductorproperties.cpp alone
and round-trips 2, 1.4, 0.4, 61.3 and 61.7 through toSettings() and
fromSettings() in a QSettings scope of its own; text, 0, -1, nan, inf
and a missing value give 1. Nine of the cases fail on master.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Beat Hangartner <beat@hangartners.ch>
This commit is contained in:
Beat Hangartner
2026-10-07 21:04:22 +02:00
parent ef795a21e5
commit 7933e89dc0
3 changed files with 130 additions and 1 deletions
+4 -1
View File
@@ -436,7 +436,10 @@ void ConductorProperties::fromSettings(QSettings &settings, const QString &prefi
m_wire_color = settings.value(prefix + "conductor_color", "").toString();
m_wire_section = settings.value(prefix + "conductor_section", "").toString();
text_size = settings.value(prefix + "textsize", "7").toInt();
cond_size = settings.value(prefix + "size", "1").toInt();
// Saved with QString::number(cond_size): a decimal such as 1.4,
// which toInt() would read as 0.
cond_size = settings.value(prefix + "size", "1").toDouble();
if (!qIsFinite(cond_size) || cond_size <= 0) cond_size = 1;
m_show_text = settings.value(prefix + "displaytext", true).toBool();
m_one_text_per_folio = settings.value(prefix + "onetextperfolio", false).toBool();
verti_rotate_text = settings.value((prefix + "vertirotatetext"), "270").toDouble();