Merge pull request #4399 from Jalle19/missing-db-close
authorjmarshallnz <jcmarsha@gmail.com>
Thu, 13 Mar 2014 20:39:34 +0000 (09:39 +1300)
committerJonathan Marshall <jmarshall@xbmc.org>
Fri, 14 Mar 2014 21:50:33 +0000 (10:50 +1300)
[pvr] add missing database close call

xbmc/pvr/recordings/PVRRecording.cpp
xbmc/pvr/recordings/PVRRecording.h

index c821f73..5b60007 100644 (file)
@@ -181,23 +181,30 @@ bool CPVRRecording::SetPlayCount(int count)
 
 void CPVRRecording::UpdateMetadata(void)
 {
-  CVideoDatabase db;
-
-  if (!g_PVRClients->SupportsRecordingPlayCount(m_iClientId))
+  if (m_bGotMetaData)
+    return;
+    
+  bool supportsPlayCount  = g_PVRClients->SupportsRecordingPlayCount(m_iClientId);
+  bool supportsLastPlayed = g_PVRClients->SupportsLastPlayedPosition(m_iClientId);
+  
+  if (!supportsPlayCount || !supportsLastPlayed)
   {
-    if (!m_bGotMetaData && db.Open())
+    CVideoDatabase db;
+    if (db.Open())
     {
-      CFileItem pFileItem(*this);
-      m_playCount = db.GetPlayCount(pFileItem);
-    }
-  }
+      if (!supportsPlayCount)
+      {
+        CFileItem pFileItem(*this);
+        m_playCount = db.GetPlayCount(pFileItem);
+      }
 
-  if (!g_PVRClients->SupportsLastPlayedPosition(m_iClientId))
-  {
-    if (!m_bGotMetaData && db.Open())
-      db.GetResumeBookMark(m_strFileNameAndPath, m_resumePoint);
-  }
+      if (!supportsLastPlayed)
+        db.GetResumeBookMark(m_strFileNameAndPath, m_resumePoint);
 
+      db.Close();
+    }
+  }
+  
   m_bGotMetaData = true;
 }
 
index dfa28a8..814b36d 100644 (file)
@@ -123,8 +123,8 @@ namespace PVR
     std::vector<PVR_EDL_ENTRY> GetEdl() const;
 
     /*!
-     * @brief Get the resume point and play count from the server (if supported) or the database
-     * @param bookmark The bookmark to update
+     * @brief Get the resume point and play count from the database if the 
+     * client doesn't handle it itself.
      */
     void UpdateMetadata(void);