[epg] fixed initial table id value when tables are created. fixes mixed up EPG entrie...
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 21 Dec 2012 01:24:04 +0000 (02:24 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 21 Dec 2012 01:31:15 +0000 (02:31 +0100)
xbmc/epg/EpgContainer.cpp
xbmc/epg/EpgDatabase.cpp
xbmc/epg/EpgDatabase.h

index 679ca14..c6c5ef7 100644 (file)
@@ -100,6 +100,7 @@ void CEpgContainer::Clear(bool bClearDb /* = false */)
     m_epgs.clear();
     m_iNextEpgUpdate  = 0;
     m_bIsInitialising = true;
+    m_iNextEpgId = 0;
   }
 
   /* clear the database entries */
@@ -174,6 +175,8 @@ void CEpgContainer::LoadFromDB(void)
   if (!m_database.IsOpen())
     m_database.Open();
 
+  m_iNextEpgId = m_database.GetLastEPGId();
+
   bool bLoaded(true);
   unsigned int iCounter(0);
   if (m_database.IsOpen())
index 65a5984..f21f234 100644 (file)
@@ -414,3 +414,12 @@ int CEpgDatabase::Persist(const CEpgInfoTag &tag, bool bSingleUpdate /* = true *
 
   return iReturn;
 }
+
+int CEpgDatabase::GetLastEPGId(void)
+{
+  CStdString strQuery = FormatSQL("SELECT MAX(idEpg) FROM epg");
+  CStdString strValue = GetSingleValue(strQuery);
+  if (!strValue.empty())
+    return atoi(strValue.c_str());
+  return 0;
+}
index 1360989..c34b654 100644 (file)
@@ -138,6 +138,11 @@ namespace EPG
      */
     virtual int Persist(const CEpgInfoTag &tag, bool bSingleUpdate = true);
 
+    /*!
+     * @return Last EPG id in the database
+     */
+    int GetLastEPGId(void);
+
     //@}
 
   protected: