diff --git a/Common/Gmsh.cpp b/Common/Gmsh.cpp index 71e2e678d56e34b4d587743a5418a14b47014886..c5d3892fdb85203a94fd30864976dd1a2dad765c 100644 --- a/Common/Gmsh.cpp +++ b/Common/Gmsh.cpp @@ -210,14 +210,16 @@ int GmshFLTK(int argc, char **argv) FlGui::instance()->check(); // open project file and merge all other input files - OpenProject(GModel::current()->getFileName()); - for(unsigned int i = 1; i < CTX::instance()->files.size(); i++){ - if(CTX::instance()->files[i] == "-new"){ - GModel::current()->setVisibility(0); - new GModel(); + if(!FlGui::instance()->getOpenedThroughMacFinder()){ + OpenProject(GModel::current()->getFileName()); + for(unsigned int i = 1; i < CTX::instance()->files.size(); i++){ + if(CTX::instance()->files[i] == "-new"){ + GModel::current()->setVisibility(0); + new GModel(); + } + else + MergeFile(CTX::instance()->files[i]); } - else - MergeFile(CTX::instance()->files[i]); } if(CTX::instance()->post.combineTime){ diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp index 5301cfa503737069a28d6724eec18fe3a3a1000f..e2106ec10672798412eaa59cfc259c8a276cbb46 100644 --- a/Common/OpenFile.cpp +++ b/Common/OpenFile.cpp @@ -504,14 +504,8 @@ void OpenProject(std::string fileName) void OpenProjectMacFinder(const char *fileName) { #if defined(HAVE_FLTK) - static int first = 1; - if(first || !FlGui::available()){ - // just copy the filename: it will be opened when the GUI is ready - // in main() - GModel::current()->setFileName(fileName); - first = 0; - } - else{ + if(FlGui::available()){ + FlGui::instance()->setOpenedThroughMacFinder(true); OpenProject(fileName); drawContext::global()->draw(); } diff --git a/Fltk/FlGui.cpp b/Fltk/FlGui.cpp index 07f23b16dee6313ed827ebc2d54aa4ffc64d24eb..abd35b0f0b0dd31e6ed7ab72d133d4ff60828fc4 100644 --- a/Fltk/FlGui.cpp +++ b/Fltk/FlGui.cpp @@ -174,7 +174,7 @@ static int globalShortcut(int event) return FlGui::instance()->testGlobalShortcuts(event); } -FlGui::FlGui(int argc, char **argv) +FlGui::FlGui(int argc, char **argv) : _openedThroughMacFinder(false) { // set X display if(CTX::instance()->display.size()) diff --git a/Fltk/FlGui.h b/Fltk/FlGui.h index 693329bdd77561eb4143c93fd330642c0d963c3d..b79330756304d47e259158f3fabc4c589c9b292b 100644 --- a/Fltk/FlGui.h +++ b/Fltk/FlGui.h @@ -43,6 +43,7 @@ class MElement; class FlGui{ private: static FlGui *_instance; + bool _openedThroughMacFinder; public: std::vector<GVertex*> selectedVertices; std::vector<GEdge*> selectedEdges; @@ -80,6 +81,9 @@ class FlGui{ static void wait(){ Fl::wait(); } // wait (at most time seconds) for any events, then process them static void wait(double time){ Fl::wait(time); } + // is a file opened through the Mac Finder? + void setOpenedThroughMacFinder(bool val){ _openedThroughMacFinder = val; } + bool getOpenedThroughMacFinder(){ return _openedThroughMacFinder; } // test application-level keyboard shortcuts int testGlobalShortcuts(int event); // test the arrow shortcuts (not in the application-level shortcuts)