From ab1cf0cf792083fcceff7788a58a6773fe67578b Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:23:02 +0200 Subject: [PVR] Fix CPVRTimers::UpdateEntries: Delete existing epg-based local timers if the respective EPG tag does no longer exist. --- xbmc/pvr/timers/PVRTimers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 53be1a9269..91dd76481c 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -551,6 +551,12 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) } } } + else if (!timer->IsTimerRule()) + { + // epg event no longer present. delete the timer + bDeleteTimer = true; + timer->DeleteFromDatabase(); + } } } -- cgit v1.2.3 From d9fd7760e74713503fc16c6aece4def0bc2bae83 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sat, 29 Jun 2024 17:55:55 +0200 Subject: [PVR] Fix CPVRTimers::UpdateEntries: Delete existing epg-based local timers if the respective EPG tag was re-used for an unrelated event that no longer matches the related timer rule. --- xbmc/pvr/timers/PVRTimers.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 91dd76481c..440f33e57f 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -550,6 +550,23 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) timer->Persist(); } } + + // check for epg tag uids that were re-used for a different event (which is actually + // an add-on/a backend bug) + if (!timer->IsTimerRule() && (epgTag->Title() != timer->Title())) + { + const std::shared_ptr parent{GetTimerRule(timer)}; + if (parent) + { + const CPVRTimerRuleMatcher matcher{parent, now}; + if (!matcher.Matches(epgTag)) + { + // epg event no longer matches the rule. delete the timer + bDeleteTimer = true; + timer->DeleteFromDatabase(); + } + } + } } else if (!timer->IsTimerRule()) { -- cgit v1.2.3 From efc508d5d1d8927fde504345991f61b7bb3ee7b7 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:04:03 +0200 Subject: [PVR] Fix CPVRTimers::UpdateEntries: Re-insert timers with changed start time before checking whether new children for local timer rules need to be created. The timers with changed start time need to be found during that check. This fixes creation of duplicate timers. --- xbmc/pvr/timers/PVRTimers.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xbmc/pvr/timers/PVRTimers.cpp b/xbmc/pvr/timers/PVRTimers.cpp index 440f33e57f..8339da75b7 100644 --- a/xbmc/pvr/timers/PVRTimers.cpp +++ b/xbmc/pvr/timers/PVRTimers.cpp @@ -668,6 +668,13 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) ++it; } + // reinsert timers with changed timer start + for (const auto& timer : timersToReinsert) + { + InsertEntry(timer); + timer->Persist(); + } + // create new children of local epg-based reminder timer rules for (const auto& epgMapEntry : epgMap) { @@ -694,14 +701,7 @@ bool CPVRTimers::UpdateEntries(int iMaxNotificationDelay) } } - // reinsert timers with changed timer start - for (const auto& timer : timersToReinsert) - { - InsertEntry(timer); - timer->Persist(); - } - - // insert new children of time-based local timer rules + // persist and insert/update new children of local time-based and epg-based reminder timer rules for (const auto& timerPair : childTimersToInsert) { PersistAndUpdateLocalTimer(timerPair.second, timerPair.first); -- cgit v1.2.3