Skip to content

Commit

Permalink
[PVR] Guide window: EPG grid: now even works if none of the available…
Browse files Browse the repository at this point in the history
… channels has EPG data (fixes trac#16548).
  • Loading branch information
ksooo committed Jan 29, 2016
1 parent 46175d6 commit 8350eb8
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions xbmc/epg/GUIEPGGridContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,14 @@ void CGUIEPGGridContainer::UpdateItems(CFileItemList *items)
FreeItemsMemory();
UpdateLayout();

/* check for invalid start and end time */
if (m_gridStart >= m_gridEnd)
{
// default to start "now minus 30 minutes" and end "start plus one page".
m_gridStart = CDateTime::GetCurrentDateTime().GetAsUTCDateTime() - CDateTimeSpan(0, 0, 30, 0);
m_gridEnd = m_gridStart + CDateTimeSpan(0, 0, m_blocksPerPage * MINSPERBLOCK, 0);
}

/* Create Ruler items */
CDateTime ruler; ruler.SetFromUTCDateTime(m_gridStart);
CDateTime rulerEnd; rulerEnd.SetFromUTCDateTime(m_gridEnd);
Expand All @@ -913,29 +921,11 @@ void CGUIEPGGridContainer::UpdateItems(CFileItemList *items)
m_rulerItems.push_back(rulerItem);
}

/* check for invalid start and end time */
if (m_gridStart >= m_gridEnd)
{
CLog::Log(LOGERROR, "CGUIEPGGridContainer - %s - invalid start and end time set", __FUNCTION__);
CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), GetParentID()); // message the window
SendWindowMessage(msg);
return;
}

CDateTimeSpan gridDuration = m_gridEnd - m_gridStart;
m_blocks = (gridDuration.GetDays()*24*60 + gridDuration.GetHours()*60 + gridDuration.GetMinutes()) / MINSPERBLOCK;
if (m_blocks >= MAXBLOCKS)
m_blocks = MAXBLOCKS;

/* if less than one page, can't display grid */
if (m_blocks < m_blocksPerPage)
{
CLog::Log(LOGERROR, "CGUIEPGGridContainer - %s - Less than one page of data available.", __FUNCTION__);
CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), GetParentID()); // message the window
SendWindowMessage(msg);
return;
}

CDateTimeSpan blockDuration;
blockDuration.SetDateTimeSpan(0, 0, MINSPERBLOCK, 0);

Expand Down

0 comments on commit 8350eb8

Please sign in to comment.