From ff5df8f29852a1c968a2797e13e494ae882bed26 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 6 Aug 2005 12:13:55 +0200 Subject: [PATCH] Fixed the cChannel copy constructor --- CONTRIBUTORS | 1 + HISTORY | 2 ++ channels.c | 47 ++++++++++++++++++++++++++--------------------- channels.h | 3 ++- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7f222839..349d70de 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -731,6 +731,7 @@ Marcel Wiesweg for adding a few missing initializations for adding play mode pmVideoOnly for fixing a possible crash with inconsistent SI data + for pointing out a problem with the cChannel copy constructor Torsten Herz for fixing a possible deadlock when using the "Blue" button in the "Schedules" menu diff --git a/HISTORY b/HISTORY index 600b83c4..6a3b25fd 100644 --- a/HISTORY +++ b/HISTORY @@ -3655,3 +3655,5 @@ Video Disk Recorder Revision History problem with this). - Files and directories are now created with rights according to the shell's umask settings (thanks to Andreas Brachold). +- Fixed the cChannel copy constructor (thanks to Marcel Wiesweg for pointing out + a problem with it). diff --git a/channels.c b/channels.c index b2d741e6..04f6dc98 100644 --- a/channels.c +++ b/channels.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.c 1.42 2005/05/29 10:32:38 kls Exp $ + * $Id: channels.c 1.43 2005/08/06 12:06:37 kls Exp $ */ #include "channels.h" @@ -179,27 +179,13 @@ cChannel::cChannel(void) cChannel::cChannel(const cChannel &Channel) { - name = strdup(""); - shortName = strdup(""); - provider = strdup(""); - portalName = strdup(""); - *this = Channel; - vpid = 0; - ppid = 0; - apids[0] = 0; - dpids[0] = 0; - spids[0] = 0; - tpid = 0; - caids[0] = 0; - nid = 0; - tid = 0; - sid = 0; - rid = 0; - number = 0; - groupSep = false; - modification = CHANNELMOD_NONE; + name = NULL; + shortName = NULL; + provider = NULL; + portalName = NULL; linkChannels = NULL; refChannel = NULL; + *this = Channel; } cChannel::~cChannel() @@ -265,6 +251,24 @@ int cChannel::Modification(int Mask) return Result; } +void cChannel::CopyTransponderData(const cChannel *Channel) +{ + if (Channel) { + frequency = Channel->frequency; + source = Channel->source; + srate = Channel->srate; + polarization = Channel->polarization; + inversion = Channel->inversion; + bandwidth = Channel->bandwidth; + coderateH = Channel->coderateH; + coderateL = Channel->coderateL; + modulation = Channel->modulation; + transmission = Channel->transmission; + guard = Channel->guard; + hierarchy = Channel->hierarchy; + } +} + bool cChannel::SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH) { // Workarounds for broadcaster stupidity: @@ -977,7 +981,8 @@ cChannel *cChannels::NewChannel(const cChannel *Transponder, const char *Name, c { if (Transponder) { dsyslog("creating new channel '%s,%s;%s' on %s transponder %d with id %d-%d-%d-%d", Name, ShortName, Provider, *cSource::ToString(Transponder->Source()), Transponder->Transponder(), Nid, Tid, Sid, Rid); - cChannel *NewChannel = new cChannel(*Transponder); + cChannel *NewChannel = new cChannel; + NewChannel->CopyTransponderData(Transponder); NewChannel->SetId(Nid, Tid, Sid, Rid); NewChannel->SetName(Name, ShortName, Provider); Add(NewChannel); diff --git a/channels.h b/channels.h index 3cb7e8f8..53720424 100644 --- a/channels.h +++ b/channels.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: channels.h 1.32 2005/05/28 13:57:08 kls Exp $ + * $Id: channels.h 1.33 2005/08/06 11:23:32 kls Exp $ */ #ifndef __CHANNELS_H @@ -181,6 +181,7 @@ public: bool IsTerr(void) const { return cSource::IsTerr(source); } tChannelID GetChannelID(void) const { return tChannelID(source, nid, (nid || tid) ? tid : Transponder(), sid, rid); } int Modification(int Mask = CHANNELMOD_ALL); + void CopyTransponderData(const cChannel *Channel); bool SetSatTransponderData(int Source, int Frequency, char Polarization, int Srate, int CoderateH); bool SetCableTransponderData(int Source, int Frequency, int Modulation, int Srate, int CoderateH); bool SetTerrTransponderData(int Source, int Frequency, int Bandwidth, int Modulation, int Hierarchy, int CodeRateH, int CodeRateL, int Guard, int Transmission);