Commit f1869fdb authored by Stefan Brüns's avatar Stefan Brüns
Browse files

Use negative caching for thumbnail plugins failing to load

Insert a nullptr into the cache when a plugin fails to load, e.g.
because some symbols are unresolvable. Also log a warning stating the
error cause.

The cache is implicitly cleared by the kioslave idle logic.
parent c973cfaa
......@@ -19,6 +19,7 @@
*/
#include "thumbnail.h"
#include "thumbnail-logsettings.h"
#include <stdlib.h>
#ifdef __FreeBSD__
......@@ -601,24 +602,27 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
ThumbCreator* ThumbnailProtocol::getThumbCreator(const QString& plugin)
{
ThumbCreator *creator = m_creators[plugin];
if (!creator) {
// Don't use KPluginFactory here, this is not a QObject and
// neither is ThumbCreator
QLibrary library(KPluginLoader::findPlugin((plugin)));
if (library.load()) {
newCreator create = (newCreator)library.resolve("new_creator");
if (create) {
creator = create();
}
}
if (!creator) {
return nullptr;
}
auto it = m_creators.constFind(plugin);
if (it != m_creators.constEnd()) {
return *it;
}
m_creators.insert(plugin, creator);
ThumbCreator *creator = nullptr;
// Don't use KPluginFactory here, this is not a QObject and
// neither is ThumbCreator
QLibrary library(KPluginLoader::findPlugin((plugin)));
if (library.load()) {
auto createFn = (newCreator)library.resolve("new_creator");
if (createFn) {
creator = createFn();
}
}
if (!creator) {
qCWarning(KIO_THUMBNAIL_LOG) << "Failed to load" << plugin << library.errorString();
}
m_creators.insert(plugin, creator);
return creator;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment