From 666e688bead1dde0bedce8b1c0f8f26639a1ae5a Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Thu, 20 Dec 2007 22:07:34 +0000 Subject: [PATCH] Bug fix to the newPhase function. --- Cantera/src/thermo/ThermoFactory.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Cantera/src/thermo/ThermoFactory.cpp b/Cantera/src/thermo/ThermoFactory.cpp index 1dedde1f6..7355ae47e 100644 --- a/Cantera/src/thermo/ThermoFactory.cpp +++ b/Cantera/src/thermo/ThermoFactory.cpp @@ -210,14 +210,17 @@ namespace Cantera { ThermoPhase* newPhase(std::string infile, std::string id) { XML_Node* root = get_XML_File(infile); if (id == "-") id = ""; - XML_Node* x = get_XML_Node(string("#")+id, root); - if (x) - return newPhase(*x); + XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root); + if (!xphase) { + throw CanteraError("newPhase", + "Couldn't find phase named \"" + id + "\" in file, " + infile); + } + if (xphase) + return newPhase(*xphase); else - return 0; + return (ThermoPhase *) 0; } - /* * Import a phase specification.