mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-31 20:34:25 -04:00
Fix additional warnings when Carla is missing (#7722)
Fix additional warnings when Carla is missing Adds new env var LMMS_EXCLUDE_LADSPA --------- Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ if command -v carla > /dev/null 2>&1; then
|
||||
else
|
||||
echo "[$ME] Carla does not appear to be installed, we'll remove it from the plugin listing." >&2
|
||||
export "LMMS_EXCLUDE_PLUGINS=libcarla,${LMMS_EXCLUDE_PLUGINS}"
|
||||
export "LMMS_EXCLUDE_LADSPA=libcarla,${LMMS_EXCLUDE_LADSPA}"
|
||||
fi
|
||||
|
||||
# Additional workarounds for library conflicts
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
~PluginFactory() = default;
|
||||
|
||||
static void setupSearchPaths();
|
||||
static QList<QRegularExpression> getExcludePatterns(const char* envVar);
|
||||
|
||||
/// Returns the singleton instance of PluginFactory. You won't need to call
|
||||
/// this directly, use pluginFactory instead.
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QLibrary>
|
||||
#include <QList>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -45,6 +47,8 @@ LadspaManager::LadspaManager()
|
||||
// Make sure plugin search paths are set up
|
||||
PluginFactory::setupSearchPaths();
|
||||
|
||||
QList<QRegularExpression> excludePatterns = PluginFactory::getExcludePatterns("LMMS_EXCLUDE_LADSPA");
|
||||
|
||||
QStringList ladspaDirectories = QString( getenv( "LADSPA_PATH" ) ).
|
||||
split( LADSPA_PATH_SEPERATOR );
|
||||
ladspaDirectories += ConfigManager::inst()->ladspaDir().split( ',' );
|
||||
@@ -67,7 +71,15 @@ LadspaManager::LadspaManager()
|
||||
QFileInfoList list = directory.entryInfoList();
|
||||
for (const auto& f : list)
|
||||
{
|
||||
if(!f.isFile() || f.fileName().right( 3 ).toLower() !=
|
||||
bool exclude = false;
|
||||
for (const auto& pattern : excludePatterns) {
|
||||
if (pattern.match(f.filePath()).hasMatch()) {
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exclude || !f.isFile() || f.fileName().right(3).toLower() !=
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
"dll"
|
||||
#else
|
||||
|
||||
@@ -249,38 +249,50 @@ void PluginFactory::discoverPlugins()
|
||||
m_descriptors = descriptors;
|
||||
}
|
||||
|
||||
// Filter plugins based on environment variable, e.g. export LMMS_EXCLUDE_PLUGINS="libcarla"
|
||||
void PluginFactory::filterPlugins(QSet<QFileInfo>& files) {
|
||||
// Get filter
|
||||
QList<QRegularExpression> excludedPatterns;
|
||||
QString excludePatternString = std::getenv("LMMS_EXCLUDE_PLUGINS");
|
||||
// Builds QList<QRegularExpression> based on environment variable envVar
|
||||
QList<QRegularExpression> PluginFactory::getExcludePatterns(const char* envVar) {
|
||||
QList<QRegularExpression> excludePatterns;
|
||||
QString excludePatternString = std::getenv(envVar);
|
||||
|
||||
if (!excludePatternString.isEmpty()) {
|
||||
QStringList patterns = excludePatternString.split(',');
|
||||
for (const QString& pattern : patterns) {
|
||||
if (pattern.trimmed().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
QRegularExpression regex(pattern.trimmed());
|
||||
if (!pattern.trimmed().isEmpty() && regex.isValid()) {
|
||||
excludedPatterns << regex;
|
||||
if (regex.isValid()) {
|
||||
excludePatterns << regex;
|
||||
} else {
|
||||
qWarning() << "Invalid regular expression:" << pattern;
|
||||
}
|
||||
}
|
||||
}
|
||||
return excludePatterns;
|
||||
}
|
||||
|
||||
// Filter plugins based on environment variable, e.g. export LMMS_EXCLUDE_PLUGINS="libcarla"
|
||||
void PluginFactory::filterPlugins(QSet<QFileInfo>& files) {
|
||||
// Get filter
|
||||
QList<QRegularExpression> excludePatterns = getExcludePatterns("LMMS_EXCLUDE_PLUGINS");
|
||||
if (excludePatterns.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get files to remove
|
||||
QSet<QFileInfo> filesToRemove;
|
||||
for (const QFileInfo& fileInfo : files) {
|
||||
bool excluded = false;
|
||||
bool exclude = false;
|
||||
QString filePath = fileInfo.filePath();
|
||||
|
||||
for (const QRegularExpression& pattern : excludedPatterns) {
|
||||
for (const QRegularExpression& pattern : excludePatterns) {
|
||||
if (pattern.match(filePath).hasMatch()) {
|
||||
excluded = true;
|
||||
exclude = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (excluded) {
|
||||
if (exclude) {
|
||||
filesToRemove.insert(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user