From 8b2ded1b791df284306551e48233c43afece2e8e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 13 May 2015 13:16:06 -0700 Subject: [PATCH] handle case where QVariant is not QVariantMap --- domain-server/src/DomainServerSettingsManager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/domain-server/src/DomainServerSettingsManager.cpp b/domain-server/src/DomainServerSettingsManager.cpp index 5539b6b564..963871c9b9 100644 --- a/domain-server/src/DomainServerSettingsManager.cpp +++ b/domain-server/src/DomainServerSettingsManager.cpp @@ -288,7 +288,16 @@ void DomainServerSettingsManager::updateSetting(const QString& key, const QJsonV settingMap[key] = QVariantMap(); } - QVariantMap& thisMap = *reinterpret_cast(settingMap[key].data()); + QVariant& possibleMap = settingMap[key]; + + if (!possibleMap.canConvert(QMetaType::QVariantMap)) { + // if this isn't a map then we need to make it one, otherwise we're about to crash + qDebug() << "Value at" << key << "was not the expected QVariantMap while updating DS settings" + << "- removing existing value and making it a QVariantMap"; + possibleMap = QVariantMap(); + } + + QVariantMap& thisMap = *reinterpret_cast(possibleMap.data()); foreach(const QString childKey, newValue.toObject().keys()) { QJsonObject childDescriptionObject = settingDescription;