Skip to content

Fix use of invalid reference when updating desktop ID in desktop KCM module

Yichao Yu requested to merge work/yyc/kcm-ref-fix into master

m_names[newId] returns an reference that can be invalidated by m_names.take(oldId) when the new and old IDs are the same. Fix this by skipping the update when no change is needed. As an additional optimization, avoid unnecessary copying of the old ID by overwriting it only at the end after the last use.

This is a bit tricky so add comments to make sure this doesn't happen again.

Introduced in cee5ea78. Happens for me only on an AArch64 machine probably due to the nature of the undefined behavior...

Merge request reports