From: abd Date: Tue, 1 Aug 2006 10:20:34 +0000 (+0000) Subject: Workload of bug OCC13051 X-Git-Tag: LAST_STABLE_VERSION_21_09_2006_ON_3_2_0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=27d354cd64e2c6c931158bcc0ce82a8a063afe2d;p=modules%2Fgeom.git Workload of bug OCC13051 Using class DLL_Collector for collect loaded libraries. --- 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());