Bug 348798 - KPluginLoader::KPluginLoader() - misleading? error message
Summary: KPluginLoader::KPluginLoader() - misleading? error message
Status: REPORTED
Alias: None
Product: frameworks-kcmutils
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-06 22:24 UTC by Elias Probst
Modified: 2021-03-09 05:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Elias Probst 2015-06-06 22:24:38 UTC
Since https://git.reviewboard.kde.org/r/119038/ KCMs (sh|c)ould drop their plugin into the kcms/ subdirectory of $QT_PLUGIN_PATH.

When kcmshell/kcmutil tries to load one of those, KPluginLoader logs the following lines:
default unknown: Error loading plugin "kcm_lookandfeel" "The shared library was not found." 
Plugin search paths are ("/usr/lib64/qt5/plugins", "/usr/bin") 
The environment variable QT_PLUGIN_PATH might be not correctly set

Loading the KCM still succeeds, so it looks to me, like the error messages shouldn't be shown in that case, but I miss the insight into kpluginloader to fully understand the situation.

How to reproduce:
- kcmshell5 kcm_lookandfeel


Running KF5/Plasma 5 from git + Qt 5.4.1
Comment 1 Dāvis 2015-08-09 11:45:49 UTC
I've same issue on Arch Linux with Qt 5.5 and all KF5 latest from git master branch (even plasma-desktop, etc.). It happens for all kcms, but seems like everything is working, only this

systemsettings5[6563]: Error loading plugin "kcm_lookandfeel" "The shared library was not found."
                                   Plugin search paths are ("/usr/lib/qt/plugins", "/usr/bin")
                                   The environment variable QT_PLUGIN_PATH might be not correctly set

QT_PLUGIN_PATH is empty and kcm_lookandfeel is located at /usr/lib/qt/plugins/kcms/
Comment 2 Michael Pyne 2015-08-29 21:58:55 UTC
I've reproduced the message but I think it's better reported against frameworks-kcmutils. I'm not real eager to disable a global warning to make KCMs less noisy, and the following patch to kcmutils allows it to load new KCMs without a warning (by using KPluginLoader::findPlugin to check which name is most appropriate).

However I'm not entirely sure there's no other issues so I don't want to commit myself.

    diff --git a/src/kcmoduleloader.cpp b/src/kcmoduleloader.cpp
    index 4090ac1..533e892 100644
    --- a/src/kcmoduleloader.cpp
    +++ b/src/kcmoduleloader.cpp
    @@ -89,22 +89,22 @@ KCModule *KCModuleLoader::loadModule(const KCModuleInfo &mod, ErrorReporting rep
             foreach (const QString &arg, args) {
                 args2 << arg;
             }
    -        KCModule *module = mod.service()->createInstance<KCModule>(parent, args2, &error);
    -        if (module) {
    -            return module;
    +
    +        QString pluginName (mod.service()->library());
    +        if (KPluginLoader::findPlugin(pluginName).isEmpty()) {
    +            pluginName.prepend(QLatin1String("kcms/"));
    +        }
    +
    +        KPluginLoader loader(KPluginLoader::findPlugin(pluginName));
    +        KPluginFactory* factory = loader.factory();
    +        if (!factory) {
    +            qWarning() << "Error loading plugin:" << loader.errorString();
             } else {
    -            KPluginLoader loader(KPluginLoader::findPlugin(QLatin1String("kcms/") + mod.service()->library()));
    -            KPluginFactory* factory = loader.factory();
    -            if (!factory) {
    -                qWarning() << "Error loading plugin:" << loader.errorString();
    -            } else {
    -                KQuickAddons::ConfigModule *cm = factory->create<KQuickAddons::ConfigModule >();
    -                if (!cm) {
    -                    qWarning() << "Error creating object from plugin" << loader.fileName();
    -                }
    -                module = new KCModuleQml(cm, parent, args2);
    -                return module;
    +            KQuickAddons::ConfigModule *cm = factory->create<KQuickAddons::ConfigModule >();
    +            if (!cm) {
    +                qWarning() << "Error creating object from plugin" << loader.fileName();
                 }
    +            return new KCModuleQml(cm, parent, args2);
             }
     //#ifndef NDEBUG
             {
Comment 3 Justin Zobel 2021-03-09 05:53:50 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.