diff options
author | Jonathan Marshall <jmarshall@never.you.mind> | 2012-05-26 15:48:03 +1200 |
---|---|---|
committer | Jonathan Marshall <jmarshall@never.you.mind> | 2012-05-26 15:54:39 +1200 |
commit | abded5e44353de2da80f1061f37e6b681f02f099 (patch) | |
tree | 759dcde92198550bc1240f012a7c6af15fd02235 | |
parent | b1d686dae222ff452a6db2c9d7132b4152511054 (diff) |
factor out OnCachingComplete from OnJobComplete - we shouldn't really be calling OnJobComplete on a job not in the queue
-rw-r--r-- | xbmc/TextureCache.cpp | 46 | ||||
-rw-r--r-- | xbmc/TextureCache.h | 8 |
2 files changed, 32 insertions, 22 deletions
diff --git a/xbmc/TextureCache.cpp b/xbmc/TextureCache.cpp index ab04ea8ced..9d63405039 100644 --- a/xbmc/TextureCache.cpp +++ b/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); } diff --git a/xbmc/TextureCache.h b/xbmc/TextureCache.h index 0ccb78956f..22a51be273 100644 --- a/xbmc/TextureCache.h +++ b/xbmc/TextureCache.h @@ -203,6 +203,14 @@ private: 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 |