PluginFactory: Fix LMMS_PLUGIN_DIR search path, add ~/lmms/plugins/
Fixes #3392, supersedes #3431
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QLibrary>
|
||||
|
||||
#include "ConfigManager.h"
|
||||
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
QStringList nameFilters("*.dll");
|
||||
#else
|
||||
@@ -39,7 +41,7 @@ PluginFactory* PluginFactory::s_instance = nullptr;
|
||||
|
||||
PluginFactory::PluginFactory()
|
||||
{
|
||||
// Adds a search path relative to the main executable to if the path exists.
|
||||
// Adds a search path relative to the main executable if the path exists.
|
||||
auto addRelativeIfExists = [this] (const QString& path) {
|
||||
QDir dir(qApp->applicationDirPath());
|
||||
if (!path.isEmpty() && dir.cd(path)) {
|
||||
@@ -68,6 +70,8 @@ PluginFactory::PluginFactory()
|
||||
if (!(env_path = qgetenv("LMMS_PLUGIN_DIR")).isEmpty())
|
||||
QDir::addSearchPath("plugins", env_path);
|
||||
|
||||
QDir::addSearchPath("plugins", ConfigManager::inst()->workingDir() + "plugins");
|
||||
|
||||
discoverPlugins();
|
||||
}
|
||||
|
||||
@@ -127,7 +131,11 @@ void PluginFactory::discoverPlugins()
|
||||
PluginInfoList pluginInfos;
|
||||
m_pluginByExt.clear();
|
||||
|
||||
const QFileInfoList& files = QDir("plugins:").entryInfoList(nameFilters);
|
||||
QFileInfoList files;
|
||||
for (const QString& searchPath : QDir::searchPaths("plugins"))
|
||||
{
|
||||
files << QDir(searchPath).entryInfoList(nameFilters);
|
||||
}
|
||||
|
||||
// Cheap dependency handling: zynaddsubfx needs ZynAddSubFxCore. By loading
|
||||
// all libraries twice we ensure that libZynAddSubFxCore is found.
|
||||
@@ -142,6 +150,7 @@ void PluginFactory::discoverPlugins()
|
||||
|
||||
if (! library->load()) {
|
||||
m_errors[file.baseName()] = library->errorString();
|
||||
qWarning(library->errorString().toLocal8Bit());
|
||||
continue;
|
||||
}
|
||||
if (library->resolve("lmms_plugin_main") == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user