[epg] refactor CalcuateLayout() into UpdateLayout() and the free item
authorxhaggi <sascha.woo@gmail.com>
Wed, 26 Mar 2014 10:23:40 +0000 (11:23 +0100)
committerxhaggi <sascha.woo@gmail.com>
Mon, 28 Apr 2014 17:53:38 +0000 (19:53 +0200)
memory stuff in it's own method

xbmc/epg/GUIEPGGridContainer.cpp
xbmc/epg/GUIEPGGridContainer.h

index 62cf62a..0e2124b 100644 (file)
@@ -776,7 +776,8 @@ bool CGUIEPGGridContainer::OnMessage(CGUIMessage& message)
             m_gridIndex.push_back(blocks);
           }
 
-          UpdateLayout(true); // true to refresh all items
+          FreeItemsMemory();
+          UpdateLayout();
 
           /* Create Ruler items */
           CDateTime ruler; ruler.SetFromUTCDateTime(m_gridStart);
@@ -1569,24 +1570,6 @@ void CGUIEPGGridContainer::LoadLayout(TiXmlElement *layout)
   }
 }
 
-void CGUIEPGGridContainer::UpdateLayout(bool updateAllItems)
-{
-  // if container is invalid, either new data has arrived, or m_blockSize has changed
-  // need to run UpdateItems rather than CalculateLayout?
-  if (updateAllItems)
-  { // free memory of items
-    for (std::vector<CGUIListItemPtr>::iterator it = m_channelItems.begin(); it != m_channelItems.end(); it++)
-      (*it)->FreeMemory();
-    for (std::vector<CGUIListItemPtr>::iterator it = m_rulerItems.begin(); it != m_rulerItems.end(); it++)
-      (*it)->FreeMemory();
-    for (std::vector<CGUIListItemPtr>::iterator it = m_programmeItems.begin(); it != m_programmeItems.end(); it++)
-      (*it)->FreeMemory();
-  }
-
-  // and recalculate the layout
-  CalculateLayout();
-}
-
 CStdString CGUIEPGGridContainer::GetDescription() const
 {
   CStdString strLabel;
@@ -1671,7 +1654,7 @@ void CGUIEPGGridContainer::SetStartEnd(CDateTime start, CDateTime end)
       __FUNCTION__, m_gridStart.GetAsLocalizedDateTime(false, true).c_str(), m_gridEnd.GetAsLocalizedDateTime(false, true).c_str());
 }
 
-void CGUIEPGGridContainer::CalculateLayout()
+void CGUIEPGGridContainer::UpdateLayout()
 {
   CGUIListItemLayout *oldFocusedChannelLayout   = m_focusedChannelLayout;
   CGUIListItemLayout *oldChannelLayout          = m_channelLayout;
@@ -1800,6 +1783,17 @@ void CGUIEPGGridContainer::SetRenderOffset(const CPoint &offset)
   m_renderOffset = offset;
 }
 
+void CGUIEPGGridContainer::FreeItemsMemory()
+{
+  // free memory of items
+  for (std::vector<CGUIListItemPtr>::iterator it = m_channelItems.begin(); it != m_channelItems.end(); it++)
+    (*it)->FreeMemory();
+  for (std::vector<CGUIListItemPtr>::iterator it = m_rulerItems.begin(); it != m_rulerItems.end(); it++)
+    (*it)->FreeMemory();
+  for (std::vector<CGUIListItemPtr>::iterator it = m_programmeItems.begin(); it != m_programmeItems.end(); it++)
+    (*it)->FreeMemory();
+}
+
 void CGUIEPGGridContainer::FreeChannelMemory(int keepStart, int keepEnd)
 {
   if (keepStart < keepEnd)
index e9d4433..8ae80e3 100644 (file)
@@ -101,8 +101,7 @@ namespace EPG
     void ChannelScroll(int amount);
     void ProgrammesScroll(int amount);
     void ValidateOffset();
-    void UpdateLayout(bool refreshAllItems = false);
-    void CalculateLayout();
+    void UpdateLayout();
     void Reset();
     void ClearGridIndex(void);
 
@@ -162,6 +161,7 @@ namespace EPG
                       // the "movement" was simply due to the list being repopulated (thus cursor position
                       // changing around)
 
+    void FreeItemsMemory();
     void FreeChannelMemory(int keepStart, int keepEnd);
     void FreeProgrammeMemory(int channel, int keepStart, int keepEnd);
     void FreeRulerMemory(int keepStart, int keepEnd);