summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-04 23:47:31 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-04 16:09:57 -0700
commita6567a0070873cd41a77d8a7d1e26558b9933a36 (patch)
treee2288be7f612fb4addb1772eb58a6623eff543ad /mobile-widgets
parent1f180552c9a5e901c3994f030f15d7cf6477305b (diff)
downloadsubsurface-a6567a0070873cd41a77d8a7d1e26558b9933a36.tar.gz
mobile/undo: consider undo-stack when checking for unsaved changes
In analogy to desktop, also consider the state of the undo-stack when testing for unsaved changes. This prevents us from missing changes. This adds duplicate code, which will be unified in the near future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index eca75b678..ea2e3321b 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -170,6 +170,14 @@ void QMLManager::usbRescan()
extern void (*uiNotificationCallback)(QString);
+// Currently we have two markers for unsaved changes:
+// 1) unsaved_changes() returns true for non-undoable changes.
+// 2) Command::isClean() returns false for undoable changes.
+static bool unsavedChanges()
+{
+ return unsaved_changes() || !Command::isClean();
+}
+
QMLManager::QMLManager() : m_locationServiceEnabled(false),
m_verboseEnabled(false),
m_diveListProcessing(false),
@@ -310,7 +318,7 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state)
}
stateText.prepend("AppState changed to ");
stateText.append(" with ");
- stateText.append((unsaved_changes() ? QLatin1String("") : QLatin1String("no ")) + QLatin1String("unsaved changes"));
+ stateText.append((unsavedChanges() ? QLatin1String("") : QLatin1String("no ")) + QLatin1String("unsaved changes"));
appendTextToLog(stateText);
if (state == Qt::ApplicationActive && !m_initialized) {
@@ -318,7 +326,7 @@ void QMLManager::applicationStateChanged(Qt::ApplicationState state)
finishSetup();
appInitialized();
}
- if (state == Qt::ApplicationInactive && unsaved_changes()) {
+ if (state == Qt::ApplicationInactive && unsavedChanges()) {
// saveChangesCloud ensures that we don't have two conflicting saves going on
appendTextToLog("trying to save data as user switched away from app");
saveChangesCloud(false);
@@ -1307,7 +1315,7 @@ void QMLManager::openNoCloudRepo()
void QMLManager::saveChangesLocal()
{
- if (unsaved_changes()) {
+ if (unsavedChanges()) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) {
if (empty_string(existing_filename)) {
QString filename = nocloud_localstorage();
@@ -1340,7 +1348,7 @@ void QMLManager::saveChangesLocal()
void QMLManager::saveChangesCloud(bool forceRemoteSync)
{
- if (!unsaved_changes() && !forceRemoteSync) {
+ if (!unsavedChanges() && !forceRemoteSync) {
appendTextToLog("asked to save changes but no unsaved changes");
return;
}
@@ -1726,7 +1734,7 @@ void QMLManager::screenChanged(QScreen *screen)
void QMLManager::quit()
{
- if (unsaved_changes())
+ if (unsavedChanges())
saveChangesCloud(false);
QApplication::quit();
}