From 89e4751823fc0d546a79b871204e01fda71ff3d9 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 21 Jul 2004 20:41:06 +0000 Subject: [PATCH] Took the deletion of a static pointer out of destructor. --- Cantera/src/ThermoFactory.h | 15 +++++++++++++-- Cantera/src/misc.cpp | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cantera/src/ThermoFactory.h b/Cantera/src/ThermoFactory.h index 9703a7f0a..f048483df 100644 --- a/Cantera/src/ThermoFactory.h +++ b/Cantera/src/ThermoFactory.h @@ -42,9 +42,20 @@ namespace Cantera { return __factory; } + static void deleteFactory() { + if (__factory) { + delete __factory; + __factory = 0; + } + } + + /** + * Destructor doesn't do anything. We do not delete statically + * created single instance of this class here, because it would + * create an infinite loop if destructor is called for that + * single instance. + */ virtual ~ThermoFactory() { - delete __factory; - __factory = 0; } /** diff --git a/Cantera/src/misc.cpp b/Cantera/src/misc.cpp index a9d4a5a55..53c98eccd 100755 --- a/Cantera/src/misc.cpp +++ b/Cantera/src/misc.cpp @@ -20,6 +20,7 @@ #include "xml.h" #include "ctml.h" #include "SpeciesThermoFactory.h" +#include "ThermoFactory.h" #include "FalloffFactory.h" //#ifndef WIN32 @@ -91,6 +92,7 @@ namespace Cantera { __app = 0; } SpeciesThermoFactory::deleteFactory(); + ThermoFactory::deleteFactory(); FalloffFactory::deleteFalloffFactory(); Unit::deleteUnit(); }