Permalink
Browse files

changed: Hold the addons database as a member in the AddonManager. Sh…

…ould address #9420

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31140 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 5144280 commit b700e3f7f4bead130df052f6ac83ff2f8ef15670 jmarshallnz committed Jun 17, 2010
Showing with 11 additions and 11 deletions.
  1. +2 −1 xbmc/AddonDatabase.cpp
  2. +0 −1 xbmc/AddonDatabase.h
  3. +2 −0 xbmc/addons/Addon.h
  4. +5 −7 xbmc/addons/AddonManager.cpp
  5. +2 −2 xbmc/addons/AddonManager.h
View
@@ -20,6 +20,7 @@
*/
#include "AddonDatabase.h"
+#include "AddonManager.h"
#include "utils/log.h"
#include "DateTime.h"
#include "StringUtils.h"
@@ -105,7 +106,7 @@ bool CAddonDatabase::UpdateOldVersion(int version)
"changelog text, fanart text, author text)\n");
m_pDS->exec("INSERT INTO addonnew select id,type,name,summary,description,stars,path,addonID,icon,version,changelog,fanart,author from addon");
m_pDS->exec("DROP TABLE addon");
- m_pDS->exec("ALTER TABLE addonnew RENAME TO addon");
+ m_pDS->exec("ALTER TABLE addonnew RENAME TO addon");
}
if (version < 8)
{
View
@@ -22,7 +22,6 @@
#include "Database.h"
#include "addons/Addon.h"
-#include "addons/AddonManager.h"
#include "StdString.h"
#include "FileItem.h"
View
@@ -35,6 +35,8 @@ typedef struct cp_extension_t cp_extension_t;
namespace ADDON
{
+ typedef std::vector<AddonPtr> VECADDONS;
+ typedef std::vector<AddonPtr>::iterator IVECADDONS;
// utils
const CStdString TranslateType(const TYPE &type, bool pretty=false);
@@ -20,7 +20,6 @@
*/
#include "AddonManager.h"
#include "Addon.h"
-#include "AddonDatabase.h"
#include "DllLibCPluff.h"
#include "StringUtils.h"
#include "RegExp.h"
@@ -218,6 +217,8 @@ bool CAddonMgr::Init()
m_cpluff = new DllLibCPluff;
m_cpluff->Load();
+ m_database.Open();
+
if (!m_cpluff->IsLoaded())
{
CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load libcpluff");
@@ -263,6 +264,7 @@ void CAddonMgr::DeInit()
if (m_cpluff)
m_cpluff->destroy();
m_cpluff = NULL;
+ m_database.Close();
}
bool CAddonMgr::HasAddons(const TYPE &type, bool enabled /*= true*/)
@@ -292,14 +294,12 @@ bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* =
addons.clear();
cp_status_t status;
int num;
- CAddonDatabase db;
- if (!db.Open()) return false;
CStdString ext_point(TranslateType(type));
cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
for(int i=0; i <num; i++)
{
AddonPtr addon(Factory(exts[i]));
- if (addon && db.IsAddonDisabled(addon->ID()) != enabled)
+ if (addon && m_database.IsAddonDisabled(addon->ID()) != enabled)
addons.push_back(addon);
}
m_cpluff->release_info(m_cp_context, exts);
@@ -310,15 +310,13 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
{
CSingleLock lock(m_critSection);
- CAddonDatabase db;
- if (!db.Open()) return false;
cp_status_t status;
cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
if (status == CP_OK && cpaddon)
{
addon = GetAddonFromDescriptor(cpaddon);
m_cpluff->release_info(m_cp_context, cpaddon);
- return NULL != addon.get() && db.IsAddonDisabled(addon->ID()) != enabled;
+ return NULL != addon.get() && m_database.IsAddonDisabled(addon->ID()) != enabled;
}
if (cpaddon)
m_cpluff->release_info(m_cp_context, cpaddon);
@@ -29,6 +29,7 @@
#include <vector>
#include <map>
#include <deque>
+#include "AddonDatabase.h"
class DllLibCPluff;
extern "C"
@@ -38,8 +39,6 @@ extern "C"
namespace ADDON
{
- typedef std::vector<AddonPtr> VECADDONS;
- typedef std::vector<AddonPtr>::iterator IVECADDONS;
typedef std::map<TYPE, VECADDONS> MAPADDONS;
typedef std::map<TYPE, VECADDONS>::iterator IMAPADDONS;
typedef std::deque<cp_cfg_element_t*> DEQUEELEMENTS;
@@ -164,6 +163,7 @@ namespace ADDON
static std::map<TYPE, IAddonMgrCallback*> m_managers;
CStopWatch m_watch;
CCriticalSection m_critSection;
+ CAddonDatabase m_database;
};
}; /* namespace ADDON */

0 comments on commit b700e3f

Please sign in to comment.