D10512: try to preload certain applets in a smart way

Kai Uwe Broulik noreply at phabricator.kde.org
Wed Feb 14 20:10:14 UTC 2018


broulik added a comment.


  Cool!
  
  Since this is all applet quick item stuff it will just work™ with applet within system tray?
  Would be nice to have some `qCInfo` in there somewhere so we can better understand what it's doing, when it's increasing/decreasing the rating, when it's preloading it, etc.

INLINE COMMENTS

> appletquickitem.cpp:47
> +//weight values for the logic for when or if to preload
> +static const int s_defaultPreloadWeight = 50;
> +static const int s_defaultLauncherPreloadWeight = 100;

imho using an `enum` rather than a bunch of `static int`s is nicer

> appletquickitem.cpp:49
> +static const int s_defaultLauncherPreloadWeight = 100;
> +static const int s_defaultDatePreloadWeight = 80;
> +static const int s_immediatePreloadWeight = 70;

Are you sure we want to preload the calendar right away? This thing takes forever to open, wouldn't want to have that slow down plasma startup massively.

> appletquickitem.cpp:95
> +    //default widgets to be barely preloaded
> +    return qBound(0, applet->config().readEntry(QStringLiteral("PreloadWeight"), qMax(defaultWeight, applet->pluginMetaData().rawData().value(QStringLiteral("X-Plasma-PreloadWeight")).toInt())), 100);
> +}

Could this be split into multiple lines, it's quite hard to follow

> appletquickitem.cpp:636
> +    //decrease weight until we open it again
> +    applet()->config().writeEntry(QStringLiteral("PreloadWeight"), qMax(0, preloadWeight - s_preloadWeightIncrement));
> +

This should go into a function, there's like three places where a "random" `writeEntry` is scattered around

> appletquickitem.cpp:642
> +        //spread the creation over a random delay between 2 and 10 seconds, to make it look plasma started before, and load everything in the background without big noticeable freezes
> +        QTimer::singleShot(qrand() % ((10000 + 1) - 2000) + 2000, [this]() {
> +            d->createFullRepresentationItem();

Add `this` as context or else it would blow up when the applet is destroyed before the timer fires:

  QTimer::singleShot(qrand..., this, [this]() {

REPOSITORY
  R242 Plasma Framework (Library)

REVISION DETAIL
  https://phabricator.kde.org/D10512

To: mart, #plasma
Cc: broulik, apol, ngraham, plasma-devel, #frameworks, michaelh, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20180214/c1612f06/attachment-0001.html>


More information about the Plasma-devel mailing list