Skip to content

Commit

Permalink
Check if document is truly empty before creating new draft. Fixes iss…
Browse files Browse the repository at this point in the history
…ue #696
  • Loading branch information
mruiz42 committed Dec 18, 2021
1 parent 929f621 commit 4c44cba
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/documentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ DocumentManager::DocumentManager
if (modified
&& d->autoSaveEnabled
&& d->document->isNew()
&& (d->document->characterCount() > 0)) {
&& (!d->document->isEmpty())) {
d->createDraft();
}
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand All @@ -1023,4 +1019,5 @@ void DocumentManagerPrivate::createDraft()
saveFile();
}
}

}

0 comments on commit 4c44cba

Please sign in to comment.