Added handling of the possibility of null Options pointers

This commit is contained in:
Robert Osfield 2016-06-29 17:06:48 +01:00
parent 0876677fb2
commit e3c48d9f45

View File

@ -18,7 +18,22 @@ using namespace osgDB;
bool ObjectCache::ClassComp::operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs) const
{
return lhs.first < rhs.first || *lhs.second < *rhs.second;
// check if filename are the same
if (lhs.first < rhs.first) return true;
if (rhs.first < lhs.first) return false;
// check if Options pointers are the same.
if (lhs.second == rhs.second) return false;
// need to compare Options pointers
if (lhs.second.valid() && rhs.second.valid())
{
// lhs & rhs have valid Options objects
return *lhs.second < *rhs.second;
}
// finally use pointer comparison, expecting at least one will be NULL pointer
return lhs.second < rhs.second;
}
////////////////////////////////////////////////////////////////////////////////////////////