Fix #1186 & UI last instance error (#1188)

* Handle Arrays & Objects differently

* Fix UI error, if "last instance used" does not longer exist
This commit is contained in:
LordGrey 2021-02-17 12:29:53 +01:00 committed by GitHub
parent 77262adf3b
commit 9e281b2347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 762 additions and 859 deletions

File diff suppressed because it is too large Load Diff

View File

@ -120,7 +120,15 @@ QJsonObject SettingsManager::getSettings() const
for(const auto & key : _qconfig.keys())
{
//Read all records from database to ensure that global settings are read across instances
config.insert(key, _sTable->getSettingsRecord(key).object());
QJsonDocument doc = _sTable->getSettingsRecord(key);
if(doc.isArray())
{
config.insert(key, doc.array());
}
else
{
config.insert(key, doc.object());
}
}
return config;
}
@ -245,5 +253,18 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
Debug(_log,"LED Layout migrated");
}
}
if (config.contains("grabberV4L2"))
{
QJsonObject newGrabberV4L2Config = config["grabberV4L2"].toObject();
if (newGrabberV4L2Config.contains("encoding_format"))
{
newGrabberV4L2Config.remove("encoding_format");
config["grabberV4L2"] = newGrabberV4L2Config;
migrated = true;
Debug(_log, "GrabberV4L2 Layout migrated");
}
}
return migrated;
}