Skip to content

Commit c27e586

Browse files
committed
fixed #202: "Cancel" button of editor close confirmation dialog is broken
It was actually equivalent to the "discard" button, possibly leading to data loss. This was a regression in 0.32.
1 parent cdb6c22 commit c27e586

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/source/changes/version_0_32_1.rst.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
Fixes
44
^^^^^
55

6+
* fixed the "Cancel" button of the confirmation dialog when trying to quit the editor with unsaved modifications.
7+
It was equivalent to discard, potentially leading to data loss.
8+
69
* fixed (harmless) error messages appearing when trying to display any variable via the console when using
710
matplotlib 3.1+

larray_editor/editor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,13 +773,14 @@ def _ask_to_save_if_unsaved_modifications(self):
773773
return True
774774

775775
def closeEvent(self, event):
776+
# as per the example in the Qt doc (https://doc.qt.io/qt-5/qwidget.html#closeEvent), we should *NOT* call
777+
# the closeEvent() method of the superclass in this case because all it does is "event.accept()"
778+
# unconditionally which results in the application being closed regardless of what the user chooses (see #202).
776779
if self._ask_to_save_if_unsaved_modifications():
780+
self.save_widgets_state_and_geometry()
777781
event.accept()
778782
else:
779783
event.ignore()
780-
self.save_widgets_state_and_geometry()
781-
AbstractEditor.closeEvent(self, event)
782-
783784

784785
#########################################
785786
# FILE MENU #

0 commit comments

Comments
 (0)