From d9b5eeef6b23560891b82c12828a45337bd764ad Mon Sep 17 00:00:00 2001 From: "Chris \"Koying\" Browet" Date: Wed, 31 Oct 2012 13:29:01 +0100 Subject: [PATCH] FIX: Crash when generating thumbnails (at least with mysql on Windows) --- xbmc/video/VideoThumbLoader.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xbmc/video/VideoThumbLoader.cpp b/xbmc/video/VideoThumbLoader.cpp index 2e2e0fcf1d7f8..7c72a8be2879f 100644 --- a/xbmc/video/VideoThumbLoader.cpp +++ b/xbmc/video/VideoThumbLoader.cpp @@ -392,7 +392,17 @@ 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 CVideoThumLoader object. + // As mysql is not thread-safe (at least on Windows), have to create a database object, here. + 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);