MCPcopy Create free account
hub / github.com/MrKepzie/Natron / getPluginBinary

Method getPluginBinary

Engine/AppManager.cpp:2293–2369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2291}
2292
2293Plugin*
2294AppManager::getPluginBinary(const QString & pluginId,
2295 int majorVersion,
2296 int minorVersion,
2297 bool convertToLowerCase) const
2298{
2299 Q_UNUSED(minorVersion);
2300
2301 PluginsMap::const_iterator foundID = _imp->_plugins.find( pluginId.toStdString() );
2302 if ( convertToLowerCase && foundID == _imp->_plugins.end() ) {
2303 foundID = _imp->_plugins.end();
2304 for (PluginsMap::const_iterator it = _imp->_plugins.begin(); it != _imp->_plugins.end(); ++it) {
2305 QString pID = QString::fromUtf8( it->first.c_str() );
2306 if ( !pluginId.startsWith( QString::fromUtf8(NATRON_ORGANIZATION_DOMAIN_TOPLEVEL "." NATRON_ORGANIZATION_DOMAIN_SUB ".built-in.") ) ) {
2307 QString lowerCase = pID.toLower();
2308 if (lowerCase == pluginId) {
2309 foundID = it;
2310 break;
2311 }
2312 }
2313 }
2314 }
2315
2316 if ( foundID != _imp->_plugins.end() ) {
2317 assert( !foundID->second.empty() );
2318
2319 // see also OFX::Host::PluginCache::getPluginById()
2320 // see also AppManager::getPluginBinaryFromOldID()
2321
2322 if (majorVersion == -1) {
2323 // -1 means we want to load the highest version existing
2324 return *foundID->second.rbegin();
2325 }
2326
2327 // Let's be a bit smarter than HostSupport.
2328 // The best compatible plugin is, by order of preference
2329 // - the plugin with the same major version and the highest minor
2330 // - the plugin with the closest major above and the highest minor
2331 // - the plugin with the highest major and the highest minor
2332 //
2333 // For example, if versions (1,0) (1,2) (3,1) (3,4) (4,2) are available,
2334 // - asking for (1,0) returns (1,2)
2335 // - asking for (2,7) returns (3,4)
2336 // - asking for (3,1) returns (3,4)
2337 // - asking for (6,0) returns (4,2)
2338
2339 // Try to find the exact major version, with the highest minor
2340 // (thus the reverse iterator)
2341 Plugin* nextPlugin = *(foundID->second.rbegin());
2342 int nextVersion = nextPlugin->getMajorVersion();
2343 for (PluginVersionsOrdered::const_reverse_iterator itver = foundID->second.rbegin(); itver != foundID->second.rend(); ++itver) {
2344 int thisMajorVersion = (*itver)->getMajorVersion();
2345 if (thisMajorVersion == majorVersion) {
2346 return *itver;
2347 } else if (thisMajorVersion > majorVersion &&
2348 thisMajorVersion < nextVersion) {
2349 nextPlugin = *itver;
2350 nextVersion = thisMajorVersion;

Callers 6

registerTestPluginsMethod · 0.80
createNodeInternalMethod · 0.80
exportDocsMethod · 0.80
handlerMethod · 0.80

Calls 6

toStdStringMethod · 0.80
emptyMethod · 0.80
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
getMajorVersionMethod · 0.45

Tested by 1

registerTestPluginsMethod · 0.64