summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2015-03-15 14:49:39 +0100
committerlouis <louis.braun@gmx.de>2015-03-15 14:49:39 +0100
commit108d8e57849f43f7728fd748a3162abba7b95c9a (patch)
treea893a7b9589decb9a72f9b807b3d347713844173
parent439d3e36cc65bd074bd0e1a1c2b6b6cc4aa392b2 (diff)
downloadvdr-plugin-tvguideng-108d8e57849f43f7728fd748a3162abba7b95c9a.tar.gz
vdr-plugin-tvguideng-108d8e57849f43f7728fd748a3162abba7b95c9a.tar.bz2
fixed crash if a channel group is empty
-rw-r--r--HISTORY2
-rw-r--r--channelgroups.c17
-rw-r--r--epggrid.c5
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<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) {
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);
}