Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[musicdb] fix album & artist lt operators, used for set/map (e.g. cache)

  • Loading branch information...
commit 4c94130c68677f68e767fa78b5bd4b170b241f22 1 parent a339cc5
@night199uk night199uk authored
Showing with 25 additions and 6 deletions.
  1. +11 −2 xbmc/music/Album.cpp
  2. +14 −4 xbmc/music/Artist.h
View
13 xbmc/music/Album.cpp
@@ -55,8 +55,17 @@ CStdString CAlbum::GetGenreString() const
bool CAlbum::operator<(const CAlbum &a) const
{
- if (strAlbum < a.strAlbum) return true;
- if (strAlbum > a.strAlbum) return false;
+ if (strMusicBrainzAlbumID.IsEmpty() && a.strMusicBrainzAlbumID.IsEmpty())
+ {
+ if (strAlbum < a.strAlbum) return true;
+ if (strAlbum > a.strAlbum) return false;
+
+ // This will do an std::vector compare (i.e. item by item)
+ if (artist < a.artist) return true;
+ if (artist > a.artist) return false;
+ return false;
+ }
+
if (strMusicBrainzAlbumID < a.strMusicBrainzAlbumID) return true;
if (strMusicBrainzAlbumID > a.strMusicBrainzAlbumID) return false;
return false;
View
18 xbmc/music/Artist.h
@@ -36,8 +36,13 @@ class CArtist
long idArtist;
bool operator<(const CArtist& a) const
{
- if (strArtist < a.strArtist) return true;
- if (strArtist > a.strArtist) return false;
+ if (strMusicBrainzArtistID.IsEmpty() && a.strMusicBrainzArtistID.IsEmpty())
+ {
+ if (strArtist < a.strArtist) return true;
+ if (strArtist > a.strArtist) return false;
+ return false;
+ }
+
if (strMusicBrainzArtistID < a.strMusicBrainzArtistID) return true;
if (strMusicBrainzArtistID > a.strMusicBrainzArtistID) return false;
return false;
@@ -102,8 +107,13 @@ class CArtistCredit
: m_strArtist(strArtist), m_strMusicBrainzArtistID(strMusicBrainzArtistID), m_strJoinPhrase(strJoinPhrase), m_boolFeatured(false) { }
bool operator<(const CArtistCredit& a) const
{
- if (m_strArtist < a.m_strArtist) return true;
- if (m_strArtist > a.m_strArtist) return false;
+ if (m_strMusicBrainzArtistID.empty() && a.m_strMusicBrainzArtistID.empty())
+ {
+ if (m_strArtist < a.m_strArtist) return true;
+ if (m_strArtist > a.m_strArtist) return false;
+ return false;
+ }
+
if (m_strMusicBrainzArtistID < a.m_strMusicBrainzArtistID) return true;
if (m_strMusicBrainzArtistID > a.m_strMusicBrainzArtistID) return false;
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.