Bug 409395 - If Krita is closed while saving, the document is not saved
Summary: If Krita is closed while saving, the document is not saved
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: git master (please specify the git hash!)
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-02 05:29 UTC by Anna Medonosova
Modified: 2019-07-30 08:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anna Medonosova 2019-07-02 05:29:48 UTC
If the user closes Krita while saving is in progress, there is a chance of Krita closing before the saving process is finished, thus leading to data loss.

1, user makes a modification to the document
2, user initiates save; KisMainWindow::saveDocument() locks itself, so it can not be entered twice
3, before the saving is finished, user generates an event to close Krita; this event gets caught by one of QApplication::processEvents() function (several occurences during save)
4, processEvents() reacts to close by triggering closeEvent(), which calls KisView::queryClose()
5, in queryClose(), the code checks if document is still flagged as modified, which it is; KisMainWindow::saveDocument() is called
6, KisMainWindow::saveDocument() is locked, because saving is already in progress and so returns false
7, Krita closes; the document was not saved
Comment 1 Anna Medonosova 2019-07-29 17:27:38 UTC
Git commit b9671ace4fe47e27ebc76a4b584545d1751e5d96 by Anna Medonosova.
Committed on 29/07/2019 at 17:27.
Pushed by amedonosova into branch 'master'.

Disallow closing Krita while it initiates saving

Do not close Krita while KisMainWindow has the savingEntryMutex locked
(while the background saving process is being initiated). After the
background saving job is initiated, KisDocument blocks closing while it
saves itself.

M  +11   -0    libs/ui/KisMainWindow.cpp

https://invent.kde.org/kde/krita/commit/b9671ace4fe47e27ebc76a4b584545d1751e5d96
Comment 2 Anna Medonosova 2019-07-29 17:27:38 UTC
Git commit d3c5a3f613dd50342af5853d331a1e93a24eb9df by Anna Medonosova.
Committed on 29/07/2019 at 17:27.
Pushed by amedonosova into branch 'master'.

Do not process user input during saving operations

Fixes a race condition in the saving process, which is caused by
processing user input events in multiple places during save.

M  +2    -2    libs/ui/KisDocument.cpp
M  +1    -1    libs/ui/dialogs/kis_delayed_save_dialog.cpp
M  +3    -3    libs/ui/kis_async_action_feedback.cpp

https://invent.kde.org/kde/krita/commit/d3c5a3f613dd50342af5853d331a1e93a24eb9df
Comment 3 Halla Rempt 2019-07-30 08:06:31 UTC
Git commit 5ea0d79445b4fff0a6507d7a31d2a30d48462753 by Boudewijn Rempt, on behalf of Anna Medonosova.
Committed on 30/07/2019 at 08:02.
Pushed by rempt into branch 'krita/4.2'.

Disallow closing Krita while it initiates saving

Do not close Krita while KisMainWindow has the savingEntryMutex locked
(while the background saving process is being initiated). After the
background saving job is initiated, KisDocument blocks closing while it
saves itself.

M  +11   -0    libs/ui/KisMainWindow.cpp

https://invent.kde.org/kde/krita/commit/5ea0d79445b4fff0a6507d7a31d2a30d48462753
Comment 4 Halla Rempt 2019-07-30 08:06:31 UTC
Git commit daf8def526223d5a717aa4152a83fbf477e23a14 by Boudewijn Rempt, on behalf of Anna Medonosova.
Committed on 30/07/2019 at 08:02.
Pushed by rempt into branch 'krita/4.2'.

Do not process user input during saving operations

Fixes a race condition in the saving process, which is caused by
processing user input events in multiple places during save.

M  +2    -2    libs/ui/KisDocument.cpp
M  +1    -1    libs/ui/dialogs/kis_delayed_save_dialog.cpp
M  +3    -3    libs/ui/kis_async_action_feedback.cpp

https://invent.kde.org/kde/krita/commit/daf8def526223d5a717aa4152a83fbf477e23a14