mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Fixed cTimer::operator=() in case a cTimer variable is assigned to itself; implemented a copy constructor for cTimer
This commit is contained in:
48
timers.c
48
timers.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: timers.c 1.63 2006/09/02 10:20:36 kls Exp $
|
||||
* $Id: timers.c 1.64 2006/09/08 15:06:09 kls Exp $
|
||||
*/
|
||||
|
||||
#include "timers.h"
|
||||
@@ -83,6 +83,14 @@ cTimer::cTimer(const cEvent *Event)
|
||||
event = NULL; // let SetEvent() be called to get a log message
|
||||
}
|
||||
|
||||
cTimer::cTimer(const cTimer &Timer)
|
||||
{
|
||||
channel = NULL;
|
||||
aux = NULL;
|
||||
event = NULL;
|
||||
*this = Timer;
|
||||
}
|
||||
|
||||
cTimer::~cTimer()
|
||||
{
|
||||
free(aux);
|
||||
@@ -90,24 +98,26 @@ cTimer::~cTimer()
|
||||
|
||||
cTimer& cTimer::operator= (const cTimer &Timer)
|
||||
{
|
||||
startTime = Timer.startTime;
|
||||
stopTime = Timer.stopTime;
|
||||
lastSetEvent = 0;
|
||||
recording = Timer.recording;
|
||||
pending = Timer.pending;
|
||||
inVpsMargin = Timer.inVpsMargin;
|
||||
flags = Timer.flags;
|
||||
channel = Timer.channel;
|
||||
day = Timer.day;
|
||||
weekdays = Timer.weekdays;
|
||||
start = Timer.start;
|
||||
stop = Timer.stop;
|
||||
priority = Timer.priority;
|
||||
lifetime = Timer.lifetime;
|
||||
strncpy(file, Timer.file, sizeof(file));
|
||||
free(aux);
|
||||
aux = Timer.aux ? strdup(Timer.aux) : NULL;
|
||||
event = NULL;
|
||||
if (&Timer != this) {
|
||||
startTime = Timer.startTime;
|
||||
stopTime = Timer.stopTime;
|
||||
lastSetEvent = 0;
|
||||
recording = Timer.recording;
|
||||
pending = Timer.pending;
|
||||
inVpsMargin = Timer.inVpsMargin;
|
||||
flags = Timer.flags;
|
||||
channel = Timer.channel;
|
||||
day = Timer.day;
|
||||
weekdays = Timer.weekdays;
|
||||
start = Timer.start;
|
||||
stop = Timer.stop;
|
||||
priority = Timer.priority;
|
||||
lifetime = Timer.lifetime;
|
||||
strncpy(file, Timer.file, sizeof(file));
|
||||
free(aux);
|
||||
aux = Timer.aux ? strdup(Timer.aux) : NULL;
|
||||
event = NULL;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user