void OutputMap::loadPlugins() { QString path; #ifdef __APPLE__ path = QString("%1/../%2").arg(QCoreApplication::applicationDirPath()) .arg(OUTPUTPLUGINDIR); #else path = QString(OUTPUTPLUGINDIR); #endif QDir dir(path, QString("*%1").arg(PLUGINEXT), QDir::Name, QDir::Files); /* Check that we can access the directory */ if (dir.exists() == false || dir.isReadable() == false) { qWarning() << "Unable to load output plugins from" << path; return; } /* Loop thru all files in the directory */ QStringListIterator it(dir.entryList()); while (it.hasNext() == true) { QLCOutPlugin* p; QString path; /* Attempt to load a plugin from the path */ path = dir.absoluteFilePath(it.next()); QPluginLoader loader(path, this); p = qobject_cast<QLCOutPlugin*> (loader.instance()); if (p != NULL) { /* Check for duplicates */ if (plugin(p->name()) == NULL) { /* New plugin. Append and init. */ p->init(); appendPlugin(p); } else { /* Duplicate plugin. Unload it. */ qWarning() << "Discarded duplicate plugin" << path; loader.unload(); } } else { qWarning() << "Unable to load an output plugin from" << path << "because:" << loader.errorString(); } } }
void OutputMap::loadPlugins(const QDir& dir) { /* Check that we can access the directory */ if (dir.exists() == false || dir.isReadable() == false) return; /* Loop thru all files in the directory */ QStringListIterator it(dir.entryList()); while (it.hasNext() == true) { /* Attempt to load a plugin from the path */ QString fileName(it.next()); QString path = dir.absoluteFilePath(fileName); QPluginLoader loader(path, this); QLCOutPlugin* p = qobject_cast<QLCOutPlugin*> (loader.instance()); if (p != NULL) { /* Check for duplicates */ if (plugin(p->name()) == NULL) { /* New plugin. Append and init. */ qDebug() << "Output plugin" << p->name() << "from" << fileName; p->init(); appendPlugin(p); QLCi18n::loadTranslation(p->name().replace(" ", "_")); } else { /* Duplicate plugin. Unload it. */ qWarning() << Q_FUNC_INFO << "Discarded duplicate output plugin" << path; loader.unload(); } } else { qWarning() << Q_FUNC_INFO << fileName << "doesn't contain a QLC output plugin:" << loader.errorString(); loader.unload(); } } }