If I add a new file type a crash in debug mode can occur in case two unsorted lists are to be merged.
(mitkCoreObjectFactory.cpp line 402)
I don't even understand why a writer of a new datatype has to be added to m_FileWriters and to m_ExtraFactories like:
static bool already_registered = false;
if ( !already_registered ) { MyIOFactory::RegisterOneFactory(); MyWriterFactory::RegisterOneFactory(); // Member of superclass so against Stryker naming conventions. m_FileWriters.push_back( MyWriter::New().GetPointer() ); mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(this); CreateFileExtensionsMap(); already_registered = true; }
Given above mentioned section:
mitk::CoreObjectFactory::FileWriterList mitk::CoreObjectFactory::GetFileWriters() {
FileWriterList allWriters = m_FileWriters; for (ExtraFactoriesContainer::iterator it = m_ExtraFactories.begin(); it != m_ExtraFactories.end() ; it++ ) { FileWriterList list2 = (*it)->GetFileWriters(); allWriters.merge(list2); } return allWriters;
}
leads to an instance of MyWriter in m_FileWriters and thus as a copy in allWriters and then all extra Factories are asked for their writers so once more its added and merged to allWriters.
If I choose to only register my factory via RegisterExtraFactory it doesn't work either.
A work around would be to
sort the list prior to merging or to choose a different container.
A callstack is in T14866.
;) Best Regards,
Ingmar