From 26f57b892ff8aa30f47668de0d8879391961be14 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 24 May 2013 17:33:22 +0000 Subject: [PATCH] OpenProject does not reset parser variables if we have -string on the command line; otherwise always reset them --- Common/OpenFile.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index a5d23aff70..3c629acaf4 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -624,17 +624,21 @@ void OpenProject(const std::string &fileName) Msg::ResetErrorCounter(); if(GModel::current()->empty()){ - // if the current model is empty, make sure it's reaaally - // cleaned-up, and reuse it (don't clear the parser variables: if - // the model is empty we probably just launched gmsh, and we don't - // want to delete variables set e.g. using the -string command - // line option) + // if the current model is empty, make sure it's reaaally cleaned-up, and + // reuse it GModel::current()->destroy(); GModel::current()->getGEOInternals()->destroy(); + // don't clear the parser variables if we just launched gmsh with the + // -string command line option +#if defined(HAVE_PARSER) + std::string c = Msg::GetCommandLineArgs(); + if(c.find("-string") == std::string::npos) + gmsh_yysymbols.clear(); +#endif } else{ - // if the current model is not empty make it invisible, clear the - // parser variables and add a new model + // if the current model is not empty make it invisible, clear the parser + // variables and add a new model #if defined(HAVE_PARSER) gmsh_yysymbols.clear(); #endif @@ -642,8 +646,7 @@ void OpenProject(const std::string &fileName) GModel::current(GModel::list.size() - 1); } - // temporary hack until we fill the current GModel on the fly during - // parsing + // temporary hack until we fill the current GModel on the fly during parsing ResetTemporaryBoundingBox(); // merge the file -- GitLab