From 50663c6210f176edafd0ee0a5edb4f95652ea1ba Mon Sep 17 00:00:00 2001 From: Fabien Roger Date: Wed, 8 Dec 2021 23:10:46 +0100 Subject: [PATCH] Fix Save As bug --- opencodeblocks/graphics/window.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/opencodeblocks/graphics/window.py b/opencodeblocks/graphics/window.py index e5fb673c..8e4a84ca 100644 --- a/opencodeblocks/graphics/window.py +++ b/opencodeblocks/graphics/window.py @@ -325,10 +325,7 @@ def onFileSave(self) -> bool: if current_window is not None: if current_window.savepath is None: return self.onFileSaveAs() - current_window.save() - self.statusbar.showMessage( - f"Successfully saved ipygraph at {current_window.savepath}", 2000 - ) + self.saveWindow(current_window) return True def onFileSaveAs(self) -> bool: @@ -344,10 +341,19 @@ def onFileSaveAs(self) -> bool: if filename == "": return False current_window.savepath = filename - self.onFileSave() + + # Note : the current_window is the activeMdiChild before the QFileDialog pops up + self.saveWindow(current_window) return True return False + def saveWindow(self, window: OCBWidget): + """Save the given window""" + window.save() + self.statusbar.showMessage( + f"Successfully saved ipygraph at {window.savepath}", 2000 + ) + @staticmethod def is_not_editing(current_window: OCBWidget): """True if current_window exists and is not in editing mode."""