Skip to content

Commit

Permalink
OfxHost::loadOFXPlugins: fix bug + add debug messages
Browse files Browse the repository at this point in the history
closes #1584
  • Loading branch information
devernay committed Mar 13, 2017
1 parent 08ea8db commit b9cd33d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Multi-dimensional parameters don't automatically fold into a single dimension, except for scale and size params.
- Binaries distributed through Natron's web site are now built with 10-bit x264 and 10/12-bit libvpx-vp9 support. That means the produced video files may be unplayable on some hardware (e.g. phones or TVs), but Natron should really be used to produce digital intermediates with the highest possible fidelity, which can then be transcoded to more suitable distribution codecs.
- Better cache usage for Readers.
- Fix a bug where custom OpenFX plugins directories would be ignored #1584

### Plugins

Expand Down
32 changes: 30 additions & 2 deletions Engine/OfxHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,14 +832,26 @@ getPluginShortcuts(const OFX::Host::ImageEffect::Descriptor& desc, std::list<Plu
}
}

static inline
QDebug operator<<(QDebug dbg, const std::list<std::string> &l)
{
for (std::list<std::string>::const_iterator it = l.begin(); it != l.end(); ++it) {
dbg.nospace() << QString::fromUtf8( it->c_str() ) << ' ';
}

return dbg.space();
}

void
OfxHost::loadOFXPlugins(IOPluginsMap* readersMap,
IOPluginsMap* writersMap)
{
qDebug() << "Load OFX Plugins...";
SettingsPtr settings = appPTR->getCurrentSettings();
assert(settings);
bool useStdOFXPluginsLocation = settings->getUseStdOFXPluginsLocation();
if (!useStdOFXPluginsLocation) {
qDebug() << "Load OFX Plugins: do not use std plugins location";
// only set if false, else use the previous value (which is set for example in BaseTest::SetUp())
OFX::Host::PluginCache::useStdOFXPluginsLocation(useStdOFXPluginsLocation);
}
Expand All @@ -853,10 +865,12 @@ OfxHost::loadOFXPlugins(IOPluginsMap* readersMap,


pluginCache->setPluginHostPath(NATRON_APPLICATION_NAME);
pluginCache->setPluginHostPath("Nuke");
pluginCache->setPluginHostPath("Nuke"); // most Nuke OFX plugins are compatible
std::list<std::string> extraPluginsSearchPaths;
settings->getOpenFXPluginsSearchPaths(&extraPluginsSearchPaths);
for (std::list<std::string>::iterator it = extraPluginsSearchPaths.begin(); it != extraPluginsSearchPaths.end(); ++it) {
if ( !(*it).empty() ) {
qDebug() << "Load OFX Plugins: append extra plugins dir" << it->c_str();
pluginCache->addFileToPath(*it);
}
}
Expand All @@ -868,8 +882,10 @@ OfxHost::loadOFXPlugins(IOPluginsMap* readersMap,
try {
if ( settings->loadBundledPlugins() ) {
if ( settings->preferBundledPlugins() ) {
qDebug() << "Load OFX Plugins: prepend bundled plugins dir" << natronBundledPluginsPath.c_str();
pluginCache->prependFileToPath(natronBundledPluginsPath);
} else {
qDebug() << "Load OFX Plugins: append bundled plugins dir" << natronBundledPluginsPath.c_str();
pluginCache->addFileToPath(natronBundledPluginsPath);
}
}
Expand All @@ -882,25 +898,36 @@ OfxHost::loadOFXPlugins(IOPluginsMap* readersMap,
//on Linux ~/.cache/<organization>/<application>/OFXLoadCache/
//on windows: C:\Users\<username>\App Data\Local\<organization>\<application>\Caches\OFXLoadCache
QString ofxCacheFilePath = getCacheFilePath();
qDebug() << "Load OFX Plugins: reading cache file" << ofxCacheFilePath;

{
FStreamsSupport::ifstream ifs;
FStreamsSupport::open( &ifs, ofxCacheFilePath.toStdString() );
if (ifs) {
if (!ifs) {
qDebug() << "Load OFX Plugins: cannot open cache file" << ofxCacheFilePath;
} else {
try {
pluginCache->readCache(ifs);
qDebug() << "Load OFX Plugins: reading cache file... done!";
} catch (const std::exception& e) {
qDebug() << "Load OFX Plugins: reading cache file... failed!";
appPTR->writeToErrorLog_mt_safe( QLatin1String("OpenFX"), QDateTime::currentDateTime(),
tr("Failure to read OpenFX plug-ins cache: %1").arg( QString::fromUtf8( e.what() ) ) );
}
}
}

qDebug() << "Load OFX Plugins: plugin path is" << pluginCache->getPluginPath();
qDebug() << "Load OFX Plugins: scan plugins...";
pluginCache->scanPluginFiles();
qDebug() << "Load OFX Plugins: scan plugins... done!";
_imp->loadingPluginID.clear(); // finished loading plugins

// write the cache NOW (it won't change anyway)
qDebug() << "Load OFX Plugins: writing cache file" << ofxCacheFilePath;
/// flush out the current cache
writeOFXCache();
qDebug() << "Load OFX Plugins: writing cache file... done!";

/*Filling node name list and plugin grouping*/
typedef std::map<OFX::Host::ImageEffect::MajorPlugin, OFX::Host::ImageEffect::ImageEffectPlugin *> PMap;
Expand Down Expand Up @@ -1037,6 +1064,7 @@ OfxHost::loadOFXPlugins(IOPluginsMap* readersMap,
}
}
}
qDebug() << "Load OFX Plugins... done!";
} // loadOFXPlugins

void
Expand Down

0 comments on commit b9cd33d

Please sign in to comment.