From f76601ee30623c7c42747089b240fb6ea008d67c Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 8 Apr 2017 14:53:44 +0200
Subject: [PATCH] create default file in homedir if no PWD

---
 Common/OpenFile.cpp        | 3 ++-
 Geo/GeoStringInterface.cpp | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 16452e4e46..bae00a890c 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -654,7 +654,8 @@ void ClearProject()
   Msg::Info("Done clearing all models and views");
 
   new GModel();
-  GModel::current()->setFileName(CTX::instance()->defaultFileName);
+  std::string base = (getenv("PWD") ? "" : CTX::instance()->homeDir);
+  GModel::current()->setFileName(base + CTX::instance()->defaultFileName);
   GModel::current()->setName("");
 #if defined(HAVE_FLTK)
   if(FlGui::available()){
diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp
index d74c00c544..8f10810b02 100644
--- a/Geo/GeoStringInterface.cpp
+++ b/Geo/GeoStringInterface.cpp
@@ -27,8 +27,8 @@ void add_infile(const std::string &text, const std::string &fileNameOrEmpty)
 {
   std::string fileName = fileNameOrEmpty;
   if(fileName.empty()){
-    fileName = CTX::instance()->defaultFileName;
-    GModel::current()->setFileName(fileName);
+    std::string base = (getenv("PWD") ? "" : CTX::instance()->homeDir);
+    GModel::current()->setFileName(base + CTX::instance()->defaultFileName);
     GModel::current()->setName("");
   }
 
-- 
GitLab