summaryrefslogtreecommitdiffstats
path: root/common/resource.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-03-16 14:28:50 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-03-16 14:28:50 +0100
commiteaf29d5080d0b1263df26e09bb3e81034bcac988 (patch)
tree77871d07b468afbdab5062fa6366202d74f1a957 /common/resource.cpp
parent90f2ce6fe1f2e697d6c6a6994bd691e0879b911f (diff)
downloadsink-eaf29d5080d0b1263df26e09bb3e81034bcac988.tar.gz
sink-eaf29d5080d0b1263df26e09bb3e81034bcac988.zip
The path is not called "plugins" on macosx.
Diffstat (limited to 'common/resource.cpp')
-rw-r--r--common/resource.cpp55
1 files changed, 27 insertions, 28 deletions
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)
89 } 89 }
90 90
91 for (auto const &path : QCoreApplication::instance()->libraryPaths()) { 91 for (auto const &path : QCoreApplication::instance()->libraryPaths()) {
92 if (path.endsWith(QLatin1String("plugins"))) { 92 QDir pluginDir(path);
93 QDir pluginDir(path); 93 // TODO: centralize this so that it is easy to change centrally
94 // TODO: centralize this so that it is easy to change centrally 94 // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH}
95 // also ref'd in cmake as ${SINK_RESOURCE_PLUGINS_PATH} 95 if (!pluginDir.cd(QStringLiteral("sink")) || !pluginDir.cd(QStringLiteral("resources"))) {
96 pluginDir.cd(QStringLiteral("sink")); 96 continue;
97 pluginDir.cd(QStringLiteral("resources")); 97 }
98 98
99 for (const QString &fileName : pluginDir.entryList(QDir::Files)) { 99 for (const QString &fileName : pluginDir.entryList(QDir::Files)) {
100 const QString path = pluginDir.absoluteFilePath(fileName); 100 const QString path = pluginDir.absoluteFilePath(fileName);
101 QPluginLoader loader(path); 101 QPluginLoader loader(path);
102 102
103 const QString id = loader.metaData()[QStringLiteral("IID")].toString(); 103 const QString id = loader.metaData()[QStringLiteral("IID")].toString();
104 if (id == resourceName) { 104 if (id == resourceName) {
105 QObject *object = loader.instance(); 105 QObject *object = loader.instance();
106 if (object) { 106 if (object) {
107 factory = qobject_cast<ResourceFactory *>(object); 107 factory = qobject_cast<ResourceFactory *>(object);
108 if (factory) { 108 if (factory) {
109 s_loadedFactories->insert(resourceName, factory); 109 s_loadedFactories->insert(resourceName, factory);
110 //TODO: Instead of always loading both facades and adaptorfactories into the respective singletons, we could also leave this up to the caller. (ResourceFactory::loadFacades(...)) 110 //TODO: Instead of always loading both facades and adaptorfactories into the respective singletons, we could also leave this up to the caller. (ResourceFactory::loadFacades(...))
111 factory->registerFacades(resourceName, FacadeFactory::instance()); 111 factory->registerFacades(resourceName, FacadeFactory::instance());
112 factory->registerAdaptorFactories(resourceName, AdaptorFactoryRegistry::instance()); 112 factory->registerAdaptorFactories(resourceName, AdaptorFactoryRegistry::instance());
113 // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject(); 113 // TODO: if we need more data on it const QJsonObject json = loader.metaData()[QStringLiteral("MetaData")].toObject();
114 return factory; 114 return factory;
115 } else {
116 qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object;
117 delete object;
118 }
119 } else { 115 } else {
120 qWarning() << "Could not load factory for" << resourceName << "from plugin" << loader.fileName() << "due to the following error:" << loader.errorString(); 116 qWarning() << "Plugin for" << resourceName << "from plugin" << loader.fileName() << "produced the wrong object type:" << object;
117 delete object;
121 } 118 }
119 } else {
120 qWarning() << "Could not load factory for" << resourceName << "from plugin" << loader.fileName() << "due to the following error:" << loader.errorString();
122 } 121 }
123 } 122 }
124 } 123 }