From 67315637f7e99f9374556ea165744daf3c9e46e3 Mon Sep 17 00:00:00 2001 From: Soham Sen Date: Fri, 2 Apr 2021 19:38:12 +0530 Subject: [PATCH 1/4] Autosave files asynchronously --- src/ui/mark.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/mark.cpp b/src/ui/mark.cpp index a22fc7f..4a1daae 100644 --- a/src/ui/mark.cpp +++ b/src/ui/mark.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -457,7 +458,9 @@ void marK::autoSave() if (m_autoSaveType == Serializer::OutputType::None) return; - Serializer::write(m_filepath, m_ui->containerWidget->savedObjects(), m_autoSaveType); + QtConcurrent::run( + Serializer::write, m_filepath, m_ui->containerWidget->savedObjects(), m_autoSaveType + ); } marK::~marK() -- GitLab From e6afb9b42486ac345d97af141cc8a79eff61ded9 Mon Sep 17 00:00:00 2001 From: Soham Sen Date: Wed, 7 Apr 2021 13:26:40 +0530 Subject: [PATCH 2/4] Show error msg if autosave fails --- src/ui/mark.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ui/mark.cpp b/src/ui/mark.cpp index 4a1daae..93766f3 100644 --- a/src/ui/mark.cpp +++ b/src/ui/mark.cpp @@ -38,6 +38,7 @@ #include #include +#include static QDir markTempDirectory() { @@ -458,9 +459,23 @@ void marK::autoSave() if (m_autoSaveType == Serializer::OutputType::None) return; - QtConcurrent::run( + auto *watcher = new QFutureWatcher(); + connect(watcher, &QFutureWatcher::finished, this, [watcher]() { + bool success = watcher->result(); + delete watcher; + + if (!success) { + QMessageBox msgBox; + msgBox.setText("failed to auto-save annotation"); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + } + }); + + QFuture future = QtConcurrent::run( Serializer::write, m_filepath, m_ui->containerWidget->savedObjects(), m_autoSaveType ); + watcher->setFuture(future); } marK::~marK() -- GitLab From 78bfde1626fa479482e80558b8c460b50a9a3789 Mon Sep 17 00:00:00 2001 From: Soham Sen Date: Thu, 8 Apr 2021 18:15:03 +0000 Subject: [PATCH 3/4] Applied suggestion fixing grammar --- src/ui/mark.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mark.cpp b/src/ui/mark.cpp index 93766f3..e8f908c 100644 --- a/src/ui/mark.cpp +++ b/src/ui/mark.cpp @@ -466,7 +466,7 @@ void marK::autoSave() if (!success) { QMessageBox msgBox; - msgBox.setText("failed to auto-save annotation"); + msgBox.setText("Failed to auto-save annotation."); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); } -- GitLab From ccc8dd3fad07e9007c19a52a8b47130bd2bbf2ca Mon Sep 17 00:00:00 2001 From: Soham Sen Date: Thu, 8 Apr 2021 20:28:31 +0000 Subject: [PATCH 4/4] Removed extra tab --- src/ui/mark.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mark.cpp b/src/ui/mark.cpp index e8f908c..366638a 100644 --- a/src/ui/mark.cpp +++ b/src/ui/mark.cpp @@ -473,7 +473,7 @@ void marK::autoSave() }); QFuture future = QtConcurrent::run( - Serializer::write, m_filepath, m_ui->containerWidget->savedObjects(), m_autoSaveType + Serializer::write, m_filepath, m_ui->containerWidget->savedObjects(), m_autoSaveType ); watcher->setFuture(future); } -- GitLab