From 470eae8b92481f1ced578731b30047d405ec9c68 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Tue, 21 Nov 2023 09:26:57 +0100
Subject: [PATCH] pamhyr: Fix #20 study reload whene study is not saved on a
 file.

---
 src/View/MainWindow.py | 5 +++--
 src/config.py          | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 92a3e8f5..ebc2d1cb 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -139,8 +139,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
         self.trans = QTranslator(self)
         # self.ui.retranslateUi()
 
-        if self.conf.last_study != "" and not self.conf.close_correctly:
-            self.dialog_reopen_study()
+        if not self.conf.close_correctly:
+            if self.conf.last_study != "":
+                self.dialog_reopen_study()
 
         if _doc == "external":
             logger.info("doc: Internal documentation is not available...")
diff --git a/src/config.py b/src/config.py
index c2aca042..c8613a42 100644
--- a/src/config.py
+++ b/src/config.py
@@ -316,6 +316,9 @@ class Config(SQL):
         self.commit()
 
     def set_last_study(self, filename):
+        if filename is None:
+            return
+
         self.last_study = filename
         self.close_correctly = False
         self.execute(
-- 
GitLab