Permalink
Browse files

Initialize the database manager on start and on change of profile, so…

… that database updates are attempted only once rather than on every Open().
  • Loading branch information...
1 parent 7e05bb2 commit 0d0eb5550e597535514d867acf4054883d2ed46c Jonathan Marshall committed Jul 7, 2012
Showing with 16 additions and 6 deletions.
  1. +7 −0 xbmc/Application.cpp
  2. +6 −6 xbmc/dbwrappers/Database.cpp
  3. +3 −0 xbmc/settings/Settings.cpp
View
@@ -306,6 +306,7 @@
#include "utils/SaveFileStateJob.h"
#include "utils/AlarmClock.h"
#include "utils/StringUtils.h"
+#include "DatabaseManager.h"
#ifdef _LINUX
#include "XHandle.h"
@@ -709,6 +710,9 @@ bool CApplication::Create()
CAEFactory::SetMute (g_settings.m_bMute);
CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode"));
+ // initialize the addon database (must be before the addon manager is init'd)
+ CDatabaseManager::Get().Initialize(true);
+
// start-up Addons Framework
// currently bails out if either cpluff Dll is unavailable or system dir can not be scanned
if (!CAddonMgr::Get().Init())
@@ -1153,6 +1157,9 @@ bool CApplication::Initialize()
g_curlInterface.Load();
g_curlInterface.Unload();
+ // initialize (and update as needed) our databases
+ CDatabaseManager::Get().Initialize();
+
#ifdef HAS_WEB_SERVER
CWebServer::RegisterRequestHandler(&m_httpImageHandler);
CWebServer::RegisterRequestHandler(&m_httpVfsHandler);
@@ -31,6 +31,7 @@
#include "utils/URIUtils.h"
#include "mysqldataset.h"
#include "sqlitedataset.h"
+#include "DatabaseManager.h"
using namespace AUTOPTR;
@@ -255,17 +256,16 @@ bool CDatabase::Open(const DatabaseSettings &settings)
return true;
}
+ // check our database manager to see if this database can be opened
+ if (!CDatabaseManager::Get().CanOpen(GetBaseDBName()))
+ return false;
+
DatabaseSettings dbSettings = settings;
InitSettings(dbSettings);
CStdString dbName = dbSettings.name;
dbName.AppendFormat("%d", GetMinVersion());
- if (!Connect(dbName, dbSettings, false) || GetDBVersion() != GetMinVersion())
- {
- if (!Update(settings))
- return false;
- }
- return true;
+ return Connect(dbName, dbSettings, false);
}
void CDatabase::InitSettings(DatabaseSettings &dbSettings)
@@ -56,6 +56,7 @@
#include "input/MouseStat.h"
#include "filesystem/File.h"
#include "filesystem/DirectoryCache.h"
+#include "DatabaseManager.h"
using namespace std;
using namespace XFILE;
@@ -950,6 +951,8 @@ bool CSettings::LoadProfile(unsigned int index)
CButtonTranslator::GetInstance().Load(true);
g_localizeStrings.Load("special://xbmc/language/", strLanguage);
+ CDatabaseManager::Get().Initialize();
+
g_Mouse.SetEnabled(g_guiSettings.GetBool("input.enablemouse"));
g_infoManager.ResetCache();

0 comments on commit 0d0eb55

Please sign in to comment.