PluginFactory::PluginFactory() { // Adds a search path relative to the main executable if the path exists. auto addRelativeIfExists = [](const QString & path) { QDir dir(qApp->applicationDirPath()); if (!path.isEmpty() && dir.cd(path)) { QDir::addSearchPath("plugins", dir.absolutePath()); } }; // We're either running LMMS installed on an Unixoid or we're running a // portable version like we do on Windows. // We want to find our plugins in both cases: // (a) Installed (Unix): // e.g. binary at /usr/bin/lmms - plugin dir at /usr/lib/lmms/ // (b) Portable: // e.g. binary at "C:/Program Files/LMMS/lmms.exe" // plugins at "C:/Program Files/LMMS/plugins/" #ifndef LMMS_BUILD_WIN32 addRelativeIfExists("../lib/lmms"); // Installed #endif addRelativeIfExists("plugins"); // Portable #ifdef PLUGIN_DIR // We may also have received a relative directory via a define addRelativeIfExists(PLUGIN_DIR); #endif // Or via an environment variable: QString env_path; if (!(env_path = qgetenv("LMMS_PLUGIN_DIR")).isEmpty()) QDir::addSearchPath("plugins", env_path); QDir::addSearchPath("plugins", ConfigManager::inst()->workingDir() + "plugins"); discoverPlugins(); }
PluginFactory::PluginFactory() { setupSearchPaths(); discoverPlugins(); }