Skip to content

Commit 69dc1ae

Browse files
committed
[xpluginpath] Save/load plugin's path as relative to current session directory,
when not found in any of the plugin search paths. (EXPERIMENTAL)
1 parent 63d21e7 commit 69dc1ae

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/qtractorPlugin.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,8 +1742,8 @@ bool qtractorPlugin::savePluginFilename (
17421742
if (typeHint == qtractorPluginType::Lv2)
17431743
return true;
17441744

1745-
// Otherwise search for a match
1746-
// with one of the search paths...
1745+
// First we search for a match with
1746+
// one of the plugin search paths...
17471747
qtractorPluginFactory *pPluginFactory
17481748
= qtractorPluginFactory::getInstance();
17491749
if (pPluginFactory) {
@@ -1757,8 +1757,15 @@ bool qtractorPlugin::savePluginFilename (
17571757
}
17581758
}
17591759

1760-
// No match is found, leave filename as is.
1761-
return true;
1760+
// No match is found, force plugin relative path...
1761+
qtractorSession *pSession = qtractorSession::getInstance();
1762+
if (pSession) {
1763+
sFilename = pSession->relativeFilePath(sFilename);
1764+
return true;
1765+
}
1766+
1767+
// Might never reach here!...
1768+
return false;
17621769
}
17631770

17641771

@@ -2699,17 +2706,30 @@ bool qtractorPluginList::loadPluginFilename (
26992706
if (typeHint == qtractorPluginType::Lv2)
27002707
return true;
27012708

2702-
// Primary check for plugin pathname...
2709+
// Primary check for the original plugin path...
27032710
QFileInfo fi(sFilename);
27042711
if (fi.exists() && fi.isReadable())
27052712
return true;
27062713

2714+
// Secondary check for a plugin relative path...
2715+
const bool bRelative = fi.isRelative();
2716+
if (bRelative) {
2717+
qtractorSession *pSession = qtractorSession::getInstance();
2718+
if (pSession) {
2719+
fi.setFile(pSession->absoluteFilePath(sFilename));
2720+
if (fi.exists() && fi.isReadable()) {
2721+
sFilename = fi.absoluteFilePath();
2722+
return true;
2723+
}
2724+
}
2725+
}
2726+
27072727
// Otherwise search for an alternative
2708-
// under each respective search paths...
2728+
// under one of the plugin search paths...
27092729
qtractorPluginFactory *pPluginFactory
27102730
= qtractorPluginFactory::getInstance();
27112731
if (pPluginFactory) {
2712-
const QString& fname = (fi.isRelative() ? sFilename : fi.fileName());
2732+
const QString& fname = (bRelative ? sFilename : fi.fileName());
27132733
QStringListIterator iter(pPluginFactory->pluginPaths(typeHint));
27142734
while (iter.hasNext()) {
27152735
fi.setFile(QDir(iter.next()), fname);

0 commit comments

Comments
 (0)