diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 5a25143896ce50d28fc532f3bebd3fb4ac2d7da0..f5b015fa84ffc81d09605181f6471f355f972007 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -348,10 +348,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): def closeEvent(self, event): if not self._close_question: if self._study is not None and not self._study.is_saved: - if self.dialog_close(cancel=False): + if self.dialog_close(): # PAMHYR is close correctly (no crash) self.conf.set_close_correctly() super(ApplicationWindow, self).closeEvent(event) + else: + event.ignore() else: super(ApplicationWindow, self).closeEvent(event) @@ -531,7 +533,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): self.update() def close_model(self): - if not self.dialog_close(cancel=True): + if not self.dialog_close(): return self._study = None @@ -833,21 +835,19 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): return file - def dialog_close(self, cancel=True): + def dialog_close(self): dlg = QMessageBox(self) dlg.setWindowTitle(self._trad["mb_close_title"]) dlg.setText(self._trad["mb_close_msg"]) opt = QMessageBox.Save | QMessageBox.Close - if cancel: - opt |= QMessageBox.Cancel + opt |= QMessageBox.Cancel dlg.setStandardButtons(opt) dlg.setIcon(QMessageBox.Warning) dlg.button(QMessageBox.Save).setText(self._trad["Save"]) dlg.button(QMessageBox.Close).setText(self._trad["Close"]) - if cancel: - dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"]) + dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"]) res = dlg.exec()