Fixed ugly bug in AlgorithmInfo initialisation order

This commit is contained in:
Andrey Kamaev
2012-04-05 16:06:09 +00:00
parent 56e7852e2f
commit fa7e7e54dc
3 changed files with 100 additions and 55 deletions

View File

@@ -149,17 +149,21 @@ struct CV_EXPORTS AlgorithmInfoData
};
static sorted_vector<string, Algorithm::Constructor> alglist;
static sorted_vector<string, Algorithm::Constructor>& alglist()
{
static sorted_vector<string, Algorithm::Constructor> alglist_var;
return alglist_var;
}
void Algorithm::getList(vector<string>& algorithms)
{
alglist.get_keys(algorithms);
alglist().get_keys(algorithms);
}
Ptr<Algorithm> Algorithm::_create(const string& name)
{
Algorithm::Constructor c = 0;
if( !alglist.find(name, c) )
if( !alglist().find(name, c) )
return Ptr<Algorithm>();
return c();
}
@@ -282,7 +286,7 @@ AlgorithmInfo::AlgorithmInfo(const string& _name, Algorithm::Constructor create)
{
data = new AlgorithmInfoData;
data->_name = _name;
alglist.add(_name, create);
alglist().add(_name, create);
}
AlgorithmInfo::~AlgorithmInfo()