Share Plasma::Theme instances between multiple ColorScope
ClosedPublic

Authored by broulik on Jan 10 2019, 9:57 AM.

Details

Summary

Especially since the Theme isn't modified in any way but just used to read some data.
While the Private part of Theme is already shared, creating a Theme instance still has some setup cost.

Test Plan

Noticed in GammaRay there was a tonne of Theme objects.
Changing themes and changing color schemes still works.

Now get ~400 Theme objects created rather than well over a thousand

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
broulik created this revision.Jan 10 2019, 9:57 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 10 2019, 9:57 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
broulik requested review of this revision.Jan 10 2019, 9:57 AM
broulik edited the test plan for this revision. (Show Details)

Now in multi-thread environment will have problems especially on actualTheme(), no?

Now in multi-thread environment will have problems especially on actualTheme(), no?

ColorScope is QML-only and should be fine? Not sure about Svg, it never mentioned being thread-safe.

apol added a subscriber: apol.Jan 10 2019, 12:54 PM
apol added inline comments.
src/declarativeimports/core/colorscope.h
135

How about using a QSharedPointer?

broulik added inline comments.Jan 10 2019, 1:01 PM
src/declarativeimports/core/colorscope.h
135

Complained with "QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer"

apol added inline comments.Jan 10 2019, 1:43 PM
src/declarativeimports/core/colorscope.h
135

Seems odd.
And QSharedDataPointer? http://doc.qt.io/qt-5/qshareddatapointer.html
or std::shared_ptr.

And QSharedDataPointer?

For that Theme would need to be QSharedData, no?

broulik updated this revision to Diff 49537.Jan 15 2019, 3:16 PM
broulik retitled this revision from Share Plasma::Theme instances between multiple Svg and ColorScope to Share Plasma::Theme instances between multiple ColorScope.
broulik edited the test plan for this revision. (Show Details)

Focus on ColorScope for now, Svg is a tad more difficult.

  • Use QSharedPointer
mart accepted this revision.Jan 18 2019, 11:23 AM
This revision is now accepted and ready to land.Jan 18 2019, 11:23 AM
This revision was automatically updated to reflect the committed changes.