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 { ...@@ -63,23 +63,22 @@ namespace IO {
//============================================================================= //=============================================================================
// Destructor never called. Moved into singleton getter function
_IOManager_ *__IOManager_instance = 0; // _IOManager_ *__IOManager_instance = 0;
_IOManager_& IOManager() _IOManager_& IOManager()
{ {
if (!__IOManager_instance) static _IOManager_ __IOManager_instance;
__IOManager_instance = new _IOManager_();
return *__IOManager_instance; //if (!__IOManager_instance)
} // __IOManager_instance = new _IOManager_();
return __IOManager_instance;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
_IOManager_:: _IOManager_::
read(const std::string& _filename, BaseImporter& _bi, Options& _opt) read(const std::string& _filename, BaseImporter& _bi, Options& _opt)
......
...@@ -101,12 +101,18 @@ class OPENMESHDLLEXPORT _IOManager_ ...@@ -101,12 +101,18 @@ class OPENMESHDLLEXPORT _IOManager_
{ {
private: private:
/// Constructor has nothing todo for the Manager
_IOManager_() {} _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 Read a mesh from file _filename. The target data structure is specified
...@@ -247,12 +253,10 @@ private: ...@@ -247,12 +253,10 @@ private:
//============================================================================= //=============================================================================
extern _IOManager_* __IOManager_instance; //_IOManager_* __IOManager_instance; Causes memory leak, as destructor is never called
OPENMESHDLLEXPORT _IOManager_& IOManager(); OPENMESHDLLEXPORT _IOManager_& IOManager();
//============================================================================= //=============================================================================
} // namespace IO } // namespace IO
} // namespace OpenMesh } // 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