fixed: Folder thumbs would not show in the playlist for music files (thanks Jonathan)
authorarnova <arnova@void.org>
Fri, 16 Nov 2012 17:40:40 +0000 (18:40 +0100)
committerarnova <arnova@void.org>
Tue, 20 Nov 2012 07:48:07 +0000 (08:48 +0100)
xbmc/FileItem.cpp
xbmc/FileItem.h
xbmc/music/MusicInfoLoader.cpp
xbmc/music/MusicThumbLoader.cpp

index 1931cf0..2a2a297 100644 (file)
@@ -2619,7 +2619,7 @@ bool CFileItemList::AlwaysCache() const
   return false;
 }
 
-CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */) const
+CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */, bool fallbackToFolder /* = false */) const
 {
   if (m_strPath.IsEmpty()
    || m_bIsShareOrDrive
@@ -2637,6 +2637,13 @@ CStdString CFileItem::GetUserMusicThumb(bool alwaysCheckRemote /* = false */) co
   if (CFile::Exists(fileThumb))
     return fileThumb;
 
+  // Fall back to folder thumb, if requested
+  if (!m_bIsFolder && fallbackToFolder)
+  {
+    CFileItem item(URIUtils::GetDirectory(m_strPath), true);
+    return item.GetUserMusicThumb(alwaysCheckRemote);
+  }
+
   // if a folder, check for folder.jpg
   if (m_bIsFolder && !IsFileFolder() && (!IsRemote() || alwaysCheckRemote || g_guiSettings.GetBool("musicfiles.findremotethumbs")))
   {
index 31f68f5..c51a73f 100644 (file)
@@ -307,7 +307,7 @@ public:
   CStdString GetBaseMoviePath(bool useFolderNames) const;
 
   // Gets the user thumb, if it exists
-  CStdString GetUserMusicThumb(bool alwaysCheckRemote = false) const;
+  CStdString GetUserMusicThumb(bool alwaysCheckRemote = false, bool fallbackToFolder = false) const;
 
   /*! \brief Get the path where we expect local metadata to reside.
    For a folder, this is just the existing path (eg tvshow folder)
index b8a68db..8eb05c4 100644 (file)
@@ -131,22 +131,17 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
   if (pItem->m_bIsFolder || pItem->IsPlayList() || pItem->IsNFO() || pItem->IsInternetStream())
     return false;
 
-  // Get thumb for item
-  if (m_thumbLoader)
-    m_thumbLoader->LoadItem(pItem);
-
-  if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded())
-    return true;
-
+  if (!pItem->HasMusicInfoTag() || !pItem->GetMusicInfoTag()->Loaded())
+  {
   // first check the cached item
   CFileItemPtr mapItem = (*m_mapFileItems)[pItem->GetPath()];
   if (mapItem && mapItem->m_dateTime==pItem->m_dateTime && mapItem->HasMusicInfoTag() && mapItem->GetMusicInfoTag()->Loaded())
   { // Query map if we previously cached the file on HD
     *pItem->GetMusicInfoTag() = *mapItem->GetMusicInfoTag();
     pItem->SetArt("thumb", mapItem->GetArt("thumb"));
-    return true;
   }
-
+    else
+    {
   CStdString strPath;
   URIUtils::GetDirectory(pItem->GetPath(), strPath);
   URIUtils::AddSlashAtEnd(strPath);
@@ -188,6 +183,12 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
   }
 
   m_strPrevPath = strPath;
+    }
+  }
+
+  // Get thumb for item
+  m_thumbLoader->LoadItem(pItem);
+
   return true;
 }
 
index d371bb9..29cbba3 100644 (file)
@@ -107,7 +107,7 @@ bool CMusicThumbLoader::FillThumb(CFileItem &item)
   CStdString thumb = GetCachedImage(item, "thumb");
   if (thumb.IsEmpty())
   {
-    thumb = item.GetUserMusicThumb();
+    thumb = item.GetUserMusicThumb(false, true);
     if (!thumb.IsEmpty())
       SetCachedImage(item, "thumb", thumb);
   }