BoorkmarksRunner: Set QIcon instead of Favicon pointer in BookmarkMatch
ClosedPublic

Authored by alex on Mar 30 2020, 2:41 PM.

Details

Summary

Before: A pointer to the favicon gets written in the BookmarkMatch and using this pointer the icon gets created when the Plasma::QueryMatch gets created.
Now: Using the favicon pointer the icon gets created and written to the BookmarkMatch, when the QueryMatch is created the icon value is read.

This makes the code easier to understand and the BookmarkMatch is independent of the Favicon class.

Test Plan

Should compile and display icons.

Diff Detail

Repository
R120 Plasma Workspace
Branch
bookmarks_change_icon_handling_in_matches
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24473
Build 24491: arc lint + arc unit
alex created this revision.Mar 30 2020, 2:41 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 30 2020, 2:41 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
alex requested review of this revision.Mar 30 2020, 2:41 PM
alex updated this revision to Diff 78906.Mar 30 2020, 2:46 PM

Remove unused includes

QIcon isn't thread safe.

alex added a comment.Mar 30 2020, 3:37 PM

QIcon isn't thread safe.

Sorry, I wasn't aware about that and haven't found anything when I had a quick look at the docs before submitting this patch.

But if I may ask: Why is this now not thread save but was before?
Before this patch the icon was created in the BookmarkMatch::asQueryMatch method which was called from the secondary thread.
And with this patch the icon gets created in the Browser::match method which gets called from the same thread.

bruns added a subscriber: bruns.Mar 30 2020, 7:36 PM
In D28439#638216, @alex wrote:

QIcon isn't thread safe.

Sorry, I wasn't aware about that and haven't found anything when I had a quick look at the docs before submitting this patch.

https://api.kde.org/frameworks/krunner/html/classPlasma_1_1AbstractRunner.html

bruns added a comment.Mar 30 2020, 7:54 PM

QIcon isn't thread safe.

I think this is related to https://phabricator.kde.org/D5889?id=14601 ?

I think we are save here, as the QIcon is created from an image stored on disk (absolute path to e.g. PNG), not from a theme.

alex added a comment.Mar 30 2020, 8:17 PM

QIcon isn't thread safe.

I think this is related to https://phabricator.kde.org/D5889?id=14601 ?

I think we are save here, as the QIcon is created from an image stored on disk (absolute path to e.g. PNG), not from a theme.

Thanks for the response, I was not sure if QIcon being not thread safe was meant in general or only for QIcon::fromTheme.

PS: When I said docs I meant the QIcon class docs, but thanks 😃

bruns added a comment.Mar 30 2020, 9:21 PM

@davidedmundson - is QIcon(QImage(...)) save?

the AppstreamRunner suffers from the same problem, it uses match->setIcon(/*wrapped*/QIcon::fromTheme(<name>)).

@davidedmundson - is QIcon(QImage(...)) save?

For the way it's used in the runner, yes.

Before this patch the icon was created in the BookmarkMatch::asQueryMatch method which was called from the secondary thread.

Then my comment is happily refuted. I read the title and wanted to provide context for why it might have been like that making an assumption.

alex added a comment.Apr 23 2020, 12:08 PM

Friendly Ping :-)

davidedmundson accepted this revision.Apr 23 2020, 12:14 PM
This revision is now accepted and ready to land.Apr 23 2020, 12:14 PM
alex edited the summary of this revision. (Show Details)Apr 23 2020, 12:47 PM
This revision was automatically updated to reflect the committed changes.