Skip to content

Instantly share code, notes, and snippets.

@mkmarineboy
Created August 9, 2020 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkmarineboy/0ff07a72a4ee2b228f910cce4f0394f9 to your computer and use it in GitHub Desktop.
Save mkmarineboy/0ff07a72a4ee2b228f910cce4f0394f9 to your computer and use it in GitHub Desktop.
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