Commit ee648b6d authored by Jan Möbius's avatar Jan Möbius

Try to get rid of memory leak in IOManager



git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@830 fdac6126-5c0c-442c-9429-916003d36597
parent adf464de
......@@ -63,23 +63,22 @@ namespace IO {
//=============================================================================
_IOManager_ *__IOManager_instance = 0;
// Destructor never called. Moved into singleton getter function
// _IOManager_ *__IOManager_instance = 0;
_IOManager_& IOManager()
{
if (!__IOManager_instance)
__IOManager_instance = new _IOManager_();
static _IOManager_ __IOManager_instance;
return *__IOManager_instance;
}
//if (!__IOManager_instance)
// __IOManager_instance = new _IOManager_();
return __IOManager_instance;
}
//-----------------------------------------------------------------------------
bool
_IOManager_::
read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
......
......@@ -101,12 +101,18 @@ class OPENMESHDLLEXPORT _IOManager_
{
private:
/// Constructor has nothing todo for the Manager
_IOManager_() {}
friend OPENMESHDLLEXPORT _IOManager_& IOManager();
/// Destructor has nothing todo for the Manager
~_IOManager_() {};
public:
/** Declare the singleton getter function as friend to access the private constructor
and destructor
*/
friend OPENMESHDLLEXPORT _IOManager_& IOManager();
public:
/**
Read a mesh from file _filename. The target data structure is specified
......@@ -247,12 +253,10 @@ private:
//=============================================================================
extern _IOManager_* __IOManager_instance;
//_IOManager_* __IOManager_instance; Causes memory leak, as destructor is never called
OPENMESHDLLEXPORT _IOManager_& IOManager();
//=============================================================================
} // namespace IO
} // namespace OpenMesh
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment