From 108d8e57849f43f7728fd748a3162abba7b95c9a Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 15 Mar 2015 14:49:39 +0100 Subject: fixed crash if a channel group is empty --- HISTORY | 2 ++ channelgroups.c | 17 +++++++++++++++-- epggrid.c | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/HISTORY b/HISTORY index 24d3acc..2dc135c 100644 --- a/HISTORY +++ b/HISTORY @@ -8,3 +8,5 @@ VDR Plugin 'tvguideng' Revision History Version 0.0.2 - fixed bug that timemanager does not use configured display time +- fixed crash if a channel group is empty + diff --git a/channelgroups.c b/channelgroups.c index 42a36b1..70cecf1 100644 --- a/channelgroups.c +++ b/channelgroups.c @@ -5,8 +5,8 @@ cChannelGroup::cChannelGroup(string name, int id) { this->id = id; - channelStart = 0; - channelStop = 0; + channelStart = -1; + channelStop = -1; this->name = name; } @@ -54,6 +54,19 @@ void cChannelgroups::Init(void) { if (channelGroups.size() > 0) { channelGroups[channelGroups.size()-1].SetChannelStop(lastChannelNumber); } + //cleanup empty groups + bool foundDelete = false; + do { + for (vector::iterator it = channelGroups.begin(); it != channelGroups.end(); it++) { + cChannelGroup group = *it; + if (group.StartChannel() == 0 || group.StartChannel() == -1) { + channelGroups.erase(it); + foundDelete = true; + break; + } + foundDelete = false; + } + } while (foundDelete); } void cChannelgroups::Clear(void) { diff --git a/epggrid.c b/epggrid.c index 79cdae7..f4dbcd7 100644 --- a/epggrid.c +++ b/epggrid.c @@ -102,7 +102,10 @@ void cEpgGrid::CreateChannels(const cChannel *startChannel, int activeChannel) { if (!foundEnough) { int numCurrent = channels.Count(); int numBack = channelsPerPage - numCurrent; - int newChannelNumber = channels.First()->GetChannelNumber() - numBack; + cChannelEpg *first = channels.First(); + int newChannelNumber = 1; + if (first) + newChannelNumber = first->GetChannelNumber() - numBack; const cChannel *newStart = Channels.GetByNumber(newChannelNumber); CreateChannels(newStart, pos+1); } -- cgit v1.2.3