From dd43e88f4074e15e6a110aca7206446beecade4f Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Mon, 2 Nov 2009 19:23:47 +0000 Subject: [PATCH] better algo to compute opt filename --- Common/OpenFile.cpp | 9 +++++---- Fltk/menuWindow.cpp | 3 --- Fltk/pluginWindow.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 2464f6df44..6b625a6d21 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -383,6 +383,11 @@ int MergeFile(std::string fileName, bool warnIfMissing) if(!status) Msg::Error("Error loading '%s'", fileName.c_str()); Msg::StatusBar(2, true, "Read '%s'", fileName.c_str()); + + // merge the associated option file if there is one + if(!StatFile(fileName + ".opt")) + MergeFile(fileName + ".opt"); + return status; } @@ -445,10 +450,6 @@ void OpenProject(std::string fileName) // merge the file MergeFile(fileName); - // merge the associated option file if there is one - if(!StatFile(fileName + ".opt")) - MergeFile(fileName + ".opt"); - CTX::instance()->lock = 0; #if defined(HAVE_FLTK) diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 5ae91f2751..2fc0566ad5 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -1991,9 +1991,6 @@ static void view_reload(int index) p->setChanged(true); FlGui::instance()->updateViews(); } - - if(!StatFile(p->getData()->getFileName() + ".opt")) - MergeFile(p->getData()->getFileName() + ".opt"); } } diff --git a/Fltk/pluginWindow.cpp b/Fltk/pluginWindow.cpp index 5f8e76fe74..cc2d757554 100644 --- a/Fltk/pluginWindow.cpp +++ b/Fltk/pluginWindow.cpp @@ -107,6 +107,8 @@ static void plugin_browser_cb(Fl_Widget *w, void *data) static void add_scripting(GMSH_PostPlugin *p, PView *view) { if(!FlGui::instance()->plugins->record->value()) return; + + std::string fileName; int oldIndex = -1; if(view){ for(int i = 0; i < p->getNbOptions(); i++){ @@ -115,9 +117,12 @@ static void add_scripting(GMSH_PostPlugin *p, PView *view) p->getOption(i)->def = view->getIndex(); } } + fileName = view->getData()->getFileName(); } + else + fileName = GModel::current()->getFileName(); - std::string fileName = GModel::current()->getFileName() + ".opt"; + fileName += + ".opt"; FILE *fp = fopen(fileName.c_str(), "a"); if(!fp){ Msg::Error("Could not open file '%s'", fileName.c_str()); -- GitLab