From 6402db2a386a7b1f89fc2fd0067b9fd16ee8cc24 Mon Sep 17 00:00:00 2001 From: montellese Date: Sat, 15 Nov 2014 10:13:43 +0100 Subject: [PATCH] videodb: cleanup paramters of CleanDatabase() --- xbmc/Application.cpp | 5 ++++- xbmc/video/VideoDatabase.cpp | 13 +++---------- xbmc/video/VideoDatabase.h | 2 +- xbmc/video/VideoInfoScanner.cpp | 7 ++++--- xbmc/video/VideoInfoScanner.h | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp index 0f09193b01255..d8f5fa382fbd5 100644 --- a/xbmc/Application.cpp +++ b/xbmc/Application.cpp @@ -4978,7 +4978,10 @@ void CApplication::StartVideoCleanup(bool userInitiated /* = true */) return; if (userInitiated) - m_videoInfoScanner->CleanDatabase(NULL, NULL, true); + { + std::set paths; + m_videoInfoScanner->CleanDatabase(NULL, paths, userInitiated); + } else { m_videoInfoScanner->ShowDialog(false); diff --git a/xbmc/video/VideoDatabase.cpp b/xbmc/video/VideoDatabase.cpp index 4346379f91dd2..f862563ab7fdd 100644 --- a/xbmc/video/VideoDatabase.cpp +++ b/xbmc/video/VideoDatabase.cpp @@ -7816,7 +7816,7 @@ void CVideoDatabase::GetMusicVideoDirectorsByName(const std::string& strSearch, } } -void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const set* paths, bool showProgress) +void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const set& paths, bool showProgress) { CGUIDialogProgress *progress=NULL; try @@ -7832,17 +7832,10 @@ void CVideoDatabase::CleanDatabase(CGUIDialogProgressBarHandle* handle, const se // find all the files std::string sql = "SELECT files.idFile, files.strFileName, path.strPath FROM files, path WHERE files.idPath = path.idPath"; - if (paths) + if (!paths.empty()) { - if (paths->empty()) - { - RollbackTransaction(); - ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnCleanFinished"); - return; - } - std::string strPaths; - for (std::set::const_iterator it = paths->begin(); it != paths->end(); ++it) + for (std::set::const_iterator it = paths.begin(); it != paths.end(); ++it) strPaths += StringUtils::Format(",%i", *it); sql += PrepareSQL(" AND path.idPath IN (%s)", strPaths.substr(1).c_str()); } diff --git a/xbmc/video/VideoDatabase.h b/xbmc/video/VideoDatabase.h index fcab0a865d9ad..8942b439f4784 100644 --- a/xbmc/video/VideoDatabase.h +++ b/xbmc/video/VideoDatabase.h @@ -668,7 +668,7 @@ class CVideoDatabase : public CDatabase bool HasContent(VIDEODB_CONTENT_TYPE type); bool HasSets() const; - void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set* paths=NULL, bool showProgress=true); + void CleanDatabase(CGUIDialogProgressBarHandle* handle = NULL, const std::set& paths = std::set(), bool showProgress = true); /*! \brief Add a file to the database, if necessary If the file is already in the database, we simply return its id. diff --git a/xbmc/video/VideoInfoScanner.cpp b/xbmc/video/VideoInfoScanner.cpp index b7244a1fd04ea..ce25e7b2d8163 100644 --- a/xbmc/video/VideoInfoScanner.cpp +++ b/xbmc/video/VideoInfoScanner.cpp @@ -89,7 +89,8 @@ namespace VIDEO // check if we only need to perform a cleaning if (m_bClean && m_pathsToScan.empty()) { - CleanDatabase(m_handle, NULL, false); + std::set paths; + CleanDatabase(m_handle, paths, false); if (m_handle) m_handle->MarkFinished(); @@ -147,7 +148,7 @@ namespace VIDEO if (!bCancelled) { if (m_bClean) - CleanDatabase(m_handle,&m_pathsToClean, false); + CleanDatabase(m_handle, m_pathsToClean, false); else { if (m_handle) @@ -244,7 +245,7 @@ namespace VIDEO StopThread(false); } - void CVideoInfoScanner::CleanDatabase(CGUIDialogProgressBarHandle* handle /*= NULL */, const set* paths /*= NULL */, bool showProgress /*= true */) + void CVideoInfoScanner::CleanDatabase(CGUIDialogProgressBarHandle* handle /* = NULL */, const set& paths /* = set */, bool showProgress /* = true */) { m_bRunning = true; m_database.Open(); diff --git a/xbmc/video/VideoInfoScanner.h b/xbmc/video/VideoInfoScanner.h index af63b1e7b3646..7d97cbc1c9d1a 100644 --- a/xbmc/video/VideoInfoScanner.h +++ b/xbmc/video/VideoInfoScanner.h @@ -61,7 +61,7 @@ namespace VIDEO void Start(const std::string& strDirectory, bool scanAll = false); void StartCleanDatabase(); bool IsScanning(); - void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set* paths=NULL, bool showProgress=true); + void CleanDatabase(CGUIDialogProgressBarHandle* handle = NULL, const std::set& paths = std::set(), bool showProgress = true); void Stop(); //! \brief Set whether or not to show a progress dialog