From 4d2181b79570209a2ed7cd11ac3f8b7d62ad6612 Mon Sep 17 00:00:00 2001 From: "Charlton, Scott R" Date: Fri, 25 Aug 2023 19:44:03 -0600 Subject: [PATCH] Fixed bug that caused selected_output to accumulate in selected_output storage --- IPhreeqc.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/IPhreeqc.cpp b/IPhreeqc.cpp index e648b313..4212aee8 100644 --- a/IPhreeqc.cpp +++ b/IPhreeqc.cpp @@ -1164,7 +1164,6 @@ void IPhreeqc::check_database(const char* sz_routine) delete (*it).second; } this->SelectedOutputMap.clear(); - this->SelectedOutputStringMap.clear(); // release this->LogString.clear(); @@ -1172,13 +1171,15 @@ void IPhreeqc::check_database(const char* sz_routine) this->OutputString.clear(); this->OutputLines.clear(); + // clear selected_output string storage + // GetSelectedOutputStringLine and GetSelectedOutputString std::map< int, std::string >::iterator mit = SelectedOutputStringMap.begin(); - for (; mit != SelectedOutputStringMap.begin(); ++mit) + for (; mit != SelectedOutputStringMap.end(); ++mit) { (*mit).second.clear(); } std::map< int, std::vector< std::string > >::iterator lit = this->SelectedOutputLinesMap.begin(); - for (; lit != this->SelectedOutputLinesMap.begin(); ++lit) + for (; lit != this->SelectedOutputLinesMap.end(); ++lit) { (*lit).second.clear(); } @@ -1245,6 +1246,18 @@ void IPhreeqc::do_run(const char* sz_routine, std::istream* pis, PFN_PRERUN_CALL this->PhreeqcPtr->dup_print(token, TRUE); if (this->PhreeqcPtr->read_input() == EOF) break; + + if (this->PhreeqcPtr->simulation == 1) + { + // force headings for selected output (on every call to do_run) + // might want to split tidy_punch to avoid duplicate searches like master_bsearch + std::map< int, SelectedOutput >::iterator pit = this->PhreeqcPtr->SelectedOutput_map.begin(); + for (; pit != this->PhreeqcPtr->SelectedOutput_map.end(); ++pit) + { + (*pit).second.Set_new_def(true); + this->PhreeqcPtr->keycount[Keywords::KEY_SELECTED_OUTPUT] = 1; + } + } // bool bWarning = false; std::map< int, SelectedOutput >::iterator mit = this->PhreeqcPtr->SelectedOutput_map.begin();