diff options
author | Kai Sommerfeld <kai.sommerfeld@gmx.com> | 2020-02-08 19:14:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-08 19:14:06 +0100 |
commit | e50950aa01e8090109869dc03e1af6d361136230 (patch) | |
tree | 1f14b09665c8e426c5ef1f08cbd74268d104665e | |
parent | 6ec05fcd7198b6e586bd97873fe3cf42e4aa853f (diff) | |
parent | febe52d1ba10abfd7f41104ce1453723fdd09626 (diff) |
Merge pull request #17345 from ksooo/pvr-fix-epgtags-delete
[PVR] Fix EPG tags not deleted from database after deleting a channel
-rw-r--r-- | xbmc/pvr/channels/PVRChannel.cpp | 2 | ||||
-rw-r--r-- | xbmc/pvr/epg/Epg.cpp | 19 | ||||
-rw-r--r-- | xbmc/pvr/epg/Epg.h | 7 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgContainer.cpp | 8 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgContainer.h | 3 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgDatabase.cpp | 9 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgDatabase.h | 7 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgTagsContainer.cpp | 8 | ||||
-rw-r--r-- | xbmc/pvr/epg/EpgTagsContainer.h | 6 |
9 files changed, 61 insertions, 8 deletions
diff --git a/xbmc/pvr/channels/PVRChannel.cpp b/xbmc/pvr/channels/PVRChannel.cpp index f70ba0e5d2..945fb1e94d 100644 --- a/xbmc/pvr/channels/PVRChannel.cpp +++ b/xbmc/pvr/channels/PVRChannel.cpp @@ -110,7 +110,7 @@ bool CPVRChannel::Delete() const std::shared_ptr<CPVREpg> epg = GetEPG(); if (epg) { - CServiceBroker::GetPVRManager().EpgContainer().DeleteEpg(epg, true); + CServiceBroker::GetPVRManager().EpgContainer().DeleteEpg(epg); CSingleLock lock(m_critSection); m_epg.reset(); diff --git a/xbmc/pvr/epg/Epg.cpp b/xbmc/pvr/epg/Epg.cpp index 37c9b526fa..cacdde3d0a 100644 --- a/xbmc/pvr/epg/Epg.cpp +++ b/xbmc/pvr/epg/Epg.cpp @@ -334,6 +334,25 @@ bool CPVREpg::Persist(const std::shared_ptr<CPVREpgDatabase>& database) return bRet; } +bool CPVREpg::Delete(const std::shared_ptr<CPVREpgDatabase>& database) +{ + if (!database) + { + CLog::LogF(LOGERROR, "No EPG database"); + return false; + } + + // delete own epg db entry + database->Delete(*this); + + // delete all tags for this epg from db + m_tags.Delete(); + + Clear(); + + return true; +} + CDateTime CPVREpg::GetFirstDate() const { CSingleLock lock(m_critSection); diff --git a/xbmc/pvr/epg/Epg.h b/xbmc/pvr/epg/Epg.h index ce93ac507e..a02ca92e9a 100644 --- a/xbmc/pvr/epg/Epg.h +++ b/xbmc/pvr/epg/Epg.h @@ -210,6 +210,13 @@ namespace PVR bool Persist(const std::shared_ptr<CPVREpgDatabase>& database); /*! + * @brief Delete this table from the given database + * @param database The database. + * @return True if the table was deleted, false otherwise. + */ + bool Delete(const std::shared_ptr<CPVREpgDatabase>& database); + + /*! * @brief Get the start time of the first entry in this table. * @return The first date in UTC. */ diff --git a/xbmc/pvr/epg/EpgContainer.cpp b/xbmc/pvr/epg/EpgContainer.cpp index 5724b42196..869e2e6939 100644 --- a/xbmc/pvr/epg/EpgContainer.cpp +++ b/xbmc/pvr/epg/EpgContainer.cpp @@ -566,7 +566,7 @@ bool CPVREpgContainer::RemoveOldEntries() return true; } -bool CPVREpgContainer::DeleteEpg(const std::shared_ptr<CPVREpg>& epg, bool bDeleteFromDatabase /* = false */) +bool CPVREpgContainer::DeleteEpg(const std::shared_ptr<CPVREpg>& epg) { if (!epg || epg->EpgID() < 0) return false; @@ -583,8 +583,8 @@ bool CPVREpgContainer::DeleteEpg(const std::shared_ptr<CPVREpg>& epg, bool bDele m_channelUidToEpgMap.erase(epgEntry1); CLog::LogFC(LOGDEBUG, LOGEPG, "Deleting EPG table %s (%d)", epg->Name().c_str(), epg->EpgID()); - if (bDeleteFromDatabase) - GetEpgDatabase()->Delete(*epgEntry->second); + + epgEntry->second->Delete(GetEpgDatabase()); epgEntry->second->Events().Unsubscribe(this); m_epgIdToEpgMap.erase(epgEntry); @@ -685,7 +685,7 @@ bool CPVREpgContainer::UpdateEPG(bool bOnlyPending /* = false */) progressHandler->DestroyProgress(); for (const auto& epg : invalidTables) - DeleteEpg(epg, true); + DeleteEpg(epg); if (bInterrupted) { diff --git a/xbmc/pvr/epg/EpgContainer.h b/xbmc/pvr/epg/EpgContainer.h index c3c8217e7d..a47f0ee7b7 100644 --- a/xbmc/pvr/epg/EpgContainer.h +++ b/xbmc/pvr/epg/EpgContainer.h @@ -87,10 +87,9 @@ namespace PVR /*! * @brief Delete an EPG table from this container. * @param epg The table to delete. - * @param bDeleteFromDatabase Delete this table from the database too if true. * @return True on success, false otherwise. */ - bool DeleteEpg(const std::shared_ptr<CPVREpg>& epg, bool bDeleteFromDatabase = false); + bool DeleteEpg(const std::shared_ptr<CPVREpg>& epg); /*! * @brief CEventStream callback for PVR events. diff --git a/xbmc/pvr/epg/EpgDatabase.cpp b/xbmc/pvr/epg/EpgDatabase.cpp index 530d8305f8..a973819324 100644 --- a/xbmc/pvr/epg/EpgDatabase.cpp +++ b/xbmc/pvr/epg/EpgDatabase.cpp @@ -895,6 +895,15 @@ bool CPVREpgDatabase::DeleteEpgTags(int iEpgId, const CDateTime& maxEndTime) return DeleteValues("epgtags", filter); } +bool CPVREpgDatabase::DeleteEpgTags(int iEpgId) +{ + Filter filter; + + CSingleLock lock(m_critSection); + filter.AppendWhere(PrepareSQL("idEpg = %u", iEpgId)); + return DeleteValues("epgtags", filter); +} + int CPVREpgDatabase::Persist(const CPVREpgInfoTag& tag, bool bSingleUpdate /* = true */) { int iReturn(-1); diff --git a/xbmc/pvr/epg/EpgDatabase.h b/xbmc/pvr/epg/EpgDatabase.h index b76681394d..dc0afc9d07 100644 --- a/xbmc/pvr/epg/EpgDatabase.h +++ b/xbmc/pvr/epg/EpgDatabase.h @@ -243,6 +243,13 @@ namespace PVR bool DeleteEpgTags(int iEpgId, const CDateTime& maxEndTime); /*! + * @brief Erase all EPG tags with the given epg ID. + * @param iEpgID The ID of the EPG. + * @return True if the entries were removed successfully, false otherwise. + */ + bool DeleteEpgTags(int iEpgId); + + /*! * @brief Persist an infotag. * @param tag The tag to persist. * @param bSingleUpdate If true, this is a single update and the query will be executed immediately. diff --git a/xbmc/pvr/epg/EpgTagsContainer.cpp b/xbmc/pvr/epg/EpgTagsContainer.cpp index f07bf87e3b..935267ce2e 100644 --- a/xbmc/pvr/epg/EpgTagsContainer.cpp +++ b/xbmc/pvr/epg/EpgTagsContainer.cpp @@ -608,3 +608,11 @@ void CPVREpgTagsContainer::Persist(bool bCommit) m_database->Unlock(); } } + +void CPVREpgTagsContainer::Delete() +{ + if (m_database) + m_database->DeleteEpgTags(m_iEpgID); + + Clear(); +} diff --git a/xbmc/pvr/epg/EpgTagsContainer.h b/xbmc/pvr/epg/EpgTagsContainer.h index d1ddac2c2f..f3ef0ad726 100644 --- a/xbmc/pvr/epg/EpgTagsContainer.h +++ b/xbmc/pvr/epg/EpgTagsContainer.h @@ -161,10 +161,14 @@ public: /*! * @brief Persist this container in its database. * @param bCommit Whether to commit the data. - * @return True if the data was persisted, false otherwise. */ void Persist(bool bCommit); + /*! + * @brief Delete this container from its database. + */ + void Delete(); + private: /*! * @brief Complete the instance data for the given tags. |