Refactored the mutex usage in osgText and freetype plugin to prevent multi-thread crash
This commit is contained in:
@@ -32,12 +32,6 @@ static osg::ApplicationUsageProxy Font_e0(osg::ApplicationUsage::ENVIRONMENTAL_V
|
||||
|
||||
static OpenThreads::ReentrantMutex s_FontFileMutex;
|
||||
|
||||
Font::FontMutex* osgText::Font::getSerializeFontCallsMutex()
|
||||
{
|
||||
static OpenThreads::Mutex s_serializeFontCallsMutex;
|
||||
return &s_serializeFontCallsMutex;
|
||||
}
|
||||
|
||||
std::string osgText::findFontFile(const std::string& str)
|
||||
{
|
||||
// try looking in OSGFILEPATH etc first for fonts.
|
||||
@@ -330,14 +324,17 @@ osg::Texture::FilterMode Font::getMagFilterHint() const
|
||||
|
||||
Font::Glyph* Font::getGlyph(const FontResolution& fontRes, unsigned int charcode)
|
||||
{
|
||||
FontSizeGlyphMap::iterator itr = _sizeGlyphMap.find(fontRes);
|
||||
if (itr!=_sizeGlyphMap.end())
|
||||
{
|
||||
GlyphMap& glyphmap = itr->second;
|
||||
GlyphMap::iterator gitr = glyphmap.find(charcode);
|
||||
if (gitr!=glyphmap.end()) return gitr->second.get();
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
||||
FontSizeGlyphMap::iterator itr = _sizeGlyphMap.find(fontRes);
|
||||
if (itr!=_sizeGlyphMap.end())
|
||||
{
|
||||
GlyphMap& glyphmap = itr->second;
|
||||
GlyphMap::iterator gitr = glyphmap.find(charcode);
|
||||
if (gitr!=glyphmap.end()) return gitr->second.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (_implementation.valid()) return _implementation->getGlyph(fontRes, charcode);
|
||||
else return 0;
|
||||
}
|
||||
@@ -400,6 +397,8 @@ bool Font::hasVertical() const
|
||||
|
||||
void Font::addGlyph(const FontResolution& fontRes, unsigned int charcode, Glyph* glyph)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_glyphMapMutex);
|
||||
|
||||
_sizeGlyphMap[fontRes][charcode]=glyph;
|
||||
|
||||
int posX=0,posY=0;
|
||||
|
||||
@@ -37,12 +37,6 @@ static OpenThreads::ReentrantMutex s_Font3DFileMutex;
|
||||
namespace osgText
|
||||
{
|
||||
|
||||
Font::FontMutex* Font3D::getSerializeFontCallsMutex()
|
||||
{
|
||||
static OpenThreads::Mutex s_serializeFontCallsMutex;
|
||||
return &s_serializeFontCallsMutex;
|
||||
}
|
||||
|
||||
std::string findFont3DFile(const std::string& str)
|
||||
{
|
||||
// try looking in OSGFILEPATH etc first for fonts.
|
||||
|
||||
@@ -224,8 +224,6 @@ void Text3D::computeGlyphRepresentation()
|
||||
return;
|
||||
}
|
||||
|
||||
OpenThreads::ScopedLock<Font3D::Font3DMutex> lock(*(_font->getSerializeFontCallsMutex()));
|
||||
|
||||
// initialize bounding box, it will be expanded during glyph position calculation
|
||||
_textBB.init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user