From 08ef3d5002d37c2f2bd7e568e6a139ad295c3a93 Mon Sep 17 00:00:00 2001 From: Jonathan Marshall Date: Sat, 1 Mar 2014 10:21:31 +1300 Subject: [PATCH] drop unneeded tracking of database updating, using the 'transaction' attribute of OnUpdate/OnRemove instead --- xbmc/listproviders/DirectoryProvider.cpp | 17 ++++------------- xbmc/listproviders/DirectoryProvider.h | 1 - xbmc/windows/GUIWindowHome.cpp | 17 ++++------------- xbmc/windows/GUIWindowHome.h | 1 - 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/xbmc/listproviders/DirectoryProvider.cpp b/xbmc/listproviders/DirectoryProvider.cpp index 65bdb4bd5f27f..28f5389ec95a2 100644 --- a/xbmc/listproviders/DirectoryProvider.cpp +++ b/xbmc/listproviders/DirectoryProvider.cpp @@ -136,7 +136,6 @@ CDirectoryProvider::CDirectoryProvider(const TiXmlElement *element, int parentID : IListProvider(parentID), m_updateTime(0), m_updateState(OK), - m_isDbUpdating(false), m_isAnnounced(false), m_jobID(0) { @@ -194,24 +193,17 @@ void CDirectoryProvider::Announce(AnnouncementFlag flag, const char *sender, con (std::find(m_itemTypes.begin(), m_itemTypes.end(), AUDIO) == m_itemTypes.end()))) return; - // don't update while scanning / cleaning - if (strcmp(message, "OnScanStarted") == 0 || - strcmp(message, "OnCleanStarted") == 0) - { - m_isDbUpdating = true; + // if we're in a database transaction, don't bother doing anything just yet + if (data.isMember("transaction") && data["transaction"].asBoolean()) return; - } // if there was a database update, we set the update state // to PENDING to fire off a new job in the next update if (strcmp(message, "OnScanFinished") == 0 || strcmp(message, "OnCleanFinished") == 0 || - ((strcmp(message, "OnUpdate") == 0 || - strcmp(message, "OnRemove") == 0) && !m_isDbUpdating)) - { - m_isDbUpdating = false; + strcmp(message, "OnUpdate") == 0 || + strcmp(message, "OnRemove") == 0) m_updateState = PENDING; - } } } @@ -304,7 +296,6 @@ void CDirectoryProvider::RegisterListProvider(bool hasLibraryContent) else if (!hasLibraryContent && m_isAnnounced) { m_isAnnounced = false; - m_isDbUpdating = false; CAnnouncementManager::RemoveAnnouncer(this); } } diff --git a/xbmc/listproviders/DirectoryProvider.h b/xbmc/listproviders/DirectoryProvider.h index 2dee7449821d4..06d817c2bdcec 100644 --- a/xbmc/listproviders/DirectoryProvider.h +++ b/xbmc/listproviders/DirectoryProvider.h @@ -65,7 +65,6 @@ class CDirectoryProvider : private: unsigned int m_updateTime; UpdateState m_updateState; - bool m_isDbUpdating; bool m_isAnnounced; unsigned int m_jobID; CGUIInfoLabel m_url; diff --git a/xbmc/windows/GUIWindowHome.cpp b/xbmc/windows/GUIWindowHome.cpp index 5736827474f6c..db8b3f7e63393 100644 --- a/xbmc/windows/GUIWindowHome.cpp +++ b/xbmc/windows/GUIWindowHome.cpp @@ -34,8 +34,7 @@ using namespace ANNOUNCEMENT; CGUIWindowHome::CGUIWindowHome(void) : CGUIWindow(WINDOW_HOME, "Home.xml"), m_recentlyAddedRunning(false), - m_cumulativeUpdateFlag(0), - m_dbUpdating(false) + m_cumulativeUpdateFlag(0) { m_updateRA = (Audio | Video | Totals); m_loadType = KEEP_IN_MEMORY; @@ -83,19 +82,11 @@ void CGUIWindowHome::Announce(AnnouncementFlag flag, const char *sender, const c if ((flag & (VideoLibrary | AudioLibrary)) == 0) return; - if (strcmp(message, "OnScanStarted") == 0 || - strcmp(message, "OnCleanStarted") == 0) - { - m_dbUpdating = true; + if (data.isMember("transaction") && data["transaction"].asBoolean()) return; - } - if (strcmp(message, "OnScanFinished") == 0 || - strcmp(message, "OnCleanFinished") == 0) - m_dbUpdating = false; - - // we are in an update/clean - if (m_dbUpdating) + if (strcmp(message, "OnScanStarted") == 0 || + strcmp(message, "OnCleanStarted") == 0) return; bool onUpdate = strcmp(message, "OnUpdate") == 0; diff --git a/xbmc/windows/GUIWindowHome.h b/xbmc/windows/GUIWindowHome.h index c7b14ccd452b1..214ce57eb7daf 100644 --- a/xbmc/windows/GUIWindowHome.h +++ b/xbmc/windows/GUIWindowHome.h @@ -45,5 +45,4 @@ class CGUIWindowHome : bool m_recentlyAddedRunning; int m_cumulativeUpdateFlag; - bool m_dbUpdating; };