Workload of bug OCC13051

Using class DLL_Collector for collect loaded libraries.
This commit is contained in:
abd 2006-08-01 10:20:34 +00:00
parent 7832c44c36
commit 27d354cd64

View 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());