Added handling of the possibility of null Options pointers

(cherry picked from commit e3c48d9f45)
This commit is contained in:
Robert Osfield 2016-06-29 17:06:48 +01:00 committed by Ralf Habacker
parent aa95d3f9bf
commit 199651ebbd

View File

@ -18,7 +18,22 @@ using namespace osgDB;
bool ObjectCache::ClassComp::operator() (const ObjectCache::FileNameOptionsPair& lhs, const ObjectCache::FileNameOptionsPair& rhs)
{
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;
}
////////////////////////////////////////////////////////////////////////////////////////////