diff options
author | louis <louis.braun@gmx.de> | 2015-03-15 14:49:39 +0100 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2015-03-15 14:49:39 +0100 |
commit | 108d8e57849f43f7728fd748a3162abba7b95c9a (patch) | |
tree | a893a7b9589decb9a72f9b807b3d347713844173 | |
parent | 439d3e36cc65bd074bd0e1a1c2b6b6cc4aa392b2 (diff) | |
download | vdr-plugin-tvguideng-108d8e57849f43f7728fd748a3162abba7b95c9a.tar.gz vdr-plugin-tvguideng-108d8e57849f43f7728fd748a3162abba7b95c9a.tar.bz2 |
fixed crash if a channel group is empty
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | channelgroups.c | 17 | ||||
-rw-r--r-- | epggrid.c | 5 |
3 files changed, 21 insertions, 3 deletions
@@ -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<cChannelGroup>::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) { @@ -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); } |