Skip to content

Commit cc3b982

Browse files
author
elupus
committed
fixed: don't crash if an (visualization) addon is disabled
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@28611 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
1 parent 829d35b commit cc3b982

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

xbmc/utils/AddonManager.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void CAddonMgr::UnregisterAddonMgrCallback(TYPE type)
241241
m_managers.erase(type);
242242
}
243243

244-
bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/)
244+
bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
245245
{
246246
if (m_addons.empty())
247247
{
@@ -253,7 +253,7 @@ bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTE
253253
return (m_addons.find(type) != m_addons.end());
254254

255255
VECADDONS addons;
256-
return GetAddons(type, addons, content, true);
256+
return GetAddons(type, addons, content, enabledOnly);
257257
}
258258

259259
void CAddonMgr::UpdateRepos()
@@ -327,7 +327,7 @@ bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYP
327327
return !addons.empty();
328328
}
329329

330-
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/)
330+
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly/*= true*/)
331331
{
332332
CDateTimeSpan span;
333333
span.SetDateTimeSpan(0, 0, 0, ADDON_DIRSCAN_FREQ);
@@ -343,7 +343,10 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
343343
if (m_idMap[str])
344344
{
345345
addon = m_idMap[str];
346-
return true;
346+
if(enabledOnly)
347+
return !addon->Disabled();
348+
else
349+
return true;
347350
}
348351

349352
VECADDONS &addons = m_addons[type];
@@ -354,7 +357,10 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
354357
if ((*adnItr)->Name() == str || (type == ADDON_SCRAPER && (*adnItr)->LibName() == str))
355358
{
356359
addon = (*adnItr);
357-
return true;
360+
if(enabledOnly)
361+
return !addon->Disabled();
362+
else
363+
return true;
358364
}
359365
adnItr++;
360366
}

xbmc/utils/AddonManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ namespace ADDON
105105

106106
/* Addon access */
107107
bool GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content = CONTENT_NONE);
108-
bool GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN);
109-
bool HasAddons(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE);
108+
bool GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN, bool enabledOnly = true);
109+
bool HasAddons(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE, bool enabledOnly = true);
110110
bool GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content = CONTENT_NONE, bool enabled = true);
111111
bool GetAllAddons(VECADDONS &addons, bool enabledOnly = true);
112112
CStdString GetString(const CStdString &id, const int number);

0 commit comments

Comments
 (0)