Skip to content

Commit

Permalink
Merge pull request #1608 from pieh/xp_context_menu
Browse files Browse the repository at this point in the history
CGUIWindow::Initialize fixes/changes
  • Loading branch information
pieh committed Oct 29, 2012
2 parents c8aba05 + 2c316ee commit d9d0126
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 12 additions & 12 deletions xbmc/guilib/GUIWindow.cpp
Expand Up @@ -701,6 +701,11 @@ bool CGUIWindow::OnMessage(CGUIMessage& message)
return SendControlMessage(message);
}

bool CGUIWindow::NeedXMLReload()
{
return !m_windowLoaded || g_infoManager.ConditionsChangedValues(m_xmlIncludeConditions);
}

void CGUIWindow::AllocResources(bool forceLoad /*= FALSE */)
{
CSingleLock lock(g_graphicsContext);
Expand All @@ -710,19 +715,12 @@ void CGUIWindow::AllocResources(bool forceLoad /*= FALSE */)
start = CurrentHostCounter();
#endif
// use forceLoad to determine if xml file needs loading
forceLoad |= (m_loadType == LOAD_EVERY_TIME);

// if window is loaded (not cleared before) and we aren't forced to load
// we will have to load it only if include conditions values were changed
if (m_windowLoaded && !forceLoad)
forceLoad = g_infoManager.ConditionsChangedValues(m_xmlIncludeConditions);
forceLoad |= NeedXMLReload() || (m_loadType == LOAD_EVERY_TIME);

// if window is loaded and load is forced we have to free window resources first
if (m_windowLoaded && forceLoad)
FreeResources(true);

// load skin xml file only if we are forced to load or window isn't loaded yet
forceLoad |= !m_windowLoaded;
if (forceLoad)
{
CStdString xmlFile = GetProperty("xmlfile").asString();
Expand Down Expand Up @@ -786,16 +784,18 @@ bool CGUIWindow::Initialize()
{
if (!g_windowManager.Initialized())
return false; // can't load if we have no skin yet
if(m_windowLoaded)
if(!NeedXMLReload())
return true;
if(g_application.IsCurrentThread())
return Load(GetProperty("xmlfile").asString());
AllocResources();
else
{
// if not app thread, send gui msg via app messenger
// and wait for results, so windowLoaded flag would be updated
CGUIMessage msg(GUI_MSG_WINDOW_LOAD, 0, 0);
g_windowManager.SendThreadMessage(msg, GetID());
CApplicationMessenger::Get().SendGUIMessage(msg, GetID(), true);
}
return true;
return m_windowLoaded;
}

void CGUIWindow::SetInitialVisibility()
Expand Down
4 changes: 4 additions & 0 deletions xbmc/guilib/GUIWindow.h
Expand Up @@ -194,6 +194,10 @@ class CGUIWindow : public CGUIControlGroup, protected CCriticalSection
virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
virtual bool LoadXML(const CStdString& strPath, const CStdString &strLowerPath); ///< Loads from the given file
bool Load(TiXmlElement *pRootElement); ///< Loads from the given XML root element
/*! \brief Check if XML file needs (re)loading
XML file has to be (re)loaded when window is not loaded or include conditions values were changed
*/
bool NeedXMLReload();
virtual void LoadAdditionalTags(TiXmlElement *root) {}; ///< Load additional information from the XML document

virtual void SetDefaults();
Expand Down

0 comments on commit d9d0126

Please sign in to comment.