Skip to content

Commit

Permalink
FIX: trap g_SkinInfo being null
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Jan 26, 2018
1 parent 6700d59 commit d0067a9
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 16 deletions.
1 change: 1 addition & 0 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,7 @@ void CApplication::UnloadSkin(bool forReload /* = false */)
// The g_SkinInfo shared_ptr ought to be reset here
// but there are too many places it's used without checking for NULL
// and as a result a race condition on exit can cause a crash.
g_SkinInfo.reset();
}

bool CApplication::LoadUserWindows()
Expand Down
25 changes: 16 additions & 9 deletions xbmc/guilib/GUIColorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,29 @@ void CGUIColorManager::Load(const std::string &colorFile)
LoadXML(xmlDoc);

// first load the default color map if it exists
std::string path = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors", "defaults.xml");
std::string path;
if (g_SkinInfo)
{
path = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors", "defaults.xml");

if (xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(path)))
LoadXML(xmlDoc);
if (xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(path)))
LoadXML(xmlDoc);
}

// now the color map requested
if (StringUtils::EqualsNoCase(colorFile, "SKINDEFAULT"))
return; // nothing to do

path = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors", colorFile);
if (!URIUtils::HasExtension(path))
path += ".xml";
CLog::Log(LOGINFO, "Loading colors from %s", path.c_str());
if (g_SkinInfo)
{
path = URIUtils::AddFileToFolder(g_SkinInfo->Path(), "colors", colorFile);
if (!URIUtils::HasExtension(path))
path += ".xml";
CLog::Log(LOGINFO, "Loading colors from %s", path.c_str());

if (xmlDoc.LoadFile(path))
LoadXML(xmlDoc);
if (xmlDoc.LoadFile(path))
LoadXML(xmlDoc);
}
}

bool CGUIColorManager::LoadXML(CXBMCTinyXML &xmlDoc)
Expand Down
6 changes: 5 additions & 1 deletion xbmc/interfaces/legacy/WindowXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ namespace XBMCAddon
{
XBMC_TRACE;
RESOLUTION_INFO res;
std::string strSkinPath = g_SkinInfo->GetSkinPath(xmlFilename, &res);
std::string strSkinPath;
if (g_SkinInfo)
strSkinPath = g_SkinInfo->GetSkinPath(xmlFilename, &res);
else
throw WindowException("No skin loaded");

if (!XFILE::CFile::Exists(strSkinPath))
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void CGUIDialogPeripheralSettings::InitializeSettings()
}

m_initialising = true;
bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml");
bool usePopup = g_SkinInfo && g_SkinInfo->HasSkinFile("DialogSlider.xml");

PeripheralPtr peripheral = g_peripherals.GetByPath(m_item->GetPath());
if (!peripheral)
Expand Down
24 changes: 24 additions & 0 deletions xbmc/settings/SkinSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,44 +48,68 @@ CSkinSettings& CSkinSettings::GetInstance()

int CSkinSettings::TranslateString(const std::string &setting)
{
if (!g_SkinInfo)
return -1;

return g_SkinInfo->TranslateString(setting);
}

const std::string& CSkinSettings::GetString(int setting) const
{
if (!g_SkinInfo)
return "";

return g_SkinInfo->GetString(setting);
}

void CSkinSettings::SetString(int setting, const std::string &label)
{
if (!g_SkinInfo)
return;

g_SkinInfo->SetString(setting, label);
g_SkinInfo->SaveSettings();
}

int CSkinSettings::TranslateBool(const std::string &setting)
{
if (!g_SkinInfo)
return -1;

return g_SkinInfo->TranslateBool(setting);
}

bool CSkinSettings::GetBool(int setting) const
{
if (!g_SkinInfo)
return false;

return g_SkinInfo->GetBool(setting);
}

void CSkinSettings::SetBool(int setting, bool set)
{
if (!g_SkinInfo)
return;

g_SkinInfo->SetBool(setting, set);
g_SkinInfo->SaveSettings();
}

void CSkinSettings::Reset(const std::string &setting)
{
if (!g_SkinInfo)
return;

g_SkinInfo->Reset(setting);
g_SkinInfo->SaveSettings();
}

void CSkinSettings::Reset()
{
if (!g_SkinInfo)
return;

g_SkinInfo->Reset();
g_SkinInfo->SaveSettings();

Expand Down
2 changes: 1 addition & 1 deletion xbmc/settings/dialogs/GUIDialogAudioDSPSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void CGUIDialogAudioDSPSettings::InitializeSettings()
return;
}

bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml");
bool usePopup = g_SkinInfo && g_SkinInfo->HasSkinFile("DialogSlider.xml");

CVideoSettings &videoSettings = CMediaSettings::GetInstance().GetCurrentVideoSettings();

Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void CGUIDialogAudioSubtitleSettings::InitializeSettings()
return;
}

bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml");
bool usePopup = g_SkinInfo && g_SkinInfo->HasSkinFile("DialogSlider.xml");

CVideoSettings &videoSettings = CMediaSettings::GetInstance().GetCurrentVideoSettings();

Expand Down
2 changes: 1 addition & 1 deletion xbmc/video/dialogs/GUIDialogVideoSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ void CGUIDialogVideoSettings::InitializeSettings()
return;
}

bool usePopup = g_SkinInfo->HasSkinFile("DialogSlider.xml");
bool usePopup = g_SkinInfo && g_SkinInfo->HasSkinFile("DialogSlider.xml");

CVideoSettings &videoSettings = CMediaSettings::GetInstance().GetCurrentVideoSettings();

Expand Down
4 changes: 2 additions & 2 deletions xbmc/windows/GUIWindowDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CGUIWindowDebugInfo::~CGUIWindowDebugInfo(void)

void CGUIWindowDebugInfo::UpdateVisibility()
{
if (LOG_LEVEL_DEBUG_FREEMEM <= g_advancedSettings.m_logLevel || g_SkinInfo->IsDebugging())
if (LOG_LEVEL_DEBUG_FREEMEM <= g_advancedSettings.m_logLevel || (g_SkinInfo && g_SkinInfo->IsDebugging()))
Open();
else
Close();
Expand Down Expand Up @@ -125,7 +125,7 @@ void CGUIWindowDebugInfo::Process(unsigned int currentTime, CDirtyRegionList &di
}

// render the skin debug info
if (g_SkinInfo->IsDebugging())
if (g_SkinInfo && g_SkinInfo->IsDebugging())
{
if (!info.empty())
info += "\n";
Expand Down

0 comments on commit d0067a9

Please sign in to comment.