Skip to content

Commit

Permalink
Fix theme xbt loading that broke during cleanup.
Browse files Browse the repository at this point in the history
Found a race condition that seems to have been hidden and a screwup during cleanup clobbering state.
  • Loading branch information
Pär Björklund committed Jul 6, 2016
1 parent 9311fff commit d05627a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions xbmc/guilib/TextureBundle.cpp
Expand Up @@ -25,6 +25,11 @@ CTextureBundle::CTextureBundle()
{
}

CTextureBundle::CTextureBundle(bool useXBT)
: m_useXBT{useXBT}
{
}

bool CTextureBundle::HasFile(const std::string& Filename)
{
if (m_useXBT)
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/TextureBundle.h
Expand Up @@ -28,6 +28,7 @@ class CTextureBundle
{
public:
CTextureBundle();
explicit CTextureBundle(bool useXBT);
~CTextureBundle() = default;

void SetThemeBundle(bool themeBundle);
Expand Down
13 changes: 11 additions & 2 deletions xbmc/guilib/TextureBundleXBT.cpp
Expand Up @@ -59,6 +59,15 @@ CTextureBundleXBT::~CTextureBundleXBT(void)
bool CTextureBundleXBT::OpenBundle()
{
// Find the correct texture file (skin or theme)

auto mediaDir = g_graphicsContext.GetMediaDir();
if (mediaDir.empty())
{
mediaDir = CSpecialProtocol::TranslatePath(
URIUtils::AddFileToFolder("special://home/addons",
CSettings::GetInstance().GetString(CSettings::SETTING_LOOKANDFEEL_SKIN)));
}

if (m_themeBundle)
{
// if we are the theme bundle, we only load if the user has chosen
Expand All @@ -67,7 +76,7 @@ bool CTextureBundleXBT::OpenBundle()
if (!theme.empty() && !StringUtils::EqualsNoCase(theme, "SKINDEFAULT"))
{
std::string themeXBT(URIUtils::ReplaceExtension(theme, ".xbt"));
m_path = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media");
m_path = URIUtils::AddFileToFolder(mediaDir, "media");
m_path = URIUtils::AddFileToFolder(m_path, themeXBT);
}
else
Expand All @@ -77,7 +86,7 @@ bool CTextureBundleXBT::OpenBundle()
}
else
{
m_path = URIUtils::AddFileToFolder(g_graphicsContext.GetMediaDir(), "media/Textures.xbt");
m_path = URIUtils::AddFileToFolder(mediaDir, "media/Textures.xbt");
}

m_path = CSpecialProtocol::TranslatePathConvertCase(m_path);
Expand Down
5 changes: 3 additions & 2 deletions xbmc/guilib/TextureManager.cpp
Expand Up @@ -539,8 +539,9 @@ void CGUITextureManager::Cleanup()
delete pMap;
i = m_vecTextures.erase(i);
}
for (int i = 0; i < 2; i++)
m_TexBundle[i] = CTextureBundle();

m_TexBundle[0] = CTextureBundle(true);
m_TexBundle[1] = CTextureBundle();
FreeUnusedTextures();
}

Expand Down

0 comments on commit d05627a

Please sign in to comment.