Skip to content
This repository
Browse code

fixed crash when CLocalizeStrings::Load() is called from multiple thr…

…eads, which is possible when called by add-ons.
  • Loading branch information...
commit 9e4c515c5426bef749594610fb4915c5d4e3acaf 1 parent 29aa6cf
Lars Op den Kamp authored July 12, 2013
2  xbmc/guilib/LocalizeStrings.cpp
@@ -27,6 +27,7 @@
27 27
 #include "utils/URIUtils.h"
28 28
 #include "utils/POUtils.h"
29 29
 #include "filesystem/Directory.h"
  30
+#include "threads/SingleLock.h"
30 31
 
31 32
 CLocalizeStrings::CLocalizeStrings(void)
32 33
 {
@@ -188,6 +189,7 @@ bool CLocalizeStrings::Load(const CStdString& strPathName, const CStdString& str
188 189
   bool bLoadFallback = !strLanguage.Equals(SOURCE_LANGUAGE);
189 190
 
190 191
   CStdString encoding;
  192
+  CSingleLock lock(m_critSection);
191 193
   Clear();
192 194
 
193 195
   if (!LoadStr2Mem(strPathName, strLanguage, encoding))
2  xbmc/guilib/LocalizeStrings.h
@@ -29,6 +29,7 @@
29 29
  */
30 30
 
31 31
 #include "utils/StdString.h"
  32
+#include "threads/CriticalSection.h"
32 33
 
33 34
 #include <map>
34 35
 
@@ -101,6 +102,7 @@ class CLocalizeStrings
101 102
   static const uint32_t block_size = 4096;
102 103
   std::map<CStdString, uint32_t> m_blocks;
103 104
   typedef std::map<CStdString, uint32_t>::iterator iBlocks;
  105
+  CCriticalSection m_critSection;
104 106
 };
105 107
 
106 108
 /*!

0 notes on commit 9e4c515

Please sign in to comment.
Something went wrong with that request. Please try again.