undo: Clear undo stack on file close

The undo stack is only relevant to the dives that were loaded at the
time the command was executed. If a file is closed, by specifically
closing it or opening another file, then the undo commands will
reference dives that aren't available anymore. Clearing the undo stack
ensures that we don't crash or accidentally do some undefined
modifications to the currently open file.

Signed-off-by: Michael Andreen <michael@andreen.dev>
This commit is contained in:
Michael Andreen 2022-04-02 17:39:38 +02:00 committed by Dirk Hohndel
parent ada4632ff1
commit be2bdb8650
3 changed files with 3 additions and 1 deletions

View file

@ -1,4 +1,5 @@
- Desktop: Allow more than one media file to be imported from web
- undo: Clear undo stack when the current file is closed
---
* Always add new entries at the very top of this file above other existing entries and this note.
* Use this layout for new entries: `[Area]: [Details about the change] [reference thread / issue]`

View file

@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include "command.h"
#include "command_base.h"
#include "core/globals.h"
#include "core/qthelper.h" // for updateWindowTitle()
@ -18,6 +19,7 @@ void init()
{
undoStack = make_global<QUndoStack>();
QObject::connect(undoStack, &QUndoStack::cleanChanged, &updateWindowTitle);
QObject::connect(&diveListNotifier, &DiveListNotifier::dataReset, &Command::clear);
changesCallback = &changesMade;
}

View file

@ -513,7 +513,6 @@ void MainWindow::closeCurrentFile()
if (!existing_filename)
setTitle();
disableShortcuts();
Command::setClean();
}
void MainWindow::updateCloudOnlineStatus()