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