Skip to content
Browse files

factor out OnCachingComplete from OnJobComplete - we shouldn't really…

… be calling OnJobComplete on a job not in the queue
  • Loading branch information...
1 parent b1d686d commit abded5e44353de2da80f1061f37e6b681f02f099 Jonathan Marshall committed May 26, 2012
Showing with 32 additions and 22 deletions.
  1. +24 −22 xbmc/TextureCache.cpp
  2. +8 −0 xbmc/TextureCache.h
View
46 xbmc/TextureCache.cpp
@@ -172,7 +172,7 @@ CStdString CTextureCache::CacheImage(const CStdString &image, CBaseTexture **tex
// cache the texture directly
CTextureCacheJob job(url);
bool success = job.CacheTexture(texture);
- OnJobComplete(0, success, &job);
+ OnCachingComplete(success, &job);
return success ? GetCachedPath(job.m_details.file) : "";
}
lock.Leave();
@@ -258,32 +258,34 @@ CStdString CTextureCache::GetCachedPath(const CStdString &file)
return URIUtils::AddFileToFolder(g_settings.GetThumbnailsFolder(), file);
}
-void CTextureCache::OnJobComplete(unsigned int jobID, bool success, CJob *job)
+void CTextureCache::OnCachingComplete(bool success, CTextureCacheJob *job)
{
- if (strcmp(job->GetType(), "cacheimage") == 0)
+ if (success)
{
- CTextureCacheJob *cacheJob = (CTextureCacheJob *)job;
- if (success)
- {
- if (cacheJob->m_oldHash == cacheJob->m_details.hash)
- SetCachedTextureValid(cacheJob->m_url, cacheJob->m_details.updateable);
- else
- AddCachedTexture(cacheJob->m_url, cacheJob->m_details);
- }
+ if (job->m_oldHash == job->m_details.hash)
+ SetCachedTextureValid(job->m_url, job->m_details.updateable);
+ else
+ AddCachedTexture(job->m_url, job->m_details);
+ }
- { // remove from our processing list
- CSingleLock lock(m_processingSection);
- std::set<CStdString>::iterator i = m_processing.find(cacheJob->m_url);
- if (i != m_processing.end())
- m_processing.erase(i);
- }
+ { // 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);
+ }
- m_completeEvent.Set();
+ m_completeEvent.Set();
- // TODO: call back to the UI indicating that it can update it's image...
- if (success && g_advancedSettings.m_useDDSFanart && !cacheJob->m_details.file.empty())
- AddJob(new CTextureDDSJob(GetCachedPath(cacheJob->m_details.file)));
- }
+ // TODO: call back to the UI indicating that it can update it's image...
+ if (success && g_advancedSettings.m_useDDSFanart && !job->m_details.file.empty())
+ AddJob(new CTextureDDSJob(GetCachedPath(job->m_details.file)));
+}
+
+void CTextureCache::OnJobComplete(unsigned int jobID, bool success, CJob *job)
+{
+ if (strcmp(job->GetType(), "cacheimage") == 0)
+ OnCachingComplete(success, (CTextureCacheJob *)job);
return CJobQueue::OnJobComplete(jobID, success, job);
}
View
8 xbmc/TextureCache.h
@@ -203,6 +203,14 @@ class CTextureCache : public CJobQueue
virtual void OnJobComplete(unsigned int jobID, bool success, CJob *job);
virtual void OnJobProgress(unsigned int jobID, unsigned int progress, unsigned int total, const CJob *job);
+ /*! \brief Called when a caching job has completed.
+ Removes the job from our processing list, updates the database
+ and fires a DDS job if appropriate.
+ \param success whether the job was successful.
+ \param job the caching job.
+ */
+ void OnCachingComplete(bool success, CTextureCacheJob *job);
+
CCriticalSection m_databaseSection;
CTextureDatabase m_database;
std::set<CStdString> m_processing; ///< currently processing list to avoid 2 jobs being processed at once

0 comments on commit abded5e

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