diff options
author | Martijn Kaijser <martijn@xbmc.org> | 2015-12-30 07:10:57 +0100 |
---|---|---|
committer | Martijn Kaijser <martijn@xbmc.org> | 2015-12-30 07:10:57 +0100 |
commit | 49b369c8bde86a5989a7d6aad8b8bedefadc0ea4 (patch) | |
tree | 43e10f8eea9660fe5deeb176d9e6b82c02cd8c69 | |
parent | f0ceefa237b1301104e18f6efbd2e71a0748b440 (diff) | |
parent | 326dc0d164332bda7c2dd5da99f4be87c90de43b (diff) |
Merge pull request #8708 from xhaggi/jarvis/fix-pvr-epg-grid-array-index-out-of-bound
[backport][fix][pvr] m_gridIndex array index out of bound
-rw-r--r-- | xbmc/epg/GUIEPGGridContainer.cpp | 37 | ||||
-rw-r--r-- | xbmc/epg/GUIEPGGridContainer.h | 1 | ||||
-rw-r--r-- | xbmc/pvr/windows/GUIWindowPVRGuide.cpp | 4 |
3 files changed, 42 insertions, 0 deletions
diff --git a/xbmc/epg/GUIEPGGridContainer.cpp b/xbmc/epg/GUIEPGGridContainer.cpp index 51a3ea4e67..8868d2bcda 100644 --- a/xbmc/epg/GUIEPGGridContainer.cpp +++ b/xbmc/epg/GUIEPGGridContainer.cpp @@ -683,6 +683,14 @@ void CGUIEPGGridContainer::RenderItem(float posX, float posY, CGUIListItem *item g_graphicsContext.RestoreOrigin(); } +void CGUIEPGGridContainer::ResetCoordinates() +{ + m_channelCursor = 0; + m_channelOffset = 0; + m_blockCursor = 0; + m_blockOffset = 0; +} + bool CGUIEPGGridContainer::OnAction(const CAction &action) { switch (action.GetID()) @@ -1896,6 +1904,8 @@ void CGUIEPGGridContainer::Reset() m_lastItem = NULL; m_lastChannel = NULL; + + m_channels = 0; } void CGUIEPGGridContainer::GoToBegin() @@ -1928,9 +1938,36 @@ void CGUIEPGGridContainer::GoToEnd() void CGUIEPGGridContainer::GoToNow() { + if (!m_gridStart.IsValid()) + return; + CDateTime currentDate = CDateTime::GetCurrentDateTime().GetAsUTCDateTime(); int offset = ((currentDate - m_gridStart).GetSecondsTotal() / 60 - 30) / MINSPERBLOCK; ScrollToBlockOffset(offset); + + if (m_channelCursor + m_channelOffset >= 0 && + m_channelCursor + m_channelOffset < m_channels) + { + // make sure offset is in valid range + offset = std::max(0, std::min(offset, m_blocks - m_blocksPerPage)); + + for (int blockIndex = 0; blockIndex < m_blocksPerPage; blockIndex++) + { + if (offset + blockIndex >= m_blocks) + break; + + const CFileItemPtr item = m_gridIndex[m_channelCursor + m_channelOffset][offset + blockIndex].item; + if (item) + { + const CEpgInfoTagPtr tag = item->GetEPGInfoTag(); + if (tag && tag->StartAsUTC() <= currentDate && tag->EndAsUTC() > currentDate) + { + SetBlock(blockIndex); // Select currently active epg element + break; + } + } + } + } } void CGUIEPGGridContainer::SetStartEnd(CDateTime start, CDateTime end) diff --git a/xbmc/epg/GUIEPGGridContainer.h b/xbmc/epg/GUIEPGGridContainer.h index f83084ca47..962dbfff3b 100644 --- a/xbmc/epg/GUIEPGGridContainer.h +++ b/xbmc/epg/GUIEPGGridContainer.h @@ -94,6 +94,7 @@ namespace EPG void SetStartEnd(CDateTime start, CDateTime end); void SetChannel(const PVR::CPVRChannelPtr &channel); void SetChannel(const std::string &channel); + void ResetCoordinates(); protected: bool OnClick(int actionID); diff --git a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp index 088890a298..ad6e04b31d 100644 --- a/xbmc/pvr/windows/GUIWindowPVRGuide.cpp +++ b/xbmc/pvr/windows/GUIWindowPVRGuide.cpp @@ -451,6 +451,10 @@ void CGUIWindowPVRGuide::GetViewTimelineItems(CFileItemList &items) CPVRChannelGroupPtr group = GetGroup(); + // group change detected reset grid coordinate + if (*m_cachedChannelGroup != *group) + epgGridContainer->ResetCoordinates(); + if (m_bUpdateRequired || m_cachedTimeline->IsEmpty() || *m_cachedChannelGroup != *group) { m_bUpdateRequired = false; |