Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick fix for QStringList list declaration
const QDir &PluginContainer::pluginDir()
{
static bool isLoaded = false;
static QDir path;
if (!isLoaded) {
isLoaded = true;
QString appDir = qApp->applicationDirPath();
QStringList list{};
#ifdef Q_OS_MAC
if (appDir == QLatin1String("MacOS")) {
list << appDir;
QDir dir(appDir);
// Development convenience-hack
dir.cdUp();
dir.cdUp();
dir.cdUp();
appDir = dir.absolutePath();
}
#endif
const auto suffix = QStringLiteral("/libsnore" SNORE_SUFFIX);
list << appDir;
for (const QString &s : qApp->libraryPaths()) {
list << s + suffix;
}
list<< appDir + suffix
<< appDir + QStringLiteral("/../lib/plugins") + suffix
<< appDir + QStringLiteral("/../lib64/plugins") + suffix
<< QStringLiteral(LIBSNORE_PLUGIN_PATH);
qCDebug(SNORE) << "Plugin locations:" << list;
foreach(const QString & p, list) {
path = QDir(p);
if (!path.entryInfoList(pluginFileFilters()).isEmpty()) {
break;
} else {
qCDebug(SNORE) << "Possible pluginpath:" << path.absolutePath() << "does not contain plugins.";
}
}
if (path.entryInfoList(pluginFileFilters()).isEmpty()) {
qCWarning(SNORE) << "Couldnt find any plugins";
}
qCDebug(SNORE) << "PluginPath is :" << path.absolutePath();
}
return path;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment