From 355a85a1fc5102ea2b1801cd88a1a9a9178fd21f Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Wed, 22 May 2019 19:59:10 -0400 Subject: [PATCH] Tweak Session YAML output to print sane floats instead of full precision. --- oscar/tests/sessiontests.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/oscar/tests/sessiontests.cpp b/oscar/tests/sessiontests.cpp index f5491d85..421e3a29 100644 --- a/oscar/tests/sessiontests.cpp +++ b/oscar/tests/sessiontests.cpp @@ -174,7 +174,14 @@ void SessionToYaml(QString filepath, Session* session) QList keys = session->settings.keys(); std::sort(keys.begin(), keys.end()); for (QList::iterator key = keys.begin(); key != keys.end(); key++) { - out << " " << settingChannel(*key) << ": " << session->settings[*key].toString() << endl; + QVariant & value = session->settings[*key]; + QString s; + if ((QMetaType::Type) value.type() == QMetaType::Float) { + s = QString::number(value.toFloat()); // Print the shortest accurate representation rather than QVariant's full precision. + } else { + s = value.toString(); + } + out << " " << settingChannel(*key) << ": " << s << endl; } out << " events:" << endl;