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 7, 2016
1 parent 9311fff commit d26c5ee
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
9 changes: 8 additions & 1 deletion xbmc/guilib/TextureBundle.cpp
Expand Up @@ -21,7 +21,14 @@
#include "TextureBundle.h"

CTextureBundle::CTextureBundle()
: m_useXBT{false}
: m_tbXBT{false}
, m_useXBT{false}
{
}

CTextureBundle::CTextureBundle(bool useXBT)
: m_tbXBT{useXBT}
, m_useXBT{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
21 changes: 18 additions & 3 deletions xbmc/guilib/TextureBundleXBT.cpp
Expand Up @@ -41,12 +41,18 @@
#endif
#endif

CTextureBundleXBT::CTextureBundleXBT(void)
CTextureBundleXBT::CTextureBundleXBT()
: m_TimeStamp{0}
, m_themeBundle{false}
{
}

CTextureBundleXBT::CTextureBundleXBT(bool themeBundle)
: m_TimeStamp{0}
, m_themeBundle{themeBundle}
{
}

CTextureBundleXBT::~CTextureBundleXBT(void)
{
if (m_XBTFReader != nullptr && m_XBTFReader->IsOpen())
Expand All @@ -59,6 +65,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 +82,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 +92,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
1 change: 1 addition & 0 deletions xbmc/guilib/TextureBundleXBT.h
Expand Up @@ -33,6 +33,7 @@ class CTextureBundleXBT
{
public:
CTextureBundleXBT();
explicit CTextureBundleXBT(bool themeBundle);
~CTextureBundleXBT();

void SetThemeBundle(bool themeBundle);
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 d26c5ee

Please sign in to comment.