]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Workaround of BUG OCC13051
authorabd <abd@opencascade.com>
Wed, 26 Jul 2006 11:32:13 +0000 (11:32 +0000)
committerabd <abd@opencascade.com>
Wed, 26 Jul 2006 11:32:13 +0000 (11:32 +0000)
src/GEOMImpl/GEOMImpl_ImportDriver.cxx

index b20706d1ec32053ebf4ae0304666aed3c50e7b23..2231421b4213f3a337bcac7323c3a98982c8f566 100644 (file)
@@ -32,6 +32,8 @@
 #include <Standard_ConstructionError.hxx>
 #include <StdFail_NotDone.hxx>
 
+#include <NCollection_DataMap.hxx>
+
 #ifdef WNT
 #include <windows.h>
 #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<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  :
@@ -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());