From 36ad9562eb1f04dd9e50153233ac810eca08d4a8 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Wed, 31 Jan 2024 09:23:50 +0100
Subject: [PATCH] MainWindow: Fix save as function.

---
 src/View/MainWindow.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 2a86b85c..adc3933d 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -454,9 +454,21 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
             "", "Pamhyr(*.pamhyr)"
         )
 
-        if file_name.rsplit(".", 1)[-1] == ".pamhyr":
+        logger.debug(f"Save study as : {repr(file_name)}")
+        if file_name == "":
+            return
+
+        if file_name.rsplit(".", 1)[-1] == "pamhyr":
+            logger.debug(
+                "Pamhyr extention is present : " +
+                f"{repr(file_name)}"
+            )
             self._study.filename = file_name
         else:
+            logger.debug(
+                "Pamhyr extention is not present : " +
+                f"{repr(file_name + '.pamhyr')}"
+            )
             self._study.filename = file_name + ".pamhyr"
 
         sql_request_count = self._study.sql_save_request_count()
-- 
GitLab