From 4c44cba741d4c1982f82ff98e779c5148f8eb606 Mon Sep 17 00:00:00 2001 From: Michael Ruiz Date: Sat, 18 Dec 2021 06:20:06 -0800 Subject: [PATCH] Check if document is truly empty before creating new draft. Fixes issue #696 --- src/documentmanager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/documentmanager.cpp b/src/documentmanager.cpp index 5b2551d32..8feb61cef 100644 --- a/src/documentmanager.cpp +++ b/src/documentmanager.cpp @@ -231,7 +231,7 @@ DocumentManager::DocumentManager if (modified && d->autoSaveEnabled && d->document->isNew() - && (d->document->characterCount() > 0)) { + && (!d->document->isEmpty())) { d->createDraft(); } } @@ -281,7 +281,7 @@ void DocumentManager::setAutoSaveEnabled(bool enabled) if (enabled) { if (d->document->isNew() - && (d->document->characterCount() > 0) + && (!d->document->isEmpty()) && d->document->isModified()) { d->createDraft(); } @@ -1005,10 +1005,6 @@ bool DocumentManagerPrivate::documentIsDraft() void DocumentManagerPrivate::createDraft() { - // TODO: This is a workaround to prevent extra empty drafts from being created when user closes application #696 - if (document->isEmpty()) { - return; - } if (document->isNew()) { int i = 1; QString draftPath; @@ -1023,4 +1019,5 @@ void DocumentManagerPrivate::createDraft() saveFile(); } } + }