Fixed invalid iterator bug during clear all in Matlab wrapper

release/4.3a0
Richard Roberts 2012-07-02 22:33:36 +00:00
parent b8a627b19c
commit b163d26d5e
1 changed files with 4 additions and 2 deletions

View File

@ -117,8 +117,10 @@ void Constructor::matlab_wrapper(const string& toolboxPath,
file.oss << "void cleanup(void) {" << endl; file.oss << "void cleanup(void) {" << endl;
//TODO: Remove //TODO: Remove
//file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl; //file.oss << " std::for_each( collector.begin(), collector.end(), Destruct() );" << endl;
file.oss << " BOOST_FOREACH(Shared* p, collector)" << endl; file.oss << " for(std::set<Shared*>::iterator iter = collector.begin(); iter != collector.end(); ) {\n";
file.oss << " collector.erase(p);" << endl; file.oss << " delete *iter;\n";
file.oss << " collector.erase(iter++);\n";
file.oss << " }\n";
file.oss << "}" << endl; file.oss << "}" << endl;
file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl; file.oss << "void mexFunction(int nargout, mxArray *out[], int nargin, const mxArray *in[])" << endl;