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

Authored by kmaterka on Jan 22 2020, 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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 21601
Build 21619: arc lint + arc unit
kmaterka created this revision.Jan 22 2020, 7:10 PM
Restricted Application added a subscriber: plasma-devel. · View Herald TranscriptJan 22 2020, 7:10 PM
kmaterka requested review of this revision.Jan 22 2020, 7:10 PM

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

kmaterka edited the summary of this revision. (Show Details)Jan 23 2020, 3:39 PM
broulik added inline comments.Jan 23 2020, 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.Jan 23 2020, 8:08 PM

Iterator used

kmaterka marked an inline comment as done.Jan 23 2020, 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).Jan 26 2020, 8:55 PM
davidedmundson accepted this revision.Jan 26 2020, 9:15 PM
This revision is now accepted and ready to land.Jan 26 2020, 9:15 PM
This revision was automatically updated to reflect the committed changes.
kmaterka marked an inline comment as done.