From 1bc6d0bae4ca48fc5686645595f02f2b4e2c694d Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 31 Aug 2007 18:56:22 +0000 Subject: [PATCH] Added mutex to protect the readFontFile calls --- src/osgText/Font.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index b3fd6910c..6f7a6f43b 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -28,6 +28,7 @@ using namespace std; static osg::ApplicationUsageProxy Font_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_TEXT_INCREMENTAL_SUBLOADING ","ON | OFF"); +static OpenThreads::Mutex s_FontFileMutex; std::string osgText::findFontFile(const std::string& str) { @@ -35,6 +36,7 @@ std::string osgText::findFontFile(const std::string& str) std::string filename = osgDB::findDataFile(str); if (!filename.empty()) return filename; + OpenThreads::ScopedLock lock(s_FontFileMutex); static osgDB::FilePathList s_FontFilePath; static bool initialized = false; @@ -88,6 +90,8 @@ osgText::Font* osgText::readFontFile(const std::string& filename, const osgDB::R std::string foundFile = findFontFile(filename); if (foundFile.empty()) return 0; + OpenThreads::ScopedLock lock(s_FontFileMutex); + osg::ref_ptr localOptions; if (!userOptions) { @@ -108,6 +112,8 @@ osgText::Font* osgText::readFontFile(const std::string& filename, const osgDB::R osgText::Font* osgText::readFontStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions) { + OpenThreads::ScopedLock lock(s_FontFileMutex); + osg::ref_ptr localOptions; if (!userOptions) {