]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Workload of bug OCC13051
authorabd <abd@opencascade.com>
Tue, 1 Aug 2006 10:20:34 +0000 (10:20 +0000)
committerabd <abd@opencascade.com>
Tue, 1 Aug 2006 10:20:34 +0000 (10:20 +0000)
Using class DLL_Collector for collect loaded libraries.

src/GEOMImpl/GEOMImpl_ExportDriver.cxx

index 77d6acc32b11f2156541ce605e3a5fc9acd79269..045e2a7cd78bcac693ec8a01a8911be197ad9b37 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <Standard_ConstructionError.hxx>
 
+#include <NCollection_DataMap.hxx>
+
 #ifdef WNT
 #include <windows.h>
 #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<TCollection_AsciiString,LibHandle> 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());