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."""