From c51098e2cfe314b311a613d10dfaf17d1bcefbf7 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Wed, 16 Dec 2015 21:29:09 +0100 Subject: [PATCH] Flush temporary file before opening attachment. Closes #390 --- src/gui/entry/EditEntryWidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index beeda2ab8..cd4d51ce4 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -671,6 +671,14 @@ void EditEntryWidget::openAttachment(const QModelIndex& index) return; } + if (!file->flush()) { + MessageBox::warning(this, tr("Error"), + tr("Unable to save the attachment:\n").append(file->errorString())); + return; + } + + file->close(); + QDesktopServices::openUrl(QUrl::fromLocalFile(file->fileName())); }