From eaf29d5080d0b1263df26e09bb3e81034bcac988 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 16 Mar 2018 14:28:50 +0100 Subject: The path is not called "plugins" on macosx. --- common/resource.cpp | 55 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'common') diff --git a/common/resource.cpp b/common/resource.cpp index 96aaded..6db5510 100644 --- a/common/resource.cpp +++ b/common/resource.cpp @@ -89,36 +89,35 @@ ResourceFactory *ResourceFactory::load(const QByteArray &resourceName) } for (auto const &path : QCoreApplication::instance()->libraryPaths()) { - if (path.endsWith(QLatin1String("plugins"))) { - QDir pluginDir(path); - // TODO: centralize this so that it is easy to change centrally - // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH} - pluginDir.cd(QStringLiteral("sink")); - pluginDir.cd(QStringLiteral("resources")); - - for (const QString &fileName : pluginDir.entryList(QDir::Files)) { - const QString path = pluginDir.absoluteFilePath(fileName); - QPluginLoader loader(path); - - const QString id = loader.metaData()[QStringLiteral("IID")].toString(); - if (id == resourceName) { - QObject *object = loader.instance(); - if (object) { - factory = qobject_cast(object); - if (factory) { - s_loadedFactories->insert(resourceName, factory); - //TODO: Instead of always loading both facades and adaptorfactories into the respective singletons, we could also leave this up to the caller. (ResourceFactory::loadFacades(...)) - factory->registerFacades(resourceName, FacadeFactory::instance()); - factory->registerAdaptorFactories(resourceName, AdaptorFactoryRegistry::instance()); - // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); - return factory; - } else { - qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object; - delete object; - } + QDir pluginDir(path); + // TODO: centralize this so that it is easy to change centrally + // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH} + if (!pluginDir.cd(QStringLiteral("sink")) || !pluginDir.cd(QStringLiteral("resources"))) { + continue; + } + + for (const QString &fileName : pluginDir.entryList(QDir::Files)) { + const QString path = pluginDir.absoluteFilePath(fileName); + QPluginLoader loader(path); + + const QString id = loader.metaData()[QStringLiteral("IID")].toString(); + if (id == resourceName) { + QObject *object = loader.instance(); + if (object) { + factory = qobject_cast(object); + if (factory) { + s_loadedFactories->insert(resourceName, factory); + //TODO: Instead of always loading both facades and adaptorfactories into the respective singletons, we could also leave this up to the caller. (ResourceFactory::loadFacades(...)) + factory->registerFacades(resourceName, FacadeFactory::instance()); + factory->registerAdaptorFactories(resourceName, AdaptorFactoryRegistry::instance()); + // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); + return factory; } else { - qWarning() << "Could not load factory for" << resourceName << "from plugin" << loader.fileName() << "due to the following error:" << loader.errorString(); + qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object; + delete object; } + } else { + qWarning() << "Could not load factory for" << resourceName << "from plugin" << loader.fileName() << "due to the following error:" << loader.errorString(); } } } -- cgit v1.2.3