forked from qt-creator/qt-creator
Environment: Avoid calling throwing functions
We do not declare any `throws` and this way we can also use QTC_GUARD Coverity-Id: 1586292 Change-Id: I75efd625e096bf02c1f7a85b9573bd134a9fb020 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -433,17 +433,26 @@ const NameValueDictionary &Environment::resolved() const
|
|||||||
m_dict = Environment::systemEnvironment().toDictionary();
|
m_dict = Environment::systemEnvironment().toDictionary();
|
||||||
m_fullDict = true;
|
m_fullDict = true;
|
||||||
break;
|
break;
|
||||||
case SetFixedDictionary:
|
case SetFixedDictionary: {
|
||||||
m_dict = std::get<SetFixedDictionary>(item);
|
const auto dict = std::get_if<SetFixedDictionary>(&item);
|
||||||
|
if (QTC_GUARD(dict)) {
|
||||||
|
m_dict = *dict;
|
||||||
m_fullDict = true;
|
m_fullDict = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case SetValue: {
|
case SetValue: {
|
||||||
auto [key, value, enabled] = std::get<SetValue>(item);
|
const auto setvalue = std::get_if<SetValue>(&item);
|
||||||
|
if (QTC_GUARD(setvalue)) {
|
||||||
|
auto [key, value, enabled] = *setvalue;
|
||||||
m_dict.set(key, value, enabled);
|
m_dict.set(key, value, enabled);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SetFallbackValue: {
|
case SetFallbackValue: {
|
||||||
auto [key, value] = std::get<SetFallbackValue>(item);
|
const auto fallbackvalue = std::get_if<SetFallbackValue>(&item);
|
||||||
|
if (QTC_GUARD(fallbackvalue)) {
|
||||||
|
auto [key, value] = *fallbackvalue;
|
||||||
if (m_fullDict) {
|
if (m_fullDict) {
|
||||||
if (m_dict.value(key).isEmpty())
|
if (m_dict.value(key).isEmpty())
|
||||||
m_dict.set(key, value, true);
|
m_dict.set(key, value, true);
|
||||||
@@ -451,13 +460,19 @@ const NameValueDictionary &Environment::resolved() const
|
|||||||
QTC_ASSERT(false, qDebug() << "operating on partial dictionary");
|
QTC_ASSERT(false, qDebug() << "operating on partial dictionary");
|
||||||
m_dict.set(key, value, true);
|
m_dict.set(key, value, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UnsetValue:
|
case UnsetValue: {
|
||||||
m_dict.unset(std::get<UnsetValue>(item));
|
const auto unsetvalue = std::get_if<UnsetValue>(&item);
|
||||||
|
if (QTC_GUARD(unsetvalue))
|
||||||
|
m_dict.unset(*unsetvalue);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PrependOrSet: {
|
case PrependOrSet: {
|
||||||
auto [key, value, sep] = std::get<PrependOrSet>(item);
|
const auto prependorset = std::get_if<PrependOrSet>(&item);
|
||||||
|
if (QTC_GUARD(prependorset)) {
|
||||||
|
auto [key, value, sep] = *prependorset;
|
||||||
QTC_ASSERT(!key.contains('='), return m_dict);
|
QTC_ASSERT(!key.contains('='), return m_dict);
|
||||||
const auto it = m_dict.findKey(key);
|
const auto it = m_dict.findKey(key);
|
||||||
if (it == m_dict.m_values.end()) {
|
if (it == m_dict.m_values.end()) {
|
||||||
@@ -468,10 +483,13 @@ const NameValueDictionary &Environment::resolved() const
|
|||||||
if (!it.value().first.startsWith(toPrepend))
|
if (!it.value().first.startsWith(toPrepend))
|
||||||
it.value().first.prepend(toPrepend);
|
it.value().first.prepend(toPrepend);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AppendOrSet: {
|
case AppendOrSet: {
|
||||||
auto [key, value, sep] = std::get<AppendOrSet>(item);
|
const auto appendorset = std::get_if<AppendOrSet>(&item);
|
||||||
|
if (QTC_GUARD(appendorset)) {
|
||||||
|
auto [key, value, sep] = *appendorset;
|
||||||
QTC_ASSERT(!key.contains('='), return m_dict);
|
QTC_ASSERT(!key.contains('='), return m_dict);
|
||||||
const auto it = m_dict.findKey(key);
|
const auto it = m_dict.findKey(key);
|
||||||
if (it == m_dict.m_values.end()) {
|
if (it == m_dict.m_values.end()) {
|
||||||
@@ -482,11 +500,15 @@ const NameValueDictionary &Environment::resolved() const
|
|||||||
if (!it.value().first.endsWith(toAppend))
|
if (!it.value().first.endsWith(toAppend))
|
||||||
it.value().first.append(toAppend);
|
it.value().first.append(toAppend);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Modify: {
|
case Modify: {
|
||||||
EnvironmentItems items = std::get<Modify>(item);
|
const auto modify = std::get_if<Modify>(&item);
|
||||||
|
if (QTC_GUARD(modify)) {
|
||||||
|
EnvironmentItems items = *modify;
|
||||||
m_dict.modify(items);
|
m_dict.modify(items);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SetupEnglishOutput:
|
case SetupEnglishOutput:
|
||||||
|
Reference in New Issue
Block a user