Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 4c94130c68677f68e767fa78b5bd4b170b241f22 1 parent a339cc5
night199uk authored July 10, 2013
13  xbmc/music/Album.cpp
@@ -55,8 +55,17 @@ CStdString CAlbum::GetGenreString() const
55 55
 
56 56
 bool CAlbum::operator<(const CAlbum &a) const
57 57
 {
58  
-  if (strAlbum < a.strAlbum) return true;
59  
-  if (strAlbum > a.strAlbum) return false;
  58
+  if (strMusicBrainzAlbumID.IsEmpty() && a.strMusicBrainzAlbumID.IsEmpty())
  59
+  {
  60
+    if (strAlbum < a.strAlbum) return true;
  61
+    if (strAlbum > a.strAlbum) return false;
  62
+
  63
+    // This will do an std::vector compare (i.e. item by item)
  64
+    if (artist < a.artist) return true;
  65
+    if (artist > a.artist) return false;
  66
+    return false;
  67
+  }
  68
+
60 69
   if (strMusicBrainzAlbumID < a.strMusicBrainzAlbumID) return true;
61 70
   if (strMusicBrainzAlbumID > a.strMusicBrainzAlbumID) return false;
62 71
   return false;
18  xbmc/music/Artist.h
@@ -36,8 +36,13 @@ class CArtist
36 36
   long idArtist;
37 37
   bool operator<(const CArtist& a) const
38 38
   {
39  
-    if (strArtist < a.strArtist) return true;
40  
-    if (strArtist > a.strArtist) return false;
  39
+    if (strMusicBrainzArtistID.IsEmpty() && a.strMusicBrainzArtistID.IsEmpty())
  40
+    {
  41
+      if (strArtist < a.strArtist) return true;
  42
+      if (strArtist > a.strArtist) return false;
  43
+      return false;
  44
+    }
  45
+
41 46
     if (strMusicBrainzArtistID < a.strMusicBrainzArtistID) return true;
42 47
     if (strMusicBrainzArtistID > a.strMusicBrainzArtistID) return false;
43 48
     return false;
@@ -102,8 +107,13 @@ class CArtistCredit
102 107
   : m_strArtist(strArtist), m_strMusicBrainzArtistID(strMusicBrainzArtistID), m_strJoinPhrase(strJoinPhrase), m_boolFeatured(false)  {  }
103 108
   bool operator<(const CArtistCredit& a) const
104 109
   {
105  
-    if (m_strArtist < a.m_strArtist) return true;
106  
-    if (m_strArtist > a.m_strArtist) return false;
  110
+    if (m_strMusicBrainzArtistID.empty() && a.m_strMusicBrainzArtistID.empty())
  111
+    {
  112
+      if (m_strArtist < a.m_strArtist) return true;
  113
+      if (m_strArtist > a.m_strArtist) return false;
  114
+      return false;
  115
+    }
  116
+
107 117
     if (m_strMusicBrainzArtistID < a.m_strMusicBrainzArtistID) return true;
108 118
     if (m_strMusicBrainzArtistID > a.m_strMusicBrainzArtistID) return false;
109 119
     return false;

0 notes on commit 4c94130

Please sign in to comment.
Something went wrong with that request. Please try again.