Mercurial > hg > svcore
changeset 251:db0dd744fa8d
* Fix hang and memory leak on startup when encountering a pre-Vamp-1.0 plugin
author | Chris Cannam |
---|---|
date | Tue, 20 Mar 2007 11:49:11 +0000 |
parents | 40db5491bcf8 |
children | 218605f94073 |
files | plugin/FeatureExtractionPluginFactory.cpp |
diffstat | 1 files changed, 33 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin/FeatureExtractionPluginFactory.cpp Mon Mar 12 15:36:31 2007 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Tue Mar 20 11:49:11 2007 +0000 @@ -137,14 +137,42 @@ const VampPluginDescriptor *descriptor = 0; int index = 0; + std::map<std::string, int> known; + bool ok = true; + while ((descriptor = fn(VAMP_API_VERSION, index))) { - QString id = PluginIdentifier::createIdentifier - ("vamp", soname, descriptor->identifier); - rv.push_back(id); + + if (known.find(descriptor->identifier) != known.end()) { + std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library " + << soname.toStdString() + << " returns the same plugin identifier \"" + << descriptor->identifier << "\" at indices " + << known[descriptor->identifier] << " and " + << index << std::endl; + std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl; + ok = false; + break; + } else { + known[descriptor->identifier] = index; + } + + ++index; + } + + if (ok) { + + index = 0; + + while ((descriptor = fn(VAMP_API_VERSION, index))) { + + QString id = PluginIdentifier::createIdentifier + ("vamp", soname, descriptor->identifier); + rv.push_back(id); #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << std::endl; + std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl; #endif - ++index; + ++index; + } } if (DLCLOSE(libraryHandle) != 0) {