From 66495f9c79cc74e1753871fc43cb68d23a1ffa79 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 30 Mar 2023 17:30:06 +0200 Subject: [PATCH] wayland/outputmanagement: don't access nullptr changesets Since 6b8e08dfa962ca49f6b004b524ade5b33a78b575, changesets can be nullptr --- src/wayland/outputmanagement_v2_interface.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/wayland/outputmanagement_v2_interface.cpp b/src/wayland/outputmanagement_v2_interface.cpp index bed5dcd648..a17a71b9be 100644 --- a/src/wayland/outputmanagement_v2_interface.cpp +++ b/src/wayland/outputmanagement_v2_interface.cpp @@ -266,7 +266,12 @@ void OutputConfigurationV2Interface::kde_output_configuration_v2_apply(Resource const auto allOutputs = kwinApp()->outputBackend()->outputs(); const bool allDisabled = !std::any_of(allOutputs.begin(), allOutputs.end(), [this](const auto &output) { - return config.constChangeSet(output)->enabled; + const auto changeset = config.constChangeSet(output); + if (changeset && changeset->enabled.has_value()) { + return *changeset->enabled; + } else { + return output->isEnabled(); + } }); if (allDisabled) { qCWarning(KWIN_CORE) << "Disabling all outputs through configuration changes is not allowed"; @@ -285,7 +290,12 @@ void OutputConfigurationV2Interface::kde_output_configuration_v2_apply(Resource return; } outputOrder.erase(std::remove_if(outputOrder.begin(), outputOrder.end(), [this](const auto &pair) { - return !config.constChangeSet(pair.second->handle())->enabled; + const auto changeset = config.constChangeSet(pair.second->handle()); + if (changeset && changeset->enabled.has_value()) { + return *changeset->enabled; + } else { + return pair.second->handle()->isEnabled(); + } }), outputOrder.end()); std::sort(outputOrder.begin(), outputOrder.end(), [](const auto &pair1, const auto &pair2) {