From e4367ef6af3a3cbdf44af16c5b5f9d598d682b2e Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sun, 18 Nov 2018 16:00:34 -0500 Subject: [PATCH] CP - If a metadata name is not found in the Json file, issue an error and exit. It would crash if let proceed. --- src/Settings/SettingsGroup.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Settings/SettingsGroup.cc b/src/Settings/SettingsGroup.cc index 0e56bdfb4..d93ed4c9f 100644 --- a/src/Settings/SettingsGroup.cc +++ b/src/Settings/SettingsGroup.cc @@ -11,19 +11,24 @@ #include "QGCCorePlugin.h" #include "QGCApplication.h" +static const char* kJsonFile = ":/json/%1.SettingsGroup.json"; + SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent) : QObject (parent) + , _visible (qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name)) , _name (name) , _settingsGroup(settingsGroup) - , _visible (qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(_name)) { - QString jsonNameFormat(":/json/%1.SettingsGroup.json"); - - _nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(_name), this); + _nameToMetaDataMap = FactMetaData::createMapFromJsonFile(QString(kJsonFile).arg(name), this); } SettingsFact* SettingsGroup::_createSettingsFact(const QString& factName) { - return new SettingsFact(_settingsGroup, _nameToMetaDataMap[factName], this); + FactMetaData* m = _nameToMetaDataMap[factName]; + if(!m) { + qCritical() << "Fact name " << factName << "not found in" << QString(kJsonFile).arg(_name); + exit(-1); + } + return new SettingsFact(_settingsGroup, m, this); } -- 2.22.0