Bug 448599

Summary: Output::writeGlobal generates duplicate name, overwriting outputs if duplicate EDIDs exist
Product: [Plasma] KScreen Reporter: gimdh
Component: commonAssignee: kscreen-bugs-null <kscreen-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: gimdh, me, nate, xaver.hugl
Priority: NOR    
Version First Reported In: 5.24.7   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description gimdh 2022-01-16 14:41:00 UTC
SUMMARY
There may exist monitors with duplicate EDIDs (so do I). In fact, Output::readInOutputs already falls back to port name comparison if duplicate EDID is detected. However, Output::writeGlobal use the hash of EDID as the filename of saved output, and ends up overwriting already generated output file of another monitor, but with same EDID.


STEPS TO REPRODUCE
1. Connect monitors with same EDID


OBSERVED RESULT
Some configurations loaded with Config::readFile, such as rotation cannot be applied per-monitor at logon. That is, monitors with same EDID are set to the same rotation.


EXPECTED RESULT
Corresponding configurations read by Config::readFile are applied to each monitor properly despite duplicate EDIDs. 


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
** NOTE: I have checked same bug still exists in latest repo.

ADDITIONAL INFORMATION
libkscreen has following fallback hash function using port name instead of EDID in case of EDID does not exist or EDID is invalid. This could be used for filename.

    const auto hash = QCryptographicHash::hash(name().toLatin1(), QCryptographicHash::Md5);
    return QString::fromLatin1(hash.toHex());
Comment 1 Bug Janitor Service 2023-02-27 18:51:55 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kscreen/-/merge_requests/187
Comment 2 Zamundaaa 2023-03-13 16:32:06 UTC
Git commit e19e157c314fdf4bbd1262ada7d3c3842fce149b by Xaver Hugl.
Committed on 13/03/2023 at 16:19.
Pushed by zamundaaa into branch 'master'.

kded/output: with duplicate edid hashes, use different global config files

Before this commit, the global config files for two outputs with the same
hash would override each other, making KScreen lose some settings after
a reboot. With this commit, it will detect that and append the connector
name to the file name instead, thus separating the settings for the outputs
properly.
Related: bug 452614

M  +7    -1    kded/config.cpp
M  +29   -23   kded/output.cpp
M  +1    -2    kded/output.h
M  +3    -3    tests/kded/testgenerator.cpp

https://invent.kde.org/plasma/kscreen/commit/e19e157c314fdf4bbd1262ada7d3c3842fce149b
Comment 3 Zamundaaa 2023-03-13 16:38:01 UTC
Git commit 8288ea632f344472241ef107732c62757a8af2c9 by Xaver Hugl.
Committed on 13/03/2023 at 16:34.
Pushed by zamundaaa into branch 'Plasma/5.27'.

kded/output: with duplicate edid hashes, use different global config files

Before this commit, the global config files for two outputs with the same
hash would override each other, making KScreen lose some settings after
a reboot. With this commit, it will detect that and append the connector
name to the file name instead, thus separating the settings for the outputs
properly.
Related: bug 452614


(cherry picked from commit e19e157c314fdf4bbd1262ada7d3c3842fce149b)

M  +7    -1    kded/config.cpp
M  +29   -23   kded/output.cpp
M  +1    -2    kded/output.h
M  +3    -3    tests/kded/testgenerator.cpp

https://invent.kde.org/plasma/kscreen/commit/8288ea632f344472241ef107732c62757a8af2c9