From 0003d6391cbf3c16daca4cd6a45632bb619342d6 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 10 Apr 2021 10:09:50 +0200 Subject: [PATCH] When spawning pattern timers, the new function cTimers::GetTimerForEvent() is now used to check whether a matching event already has a local timer --- HISTORY | 10 ++++++++++ timers.c | 17 ++++++++++++++--- timers.h | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index b20a80ef..3cda625c 100644 --- a/HISTORY +++ b/HISTORY @@ -9640,3 +9640,13 @@ Video Disk Recorder Revision History by Jürgen Schneider). - No longer switching devices for pattern timers (thanks to Helmut Binder). - cTimer::TriggerRespawn() now only acts on local timers. + +2021-04-10: + +- When spawning pattern timers, the new function cTimers::GetTimerForEvent() is now used + to check whether a matching event already has a local spawned timer. Reason: creating a timer + from the Schedule menu (by pressing the Red button), then pressing Red again to edit + the timer, making it a pattern timer and moving it to a remote machine, did not cause + an immediate respawn on the remote machine, because at that time the event on the remote + machine was still covered by the initial timer (which, from the remote machine's standpoint, + was "remote"). diff --git a/timers.c b/timers.c index 1dc3c75a..bfa1f700 100644 --- a/timers.c +++ b/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 5.9 2021/04/06 14:25:05 kls Exp $ + * $Id: timers.c 5.10 2021/04/10 10:09:50 kls Exp $ */ #include "timers.h" @@ -731,7 +731,7 @@ bool cTimer::SpawnPatternTimers(const cSchedules *Schedules, cTimers *Timers) if (Matches(e) != tmNone) { bool CheckThis = false; bool CheckNext = false; - if (e->HasTimer()) // a matching event that already has a timer + if (Timers->GetTimerForEvent(e, tfSpawned)) // a matching event that already has a spawned timer CheckNext = true; else if (e->EndTime() > Now) { // only look at events that have not yet ended CheckThis = true; @@ -744,7 +744,7 @@ bool cTimer::SpawnPatternTimers(const cSchedules *Schedules, cTimers *Timers) if (CheckNext) { // We also check the event immediately following this one: e = Schedule->Events()->Next(e); - if (e && !e->HasTimer() && Matches(e) != tmNone) { + if (e && !Timers->GetTimerForEvent(e, tfSpawned) && Matches(e) != tmNone) { SpawnPatternTimer(e, Timers); TimersSpawned = true; } @@ -1084,6 +1084,17 @@ const cTimer *cTimers::GetMatch(const cEvent *Event, eTimerMatch *Match) const return t; } +const cTimer *cTimers::GetTimerForEvent(const cEvent *Event, eTimerFlags Flags) +{ + if (Event && Event->HasTimer()) { + for (const cTimer *ti = First(); ti; ti = Next(ti)) { + if (ti->Event() == Event && ti->Local() && ti->HasFlags(Flags)) + return ti; + } + } + return NULL; +} + int cTimers::GetMaxPriority(void) const { int n = -1; diff --git a/timers.h b/timers.h index 0c707f7b..18c8362d 100644 --- a/timers.h +++ b/timers.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: timers.h 5.4 2021/04/06 08:48:35 kls Exp $ + * $Id: timers.h 5.5 2021/04/10 10:09:50 kls Exp $ */ #ifndef __TIMERS_H @@ -192,6 +192,7 @@ public: cTimer *GetMatch(time_t t) { return const_cast(static_cast(this)->GetMatch(t)); }; const cTimer *GetMatch(const cEvent *Event, eTimerMatch *Match = NULL) const; cTimer *GetMatch(const cEvent *Event, eTimerMatch *Match = NULL) { return const_cast(static_cast(this)->GetMatch(Event, Match)); } + const cTimer *GetTimerForEvent(const cEvent *Event, eTimerFlags Flags = tfNone); int GetMaxPriority(void) const; ///< Returns the maximum priority of all local timers that are currently recording. ///< If there is no local timer currently recording, -1 is returned.