Skip to content

Commit

Permalink
drop unneeded tracking of database updating, using the 'transaction' …
Browse files Browse the repository at this point in the history
…attribute of OnUpdate/OnRemove instead
  • Loading branch information
Jonathan Marshall committed May 3, 2014
1 parent 1c8ec0a commit 08ef3d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
17 changes: 4 additions & 13 deletions xbmc/listproviders/DirectoryProvider.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -304,7 +296,6 @@ void CDirectoryProvider::RegisterListProvider(bool hasLibraryContent)
else if (!hasLibraryContent && m_isAnnounced)
{
m_isAnnounced = false;
m_isDbUpdating = false;
CAnnouncementManager::RemoveAnnouncer(this);
}
}
Expand Down
1 change: 0 additions & 1 deletion xbmc/listproviders/DirectoryProvider.h
Expand Up @@ -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;
Expand Down
17 changes: 4 additions & 13 deletions xbmc/windows/GUIWindowHome.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion xbmc/windows/GUIWindowHome.h
Expand Up @@ -45,5 +45,4 @@ class CGUIWindowHome :

bool m_recentlyAddedRunning;
int m_cumulativeUpdateFlag;
bool m_dbUpdating;
};

0 comments on commit 08ef3d5

Please sign in to comment.