From 3b6b9951ae0595c21dc35d95126e644babbfbc2d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 16 Nov 2019 22:00:25 +0100 Subject: [PATCH] undo: clear undo-stack when clearing dive data When the dive data is cleared, all pointers in the undo-stack become stale. Desktop explicitly called Command::clear() in that case, but mobile doesn't. Thus, move the clear() call into DiveTripModelBase::clear() Signed-off-by: Berthold Stoeger --- desktop-widgets/mainwindow.cpp | 2 -- qt-models/divetripmodel.cpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 9d2b31136..d995c7a36 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -547,7 +547,6 @@ void MainWindow::on_actionCloudstorageopen_triggered() if (!parse_file(fileNamePtr.data(), &dive_table, &trip_table, &dive_site_table)) setCurrentFile(fileNamePtr.data()); process_loaded_dives(); - Command::clear(); hideProgressBar(); refreshDisplay(); } @@ -1695,7 +1694,6 @@ void MainWindow::loadFiles(const QStringList fileNames) hideProgressBar(); updateRecentFiles(); process_loaded_dives(); - Command::clear(); refreshDisplay(); diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 6c1a7218a..a9fd3490b 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -467,6 +467,7 @@ void DiveTripModelBase::initSelection() void DiveTripModelBase::clear() { + Command::clear(); // If we clear the dive list, all undo-information becomes stalte. beginResetModel(); clear_dive_file_data(); clearData();