From 41b53d7a7f1c65a1ad4e3edefaf0dbc2cd4b193a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 31 Dec 2019 15:39:17 +1100 Subject: [PATCH] correctly upconvert the DefaultSequenceFrameRate from a legacy config file --- app/config/config.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/config/config.cpp b/app/config/config.cpp index f3da4d484..6be80212c 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -96,6 +96,9 @@ void Config::Load() current_config_.SetDefaults(); QXmlStreamReader reader(&config_file); + + QString config_version; + while (!reader.atEnd()) { reader.readNext(); @@ -111,9 +114,35 @@ void Config::Load() if (key == "Configuration") { // First element, ignore } else if (key == "Version") { + config_version = value; + if (!value.contains(".")) { - qDebug() << "This is a 0.1.x config file, upconvert"; + qDebug() << "CONFIG: This is a 0.1.x config file, upconvert"; } + } else if (key == "DefaultSequenceFrameRate" && !config_version.contains(".")) { + // 0.1.x stored this value as a float while we now use rationals, we'll use a heuristic to find the closest + // supported rational + qDebug() << " CONFIG: Finding closest match to" << value; + + double config_fr = value.toDouble(); + + QList supported_frame_rates = Core::SupportedFrameRates(); + + rational match = supported_frame_rates.first(); + double match_diff = qAbs(match.toDouble() - config_fr); + + for (int i=1;i