From ddeda336632decb7af61bdd6192a6291718ca167 Mon Sep 17 00:00:00 2001 From: abd Date: Wed, 26 Jul 2006 11:32:13 +0000 Subject: [PATCH] Workaround of BUG OCC13051 --- src/GEOMImpl/GEOMImpl_ImportDriver.cxx | 41 +++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx index b20706d1e..2231421b4 100644 --- a/src/GEOMImpl/GEOMImpl_ImportDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ImportDriver.cxx @@ -32,6 +32,8 @@ #include #include +#include + #ifdef WNT #include #else @@ -54,6 +56,37 @@ typedef TopoDS_Shape (*funcPoint)(const TCollection_AsciiString&, const TCollection_AsciiString&, TCollection_AsciiString&); +//This class is workaround of BUG OCC13051 +//It's stored all loaded libraries for import and unload that in destructor +class DLL_Collector +{ + typedef NCollection_DataMap DLL_Collector_Map; + DLL_Collector_Map myMapOfDLL; +public: + DLL_Collector(){}; + ~DLL_Collector() + { + DLL_Collector_Map::Iterator Iter( myMapOfDLL ); + for( ; Iter.More(); Iter.Next() ) + UnLoadLib( Iter.Value() ); + } + +public: + LibHandle LoadDLL( const TCollection_AsciiString& theLibName ) + { + if ( myMapOfDLL.IsBound( theLibName ) ) + return myMapOfDLL( theLibName ); + + LibHandle res = LoadLib( theLibName.ToCString() ); + if ( res ) + myMapOfDLL.Bind( theLibName, res ); + + return res; + } +}; + +static DLL_Collector GlobalCollector; + //======================================================================= //function : GetID //purpose : @@ -92,8 +125,8 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const if (aFileName.IsEmpty() || aFormatName.IsEmpty() || aLibName.IsEmpty()) return 0; - // load plugin library - LibHandle anImportLib = LoadLib( aLibName.ToCString() ); + // load plugin library + LibHandle anImportLib = GlobalCollector.LoadDLL( aLibName ); //This is workaround of BUG OCC13051 funcPoint fp = 0; if ( anImportLib ) fp = (funcPoint)GetProc( anImportLib, "Import" ); @@ -105,8 +138,8 @@ Standard_Integer GEOMImpl_ImportDriver::Execute(TFunction_Logbook& log) const TCollection_AsciiString anError; TopoDS_Shape aShape = fp( aFileName, aFormatName, anError ); - // unload plugin library - UnLoadLib( anImportLib ); + // unload plugin library + //UnLoadLib( anImportLib ); //This is workaround of BUG OCC13051 if ( aShape.IsNull() ) { StdFail_NotDone::Raise(anError.ToCString()); -- 2.39.2