aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphunkyfish <phunkyfish@gmail.com>2023-02-12 14:04:36 +0000
committerphunkyfish <phunkyfish@gmail.com>2023-02-12 14:05:26 +0000
commitb51cd354f8b61e449f339b8722cb9af2830e4379 (patch)
tree967cc360964948d6c344005e3442f8733d554e17
parent7d010efbb843fbf34018e9a5761dd74a472a338d (diff)
[pvr] Retrieve the max provider ID from the DB to ensure any new providers can be successfully created
-rw-r--r--xbmc/pvr/PVRDatabase.cpp8
-rw-r--r--xbmc/pvr/PVRDatabase.h6
-rw-r--r--xbmc/pvr/providers/PVRProviders.cpp2
3 files changed, 16 insertions, 0 deletions
diff --git a/xbmc/pvr/PVRDatabase.cpp b/xbmc/pvr/PVRDatabase.cpp
index 8ad293b672..9475c5a631 100644
--- a/xbmc/pvr/PVRDatabase.cpp
+++ b/xbmc/pvr/PVRDatabase.cpp
@@ -478,6 +478,14 @@ bool CPVRDatabase::Get(CPVRProviders& results,
return bReturn;
}
+int CPVRDatabase::GetMaxProviderId()
+{
+ std::string strQuery = PrepareSQL("SELECT max(idProvider) as maxProviderId from providers");
+ std::unique_lock<CCriticalSection> lock(m_critSection);
+
+ return GetSingleValueInt(strQuery);
+}
+
/********** Channel methods **********/
int CPVRDatabase::Get(bool bRadio,
diff --git a/xbmc/pvr/PVRDatabase.h b/xbmc/pvr/PVRDatabase.h
index e9a1950122..1e9cbf5756 100644
--- a/xbmc/pvr/PVRDatabase.h
+++ b/xbmc/pvr/PVRDatabase.h
@@ -183,6 +183,12 @@ namespace PVR
*/
bool Get(CPVRProviders& results, const std::vector<std::shared_ptr<CPVRClient>>& clients) const;
+ /*!
+ * @brief Get the maximum provider id in the database
+ * @return The maximum provider id in the database
+ */
+ int GetMaxProviderId();
+
//@}
/*! @name Channel group methods */
diff --git a/xbmc/pvr/providers/PVRProviders.cpp b/xbmc/pvr/providers/PVRProviders.cpp
index e4dabe6857..6d751a2fb9 100644
--- a/xbmc/pvr/providers/PVRProviders.cpp
+++ b/xbmc/pvr/providers/PVRProviders.cpp
@@ -105,6 +105,8 @@ bool CPVRProviders::LoadFromDatabase(const std::vector<std::shared_ptr<CPVRClien
const std::shared_ptr<CPVRDatabase> database = CServiceBroker::GetPVRManager().GetTVDatabase();
if (database)
{
+ m_iLastId = database->GetMaxProviderId();
+
CPVRProviders providers;
database->Get(providers, clients);