[SystemTray] Fix model update in settings (missing icon)
ClosedPublic

Authored by kmaterka on Wed, Jan 22, 7:10 PM.

Details

Summary

Fixes a bug, when system tray settings is opened and new application is opened, view is not correctly refreshed and icon is missing. Caused by duplicated role names. Related to: D26586

BUG: 416400
FIXED-IN: 5.18.0

Test Plan
  1. Open system tray settings
  2. Open an app with systray icon

Expected:
Icon, title etc are correctly rendered.

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kmaterka created this revision.Wed, Jan 22, 7:10 PM
Restricted Application added a subscriber: plasma-devel. · View Herald TranscriptWed, Jan 22, 7:10 PM
kmaterka requested review of this revision.Wed, Jan 22, 7:10 PM

Problem was in duplicated role names, which confused ListView/delegate.

kmaterka edited the summary of this revision. (Show Details)Thu, Jan 23, 3:39 PM
broulik added inline comments.Thu, Jan 23, 3:50 PM
applets/systemtray/systemtraymodel.cpp
269

Avoid keys() which creates a temporary list, instead use iterators

const auto roleNames = sourceModel->roleNames();
for (auto it = roleNames.begin(), end = roleNames.end(); it != end; ++it) {
    if (!m_roleNames.contains(it.key()) {
        m_roleNames.insert(it.key(), it.value());
    }
}
kmaterka updated this revision to Diff 74272.Thu, Jan 23, 8:08 PM

Iterator used

kmaterka marked an inline comment as done.Thu, Jan 23, 8:12 PM
kmaterka added inline comments.
applets/systemtray/systemtraymodel.cpp
269

Done. Does it matter if I use Java-style iterator or STL-style? Documentation says that STL-style is slightly faster, but I like Java -style more. I checked plasma-workspace and both are used.

kmaterka retitled this revision from [SystemTray] Refresh icon in settings on update to [SystemTray] Fix model update in settings (missing icon).Sun, Jan 26, 8:55 PM
davidedmundson accepted this revision.Sun, Jan 26, 9:15 PM
This revision is now accepted and ready to land.Sun, Jan 26, 9:15 PM
This revision was automatically updated to reflect the committed changes.
kmaterka marked an inline comment as done.