From 27d354cd64e2c6c931158bcc0ce82a8a063afe2d Mon Sep 17 00:00:00 2001 From: abd Date: Tue, 1 Aug 2006 10:20:34 +0000 Subject: [PATCH] Workload of bug OCC13051 Using class DLL_Collector for collect loaded libraries. --- src/GEOMImpl/GEOMImpl_ExportDriver.cxx | 37 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_ExportDriver.cxx b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx index 77d6acc32..045e2a7cd 100644 --- a/src/GEOMImpl/GEOMImpl_ExportDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ExportDriver.cxx @@ -30,6 +30,8 @@ #include +#include + #ifdef WNT #include #else @@ -52,6 +54,37 @@ typedef int (*funcPoint)(const TopoDS_Shape&, const TCollection_AsciiString&, const TCollection_AsciiString&); +//This class is workaround of BUG OCC13051 ( SWP13103 ) +//It's stored all loaded libraries for export 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 : @@ -99,7 +132,7 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const return 0; // load plugin library - LibHandle anExportLib = LoadLib( aLibName.ToCString() ); + LibHandle anExportLib = GlobalCollector.LoadDLL( aLibName ); //This is workaround of BUG OCC13051 funcPoint fp = 0; if ( anExportLib ) fp = (funcPoint)GetProc( anExportLib, "Export" ); @@ -111,7 +144,7 @@ Standard_Integer GEOMImpl_ExportDriver::Execute(TFunction_Logbook& log) const int res = fp( aShape, aFileName, aFormatName ); // unload plugin library - UnLoadLib( anExportLib ); + //UnLoadLib( anExportLib ); if ( res ) log.SetTouched(Label()); -- 2.39.2