From c68848a7d4ea310c9005e5228ca78997ab70114b Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 25 Jul 2008 14:52:29 +0000
Subject: [PATCH] reinitialize the parser symbol tree when we open a new projet
 file

(only if the current model is not empty: if it's empty it probably mean
we just launched gmsh, and we don't want to delete variables set e.g.
using the -string command line option)

all this open/merge stuff needs to be cleaned up
---
 Common/Gmsh.cpp     | 2 +-
 Common/OpenFile.cpp | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp
index 8a1f2a7773..18cb37bcaf 100644
--- a/Common/Gmsh.cpp
+++ b/Common/Gmsh.cpp
@@ -32,7 +32,7 @@ int GmshInitialize(int argc, char **argv)
   // Initialize messages (parallel stuff, etc.)
   Msg::Init(argc, argv);
 
-#if !defined(HAVE_NO_POST)
+#if !defined(HAVE_NO_PARSER)
   // Initialize the symbol tree that will hold variable names in the
   // parser
   InitSymbols();
diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 61ee997bfc..fe3e647e8f 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -402,6 +402,13 @@ void OpenProject(const char *name)
   for(int i = PView::list.size() - 1; i >= 0; i--)
     if(PView::list[i]->getData()->hasModel(GModel::current()))
       delete PView::list[i];
+#endif
+#if !defined(HAVE_NO_PARSER)
+  // reinitialize the parser symbol tree (only if the current model is
+  // not empty: if it's empty it probably mean we just launched gmsh,
+  // and we don't want to delete variables set e.g. using the -string
+  // command line option)
+  if(GModel::current()->getNumVertices()) InitSymbols();
 #endif
   GModel::current()->destroy();
   GModel::current()->getGEOInternals()->destroy();
-- 
GitLab