# HG changeset patch # User Chris Cannam # Date 1174391351 0 # Node ID db0dd744fa8d59224b7154cb5d7bba9990e527d3 # Parent 40db5491bcf82c7c3294eddc2a83d3efee69e15c * Fix hang and memory leak on startup when encountering a pre-Vamp-1.0 plugin diff -r 40db5491bcf8 -r db0dd744fa8d plugin/FeatureExtractionPluginFactory.cpp --- 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 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) {