diff options
author | tamland <thomas.amland@gmail.com> | 2016-08-02 21:54:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-02 21:54:30 +0200 |
commit | f5f9dc515caf8d98aa6e972ca55331145f85d457 (patch) | |
tree | da102a4392bcbcea5f138d897ff598e7d3aa3516 | |
parent | 282cb04bfacc768e65a488d80875645c4042fff5 (diff) | |
parent | a0f72af516b6720a5cfd213396fa78b738ce3fa2 (diff) |
Merge pull request #10203 from tamland/fix_listprovider_updating
fix listprovider updating
-rw-r--r-- | xbmc/listproviders/DirectoryProvider.cpp | 50 | ||||
-rw-r--r-- | xbmc/listproviders/DirectoryProvider.h | 3 |
2 files changed, 24 insertions, 29 deletions
diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp index d01d6fa07d..17657413eb 100644 --- a/xbmc/listproviders/DirectoryProvider.cpp +++ b/xbmc/listproviders/DirectoryProvider.cpp @@ -192,30 +192,33 @@ bool CDirectoryProvider::Update(bool forceRefresh) // we never need to force refresh here bool changed = false; bool fireJob = false; - { - CSingleLock lock(m_section); - if (m_updateState == DONE) - changed = true; - else if (m_updateState == PENDING) - fireJob = true; - m_updateState = OK; - } // update the URL & limit and fire off a new job if needed fireJob |= UpdateURL(); fireJob |= UpdateSort(); fireJob |= UpdateLimit(); + + CSingleLock lock(m_section); + if (m_updateState == INVALIDATED) + fireJob = true; + else if (m_updateState == DONE) + changed = true; + + m_updateState = OK; + if (fireJob) { - { - CSingleLock lock(m_section); - CLog::Log(LOGDEBUG, "CDirectoryProvider[%s]: refreshing..", m_currentUrl.c_str()); - } - FireJob(); + CLog::Log(LOGDEBUG, "CDirectoryProvider[%s]: refreshing..", m_currentUrl.c_str()); + if (m_jobID) + CJobManager::GetInstance().CancelJob(m_jobID); + m_jobID = CJobManager::GetInstance().AddJob(new CDirectoryJob(m_currentUrl, m_currentSort, m_currentLimit, m_parentID), this); } - for (std::vector<CGUIStaticItemPtr>::iterator i = m_items.begin(); i != m_items.end(); ++i) - changed |= (*i)->UpdateVisibility(m_parentID); + if (!changed) + { + for (std::vector<CGUIStaticItemPtr>::iterator i = m_items.begin(); i != m_items.end(); ++i) + changed |= (*i)->UpdateVisibility(m_parentID); + } return changed; //! @todo Also returned changed if properties are changed (if so, need to update scroll to letter). } @@ -245,7 +248,7 @@ void CDirectoryProvider::Announce(AnnouncementFlag flag, const char *sender, con strcmp(message, "OnCleanFinished") == 0 || strcmp(message, "OnUpdate") == 0 || strcmp(message, "OnRemove") == 0) - m_updateState = PENDING; + m_updateState = INVALIDATED; } } @@ -269,7 +272,7 @@ void CDirectoryProvider::OnEvent(const ADDON::AddonEvent& event) typeid(event) == typeid(ADDON::AddonEvents::Disabled) || typeid(event) == typeid(ADDON::AddonEvents::InstalledChanged) || typeid(event) == typeid(ADDON::AddonEvents::MetadataChanged)) - m_updateState = PENDING; + m_updateState = INVALIDATED; } } @@ -303,7 +306,8 @@ void CDirectoryProvider::OnJobComplete(unsigned int jobID, bool success, CJob *j m_items = ((CDirectoryJob*)job)->GetItems(); m_currentTarget = ((CDirectoryJob*)job)->GetTarget(); ((CDirectoryJob*)job)->GetItemTypes(m_itemTypes); - m_updateState = DONE; + if (m_updateState == OK) + m_updateState = DONE; } m_jobID = 0; } @@ -367,15 +371,7 @@ bool CDirectoryProvider::OnContextMenu(const CGUIListItemPtr& item) bool CDirectoryProvider::IsUpdating() const { CSingleLock lock(m_section); - return m_jobID || (m_updateState == DONE); -} - -void CDirectoryProvider::FireJob() -{ - CSingleLock lock(m_section); - if (m_jobID) - CJobManager::GetInstance().CancelJob(m_jobID); - m_jobID = CJobManager::GetInstance().AddJob(new CDirectoryJob(m_currentUrl, m_currentSort, m_currentLimit, m_parentID), this); + return m_jobID || m_updateState == DONE || m_updateState == INVALIDATED; } void CDirectoryProvider::RegisterListProvider() diff --git a/xbmc/listproviders/DirectoryProvider.h b/xbmc/listproviders/DirectoryProvider.h index 1b0a7e367c..d5de8c99ec 100644 --- a/xbmc/listproviders/DirectoryProvider.h +++ b/xbmc/listproviders/DirectoryProvider.h @@ -49,7 +49,7 @@ public: typedef enum { OK, - PENDING, + INVALIDATED, DONE } UpdateState; @@ -84,7 +84,6 @@ private: std::vector<InfoTagType> m_itemTypes; CCriticalSection m_section; - void FireJob(); void RegisterListProvider(); bool UpdateURL(); bool UpdateLimit(); |