From 3ba6ce887bf4c7bf25777a47eb640bbdf09e0c62 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 May 2005 10:37:18 +0000 Subject: [PATCH] Added re-entrent mutex to serialize access to OpenFlight plugin to prevent any multi-threaded issues. --- src/osgPlugins/flt/ReaderWriterFLT.cpp | 3 +++ src/osgPlugins/flt/ReaderWriterFLT.h | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/flt/ReaderWriterFLT.cpp b/src/osgPlugins/flt/ReaderWriterFLT.cpp index 69296d585..3e8436c34 100644 --- a/src/osgPlugins/flt/ReaderWriterFLT.cpp +++ b/src/osgPlugins/flt/ReaderWriterFLT.cpp @@ -25,6 +25,9 @@ osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readObject(const std::string& f osgDB::ReaderWriter::ReadResult ReaderWriterFLT::readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { + // serialize all access to the OpenFlight plugin as its not thread safe by itself. + OpenThreads::ScopedLock lock(_serializerMutex); + std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; diff --git a/src/osgPlugins/flt/ReaderWriterFLT.h b/src/osgPlugins/flt/ReaderWriterFLT.h index 01f3cde57..4c61ec49f 100644 --- a/src/osgPlugins/flt/ReaderWriterFLT.h +++ b/src/osgPlugins/flt/ReaderWriterFLT.h @@ -1,4 +1,3 @@ - // // OpenFlightŪ loader for Open Scene Graph // @@ -39,6 +38,7 @@ #include #include +#include namespace flt { @@ -56,6 +56,10 @@ public: virtual ReadResult readObject(const std::string& fileName, const osgDB::ReaderWriter::Options*) const; virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const; + +protected: + + mutable osgDB::ReentrantMutex _serializerMutex; };