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.
master
Xaver Hugl 11 months ago
parent 0a844c2bde
commit fde1393076

@ -555,6 +555,18 @@ void OutputConfigurationStore::load()
// without an identifier the settings are useless // without an identifier the settings are useless
// we still have to push something into the list so that the indices stay correct // we still have to push something into the list so that the indices stay correct
outputDatas.push_back(std::nullopt); 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; continue;
} }
if (const auto it = data.find("mode"); it != data.end()) { if (const auto it = data.find("mode"); it != data.end()) {

Loading…
Cancel
Save