diff --git a/src/outputconfigurationstore.cpp b/src/outputconfigurationstore.cpp index 4820a77a58..3cb1bf3e0a 100644 --- a/src/outputconfigurationstore.cpp +++ b/src/outputconfigurationstore.cpp @@ -128,25 +128,22 @@ std::optional OutputConfigurationStore::findOutput(Output *output, const QList &allOutputs) const { - const bool duplicateEdid = std::any_of(allOutputs.begin(), allOutputs.end(), [output](Output *otherOutput) { + const bool uniqueEdid = !output->edid().identifier().isEmpty() && std::none_of(allOutputs.begin(), allOutputs.end(), [output](Output *otherOutput) { return otherOutput != output && otherOutput->edid().identifier() == output->edid().identifier(); }); - const bool duplicateMst = std::any_of(allOutputs.begin(), allOutputs.end(), [output](Output *otherOutput) { + const bool uniqueMst = !output->mstPath().isEmpty() && std::none_of(allOutputs.begin(), allOutputs.end(), [output](Output *otherOutput) { return otherOutput != output && otherOutput->edid().identifier() == output->edid().identifier() && otherOutput->mstPath() == output->mstPath(); }); - const auto it = std::find_if(m_outputs.begin(), m_outputs.end(), [duplicateEdid, duplicateMst, output](const auto &outputState) { + const auto it = std::find_if(m_outputs.begin(), m_outputs.end(), [uniqueEdid, uniqueMst, output](const auto &outputState) { if (outputState.edidIdentifier != output->edid().identifier()) { return false; - } - if (!duplicateEdid) { + } else if (uniqueEdid) { return true; } - if (!output->mstPath().isEmpty()) { - if (outputState.mstPath != output->mstPath()) { - return false; - } else if (!duplicateMst) { - return true; - } + if (outputState.mstPath != output->mstPath()) { + return false; + } else if (uniqueMst) { + return true; } return outputState.connectorName == output->name(); });