Merge pull request #4775 from jmarshallnz/empty_episode_playcount
[vuplus_xbmc] / xbmc / TextureCache.cpp
index 7f356b7..8b45d39 100644 (file)
@@ -27,6 +27,7 @@
 #include "settings/AdvancedSettings.h"
 #include "utils/log.h"
 #include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
 #include "URL.h"
 #include "utils/StringUtils.h"
 
@@ -65,6 +66,7 @@ bool CTextureCache::IsCachedImage(const CStdString &url) const
   if (url != "-" && !CURL::IsFullPath(url))
     return true;
   if (URIUtils::IsInPath(url, "special://skin/") ||
+      URIUtils::IsInPath(url, "special://temp/") ||
       URIUtils::IsInPath(url, "androidapp://")   ||
       URIUtils::IsInPath(url, CProfilesManager::Get().GetThumbnailsFolder()))
     return true;
@@ -75,7 +77,7 @@ bool CTextureCache::HasCachedImage(const CStdString &url)
 {
   CTextureDetails details;
   CStdString cachedImage(GetCachedImage(url, details));
-  return (!cachedImage.IsEmpty() && cachedImage != url);
+  return (!cachedImage.empty() && cachedImage != url);
 }
 
 CStdString CTextureCache::GetCachedImage(const CStdString &image, CTextureDetails &details, bool trackUsage)
@@ -105,7 +107,7 @@ CStdString CTextureCache::CheckCachedImage(const CStdString &url, bool returnDDS
   CTextureDetails details;
   CStdString path(GetCachedImage(url, details, true));
   needsRecaching = !details.hash.empty();
-  if (!path.IsEmpty())
+  if (!path.empty())
   {
     if (!needsRecaching && returnDDS && !URIUtils::IsInPath(url, "special://skin/")) // TODO: should skin images be .dds'd (currently they're not necessarily writeable)
     { // check for dds version
@@ -124,7 +126,7 @@ void CTextureCache::BackgroundCacheImage(const CStdString &url)
 {
   CTextureDetails details;
   CStdString path(GetCachedImage(url, details));
-  if (!path.IsEmpty() && details.hash.empty())
+  if (!path.empty() && details.hash.empty())
     return; // image is already cached and doesn't need to be checked further
 
   // needs (re)caching
@@ -144,9 +146,9 @@ CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **tex
 {
   CStdString url = CTextureUtils::UnwrapImageURL(image);
   CSingleLock lock(m_processingSection);
-  if (m_processing.find(url) == m_processing.end())
+  if (m_processinglist.find(url) == m_processinglist.end())
   {
-    m_processing.insert(url);
+    m_processinglist.insert(url);
     lock.Leave();
     // cache the texture directly
     CTextureCacheJob job(url);
@@ -164,7 +166,7 @@ CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **tex
     m_completeEvent.WaitMSec(1000);
     {
       CSingleLock lock(m_processingSection);
-      if (m_processing.find(url) == m_processing.end())
+      if (m_processinglist.find(url) == m_processinglist.end())
         break;
     }
   }
@@ -251,10 +253,8 @@ CStdString CTextureCache::GetCacheFile(const CStdString &url)
 {
   Crc32 crc;
   crc.ComputeFromLowerCase(url);
-  CStdString hex;
-  hex.Format("%08x", (unsigned int)crc);
-  CStdString hash;
-  hash.Format("%c/%s", hex[0], hex.c_str());
+  CStdString hex = StringUtils::Format("%08x", (unsigned int)crc);
+  CStdString hash = StringUtils::Format("%c/%s", hex[0], hex.c_str());
   return hash;
 }
 
@@ -275,9 +275,9 @@ void CTextureCache::OnCachingComplete(bool success, CTextureCacheJob *job)
 
   { // remove from our processing list
     CSingleLock lock(m_processingSection);
-    std::set<CStdString>::iterator i = m_processing.find(job->m_url);
-    if (i != m_processing.end())
-      m_processing.erase(i);
+    std::set<CStdString>::iterator i = m_processinglist.find(job->m_url);
+    if (i != m_processinglist.end())
+      m_processinglist.erase(i);
   }
 
   m_completeEvent.Set();
@@ -301,10 +301,10 @@ void CTextureCache::OnJobProgress(unsigned int jobID, unsigned int progress, uns
     {
       CSingleLock lock(m_processingSection);
       const CTextureCacheJob *cacheJob = (CTextureCacheJob *)job;
-      std::set<CStdString>::iterator i = m_processing.find(cacheJob->m_url);
-      if (i == m_processing.end())
+      std::set<CStdString>::iterator i = m_processinglist.find(cacheJob->m_url);
+      if (i == m_processinglist.end())
       {
-        m_processing.insert(cacheJob->m_url);
+        m_processinglist.insert(cacheJob->m_url);
         return;
       }
     }
@@ -318,7 +318,7 @@ bool CTextureCache::Export(const CStdString &image, const CStdString &destinatio
 {
   CTextureDetails details;
   CStdString cachedImage(GetCachedImage(image, details));
-  if (!cachedImage.IsEmpty())
+  if (!cachedImage.empty())
   {
     CStdString dest = destination + URIUtils::GetExtension(cachedImage);
     if (overwrite || !CFile::Exists(dest))
@@ -335,7 +335,7 @@ bool CTextureCache::Export(const CStdString &image, const CStdString &destinatio
 {
   CTextureDetails details;
   CStdString cachedImage(GetCachedImage(image, details));
-  if (!cachedImage.IsEmpty())
+  if (!cachedImage.empty())
   {
     if (CFile::Cache(cachedImage, destination))
       return true;