FIX: Crash when generating thumbnails (at least with mysql on Windows)
authorChris "Koying" Browet <cbro@semperpax.com>
Wed, 31 Oct 2012 12:29:01 +0000 (13:29 +0100)
committerChris "Koying" Browet <cbro@semperpax.com>
Thu, 1 Nov 2012 08:29:41 +0000 (09:29 +0100)
xbmc/video/VideoThumbLoader.cpp

index efa7c01..c76b48f 100644 (file)
@@ -408,7 +408,16 @@ void CVideoThumbLoader::OnJobComplete(unsigned int jobID, bool success, CJob* jo
     CVideoInfoTag* info = loader->m_item.GetVideoInfoTag();
 
     if (loader->m_thumb && info->m_iDbId > 0 && !info->m_type.empty())
-      m_database->SetArtForItem(info->m_iDbId, info->m_type, "thumb", loader->m_item.GetArt("thumb"));
+    {
+      // This runs in a different thread than the CVideoThumbLoader object.
+      CVideoDatabase db;
+      if (db.Open())
+      {
+        db.SetArtForItem(info->m_iDbId, info->m_type, "thumb", loader->m_item.GetArt("thumb"));
+        db.Close();
+      }
+
+    }
 
     if (m_pStreamDetailsObs)
       m_pStreamDetailsObs->OnStreamDetails(info->m_streamDetails, info->m_strFileNameAndPath, info->m_iFileId);