kscreenintegration: don't access optionals that may be missing a value

This commit is contained in:
Xaver Hugl 2023-03-31 01:29:21 +02:00 committed by Vlad Zahorodnii
parent f70be829c6
commit 4f48258269

View file

@ -242,14 +242,14 @@ std::optional<std::pair<OutputConfiguration, QVector<Output *>>> readOutputConfi
} }
bool allDisabled = std::all_of(outputs.begin(), outputs.end(), [&cfg](const auto &output) { bool allDisabled = std::all_of(outputs.begin(), outputs.end(), [&cfg](const auto &output) {
return !cfg.changeSet(output)->enabled; return !cfg.changeSet(output)->enabled.value_or(output->isEnabled());
}); });
if (allDisabled) { if (allDisabled) {
qCWarning(KWIN_CORE) << "KScreen config would disable all outputs!"; qCWarning(KWIN_CORE) << "KScreen config would disable all outputs!";
return std::nullopt; return std::nullopt;
} }
std::erase_if(outputOrder, [&cfg](const auto &pair) { std::erase_if(outputOrder, [&cfg](const auto &pair) {
return !cfg.constChangeSet(pair.second)->enabled; return !cfg.constChangeSet(pair.second)->enabled.value_or(pair.second->isEnabled());
}); });
std::sort(outputOrder.begin(), outputOrder.end(), [](const auto &left, const auto &right) { std::sort(outputOrder.begin(), outputOrder.end(), [](const auto &left, const auto &right) {
if (left.first == right.first) { if (left.first == right.first) {