Base: QuantityFormat: avoid storing formatting defaults

User defined precision and fractional inch are stored on QuantityFormat
construction making changes persistent to object life time.
Change that so until not explicitely overriden, user defined values
are always returned.

Co-authored-by: Matthias Danner <28687794+matthiasdanner@users.noreply.github.com>
This commit is contained in:
Ladislav Michl
2025-09-02 23:17:22 +02:00
parent 0278a1298d
commit a5f039dd6a
10 changed files with 42 additions and 29 deletions

View File

@@ -208,9 +208,7 @@ PyObject* UnitsApi::sToNumber(PyObject* /*self*/, PyObject* args)
}
bool ok {};
QuantityFormat qf;
qf.format = QuantityFormat::toFormat(format[0], &ok);
qf.precision = decimals;
QuantityFormat qf {QuantityFormat::toFormat(format[0], &ok), decimals};
if (!ok) {
PyErr_SetString(PyExc_ValueError, "Invalid format string");