fix StepsID::operator<
beware: invalid < operations (where a<b and b<a can both be true) lead to crashes with std::map on glibc
This commit is contained in:
@@ -205,3 +205,13 @@ bool StepsID::IsValid() const
|
|||||||
return st != STEPS_TYPE_INVALID && dc != DIFFICULTY_INVALID;
|
return st != STEPS_TYPE_INVALID && dc != DIFFICULTY_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StepsID::operator<( const StepsID &rhs ) const
|
||||||
|
{
|
||||||
|
#define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false;
|
||||||
|
COMP(st);
|
||||||
|
COMP(dc);
|
||||||
|
COMP(sDescription);
|
||||||
|
COMP(uHash);
|
||||||
|
#undef COMP
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,10 +44,7 @@ public:
|
|||||||
void Unset() { FromSteps(NULL); }
|
void Unset() { FromSteps(NULL); }
|
||||||
void FromSteps( const Steps *p );
|
void FromSteps( const Steps *p );
|
||||||
Steps *ToSteps( const Song *p, bool bAllowNull ) const;
|
Steps *ToSteps( const Song *p, bool bAllowNull ) const;
|
||||||
bool operator<( const StepsID &other ) const
|
bool operator<( const StepsID &rhs ) const;
|
||||||
{
|
|
||||||
return st < other.st || dc < other.dc || sDescription < other.sDescription || uHash < other.uHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
XNode* CreateNode() const;
|
XNode* CreateNode() const;
|
||||||
void LoadFromNode( const XNode* pNode );
|
void LoadFromNode( const XNode* pNode );
|
||||||
|
|||||||
Reference in New Issue
Block a user