From fde1393076359ec53a5a71fe5bcb9b8c4d45d2e5 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 13 Oct 2023 17:41:44 +0200 Subject: [PATCH] outputconfigurationstore: invalidate duplicate output entries The configuration file may contain entries that have the same output identifiers if there's a bug in the implementation. To repair the config, this commit checks for duplicate entries in the output list and removes them when loading the config file. --- src/outputconfigurationstore.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/outputconfigurationstore.cpp b/src/outputconfigurationstore.cpp index e13a88b668..4820a77a58 100644 --- a/src/outputconfigurationstore.cpp +++ b/src/outputconfigurationstore.cpp @@ -555,6 +555,18 @@ void OutputConfigurationStore::load() // without an identifier the settings are useless // we still have to push something into the list so that the indices stay correct outputDatas.push_back(std::nullopt); + qCWarning(KWIN_CORE, "Output in config is missing identifiers"); + continue; + } + const bool hasDuplicate = std::any_of(outputDatas.begin(), outputDatas.end(), [&state](const auto &data) { + return data + && data->edidIdentifier == state.edidIdentifier + && data->mstPath == state.mstPath + && data->connectorName == state.connectorName; + }); + if (hasDuplicate) { + qCWarning(KWIN_CORE, "Duplicate output found in config"); + outputDatas.push_back(std::nullopt); continue; } if (const auto it = data.find("mode"); it != data.end()) {