Skip to content

Commit

Permalink
don't allow LoadSkin() to run during an Unload/Reload cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Marshall committed Mar 3, 2011
1 parent 27bfc6a commit 72eb444
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ CApplication::CApplication(void) : m_itemCurrentFile(new CFileItem), m_progressT
m_strPlayListFile = "";
m_nextPlaylistItem = -1;
m_bPlaybackStarting = false;
m_skinReloading = false;

#ifdef HAS_GLX
XInitThreads();
Expand Down Expand Up @@ -1471,6 +1472,7 @@ void CApplication::StopServices()

void CApplication::ReloadSkin()
{
m_skinReloading = false;
CGUIMessage msg(GUI_MSG_LOAD_SKIN, -1, g_windowManager.GetActiveWindow());
g_windowManager.SendMessage(msg);
// Reload the skin, restoring the previously focused control. We need this as
Expand All @@ -1488,6 +1490,9 @@ void CApplication::ReloadSkin()

bool CApplication::LoadSkin(const CStdString& skinID)
{
if (m_skinReloading)
return false;

AddonPtr addon;
if (CAddonMgr::Get().GetAddon(skinID, addon, ADDON_SKIN))
{
Expand Down Expand Up @@ -1533,7 +1538,6 @@ void CApplication::LoadSkin(const SkinPtr& skin)
vector<int> currentModelessWindows;
g_windowManager.GetActiveModelessWindows(currentModelessWindows);

CLog::Log(LOGINFO, " delete old skin...");
UnloadSkin();

CLog::Log(LOGINFO, " load skin from:%s", skin->Path().c_str());
Expand Down Expand Up @@ -1642,8 +1646,12 @@ void CApplication::LoadSkin(const SkinPtr& skin)
}
}

void CApplication::UnloadSkin()
void CApplication::UnloadSkin(bool forReload /* = false */)
{
m_skinReloading = forReload;

CLog::Log(LOGINFO, "Unloading old skin %s...", forReload ? "for reload " : "");

g_audioManager.Enable(false);

g_windowManager.DeInitialize();
Expand Down
4 changes: 3 additions & 1 deletion xbmc/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool IsCurrentThread() const;
void Stop();
void RestartApp();
void UnloadSkin();
void UnloadSkin(bool forReload = false);
bool LoadUserWindows();
void ReloadSkin();
const CStdString& CurrentFile();
Expand Down Expand Up @@ -298,6 +298,8 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool LoadSkin(const CStdString& skinID);
void LoadSkin(const boost::shared_ptr<ADDON::CSkinInfo>& skin);

bool m_skinReloading; // if true we disallow LoadSkin until ReloadSkin is called

friend class CApplicationMessenger;
// screensaver
bool m_bScreenSave;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ int CBuiltins::Execute(const CStdString& execString)
}
else if (execute.Equals("unloadskin"))
{
g_application.UnloadSkin();
g_application.UnloadSkin(true); // we're reloading the skin after this
}
else if (execute.Equals("refreshrss"))
{
Expand Down

0 comments on commit 72eb444

Please sign in to comment.