[plasma-framework] src/plasma: if path is passed, pick the tail

Aleix Pol aleixpol at kde.org
Mon Feb 29 21:02:04 UTC 2016


El dia 29 febr. 2016 5:34 p. m., "Marco Martin" <notmart at gmail.com> va
escriure:
>
> Git commit 40b99a91222f59a6172b8673536c3c15c0458bf6 by Marco Martin.
> Committed on 29/02/2016 at 16:31.
> Pushed by mart into branch 'master'.
>
> if path is passed, pick the tail
>
> PluginLoader::loadApplet works both by passing a simple plugin
> name and a full path of a plasmoid package.
>
> However, when loading the optional C++ plugin, we have to look
> in the standard plasmoid plugin path, so only consider the
> tail of the path name, as is guaranteed that part is equal to
> the plugin name.
>
> BUG:359902
> Change-Id: Ic7300b7c12d7693bcb5590e29de780109a8ff81c
>
> M  +4    -2    src/plasma/pluginloader.cpp
>
>
http://commits.kde.org/plasma-framework/40b99a91222f59a6172b8673536c3c15c0458bf6
>
> diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp
> index 6691980..0915e46 100644
> --- a/src/plasma/pluginloader.cpp
> +++ b/src/plasma/pluginloader.cpp
> @@ -186,11 +186,13 @@ Applet *PluginLoader::loadApplet(const QString
&name, uint appletId, const QVari
>      }
>
>
> +    //if name wasn't a path, pluginName == name
> +    const QString pluginName = name.split('/').last();
>
>      // Look for C++ plugins first
> -    auto filter = [&name](const KPluginMetaData &md) -> bool
> +    auto filter = [&pluginName](const KPluginMetaData &md) -> bool
>      {
> -        return md.pluginId() == name;
> +        return md.pluginId() == pluginName;
>      };
>      QVector<KPluginMetaData> plugins =
KPluginLoader::findPlugins(PluginLoaderPrivate::s_plasmoidsPluginDir,
filter);
>

Use splitRef, or even better, lastIndexOf+midRef.

Aleix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160229/87423807/attachment.html>


More information about the Plasma-devel mailing list