From 628ec5ff2e79ad1f83219733de0280239eae348d Mon Sep 17 00:00:00 2001 From: elupus Date: Sun, 20 Jun 2010 01:38:55 +0000 Subject: changed: delete python windows from app thread, and only when we are not nested changed: when a window is removed, it should not be part of the open dialogs list either git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31222 568bbfeb-2a22-0410-94d2-cc84cf5bfa90 --- guilib/GUIWindowManager.cpp | 26 +++++++++++++++++++++++++- guilib/GUIWindowManager.h | 2 ++ xbmc/lib/libPython/xbmcmodule/window.cpp | 10 ++-------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/guilib/GUIWindowManager.cpp b/guilib/GUIWindowManager.cpp index ffc7a00786..1ee6ab7a71 100644 --- a/guilib/GUIWindowManager.cpp +++ b/guilib/GUIWindowManager.cpp @@ -39,6 +39,7 @@ CGUIWindowManager::CGUIWindowManager(void) { m_pCallback = NULL; m_bShowOverlay = true; + m_iNested = 0; } CGUIWindowManager::~CGUIWindowManager(void) @@ -212,6 +213,14 @@ void CGUIWindowManager::Remove(int id) WindowMap::iterator it = m_mapWindows.find(id); if (it != m_mapWindows.end()) { + for(vector::iterator it2 = m_activeDialogs.begin(); it2 != m_activeDialogs.end();) + { + if(*it2 == it->second) + it2 = m_activeDialogs.erase(it2); + else + it2++; + } + m_mapWindows.erase(it); } else @@ -231,7 +240,7 @@ void CGUIWindowManager::Delete(int id) if (pWindow) { Remove(id); - delete pWindow; + m_deleteWindows.push_back(pWindow); } } @@ -509,6 +518,19 @@ void CGUIWindowManager::FrameMove() { assert(g_application.IsCurrentThread()); CSingleLock lock(g_graphicsContext); + + if(m_iNested == 0) + { + // delete any windows queued for deletion + for(iDialog it = m_deleteWindows.begin(); it != m_deleteWindows.end(); it++) + { + // Free any window resources + (*it)->FreeResources(true); + delete *it; + } + m_deleteWindows.clear(); + } + CGUIWindow* pWindow = GetWindow(GetActiveWindow()); if (pWindow) pWindow->FrameMove(); @@ -554,12 +576,14 @@ void CGUIWindowManager::Process(bool renderOnly /*= false*/) { if (g_application.IsCurrentThread() && m_pCallback) { + m_iNested++; if (!renderOnly) { m_pCallback->Process(); m_pCallback->FrameMove(); } m_pCallback->Render(); + m_iNested--; } } diff --git a/guilib/GUIWindowManager.h b/guilib/GUIWindowManager.h index 2beb098846..e68af05170 100644 --- a/guilib/GUIWindowManager.h +++ b/guilib/GUIWindowManager.h @@ -125,6 +125,7 @@ private: WindowMap m_mapWindows; std::vector m_vecCustomWindows; std::vector m_activeDialogs; + std::vector m_deleteWindows; typedef std::vector::iterator iDialog; typedef std::vector::const_iterator ciDialog; typedef std::vector::reverse_iterator rDialog; @@ -138,6 +139,7 @@ private: std::vector m_vecMsgTargets; bool m_bShowOverlay; + int m_iNested; }; /*! diff --git a/xbmc/lib/libPython/xbmcmodule/window.cpp b/xbmc/lib/libPython/xbmcmodule/window.cpp index 247e813d84..6f0ea8a44d 100644 --- a/xbmc/lib/libPython/xbmcmodule/window.cpp +++ b/xbmc/lib/libPython/xbmcmodule/window.cpp @@ -350,10 +350,6 @@ namespace PYXBMC // old window does not exist anymore, switch to home else g_windowManager.ActivateWindow(WINDOW_HOME); } - // Free any window properties - self->pWindow->ClearProperties(); - // free the window's resources and unload it (free all guicontrols) - self->pWindow->FreeResources(true); } else { @@ -380,10 +376,8 @@ namespace PYXBMC } if (self->bIsPythonWindow) - { - g_windowManager.Remove(self->pWindow->GetID()); - delete self->pWindow; - } + g_windowManager.Delete(self->pWindow->GetID()); + PyXBMCGUIUnlock(); self->vecControls.clear(); self->vecControls.~vector(); -- cgit v1.2.3