From Jeremy Moles, refactored by Robert Osfield.

Fixed bug osgDB::Registry::Registry::read(const ReadFunctor& readFunctor) relating to
the handling of failed loads with the ReadResult::_message value being lost, this changes
ensure that the original ReadResult from the plugin, with message intact, is returned correctly.
This commit is contained in:
Robert Osfield
2006-08-05 20:36:49 +00:00
parent f8490e386a
commit 6c419af79c

View File

@@ -1357,7 +1357,8 @@ ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor)
unsigned int num_FILE_NOT_FOUND = 0;
unsigned int num_ERROR_IN_READING_FILE = 0;
for(Results::iterator ritr=results.begin();
Results::iterator ritr;
for(ritr=results.begin();
ritr!=results.end();
++ritr)
{
@@ -1368,16 +1369,22 @@ ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor)
if (num_FILE_NOT_HANDLED!=results.size())
{
// we've come across a file not found or error in reading file.
if (num_ERROR_IN_READING_FILE)
for(ritr=results.begin(); ritr!=results.end(); ++ritr)
{
osg::notify(osg::NOTICE)<<"Warning: error reading file \""<<readFunctor._filename<<"\""<<std::endl;
return ReaderWriter::ReadResult(ReaderWriter::ReadResult::ERROR_IN_READING_FILE);
if (ritr->status()==ReaderWriter::ReadResult::ERROR_IN_READING_FILE)
{
osg::notify(osg::NOTICE)<<"Warning: error reading file \""<<readFunctor._filename<<"\""<<std::endl;
return *ritr;
}
}
else if (num_FILE_NOT_FOUND)
for(ritr=results.begin(); ritr!=results.end(); ++ritr)
{
osg::notify(osg::NOTICE)<<"Warning: could not find file \""<<readFunctor._filename<<"\""<<std::endl;
return ReaderWriter::ReadResult(ReaderWriter::ReadResult::FILE_NOT_FOUND);
if (ritr->status()==ReaderWriter::ReadResult::FILE_NOT_FOUND)
{
osg::notify(osg::NOTICE)<<"Warning: could not find file \""<<readFunctor._filename<<"\""<<std::endl;
return *ritr;
}
}
}
}