Bug 397320 - [API] No obvious way to probe the dirty/modified flag of the active document
Summary: [API] No obvious way to probe the dirty/modified flag of the active document
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-09 16:49 UTC by Neviril
Modified: 2018-09-07 14:25 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neviril 2018-08-09 16:49:38 UTC
I've been advised to open a wishbug for this.

I am in the process of writing simple Python plugin. In short, I have a docker with two buttons for iterating back/forth through files from a given directory, replacing the open document with a new one. This operation implies that if the active document has unsaved changes they will be irreversibly lost. A possibility could be to always save the open file before switching it, but in this way iterating through the existing file list becomes much slower. Unnecessarily modifying files is generally not desirable on reliability and performance grounds.

Therefore it would be useful to check out in advance if the active document has any unsaved changes.

Oddly enough, I couldn't find any obviously named class member in the Krita Python API documentation for checking the modified/dirty status of a document, like for example something like isDirty(), or isModified(), etc. According to one developer on the official #Krita IRC channel, this doesn't seem to be currently possible.

An alternative could be making Document::save() operate in a way that it doesn't actually save the document if no changes are detected, but it could be a potentially breaking change, and being able to save the document despite not having actually modified it could potentially have uses for some people.
Comment 1 Halla Rempt 2018-08-14 11:50:46 UTC
Git commit 670f725984714ac9b3f0f8987b4319a5813c007a by Boudewijn Rempt.
Committed on 14/08/2018 at 11:50.
Pushed by rempt into branch 'master'.

Add modified() getter to the Document class

M  +6    -0    libs/libkis/Document.cpp
M  +5    -0    libs/libkis/Document.h
M  +1    -0    plugins/extensions/pykrita/sip/krita/Document.sip

https://commits.kde.org/krita/670f725984714ac9b3f0f8987b4319a5813c007a
Comment 2 Halla Rempt 2018-09-07 14:25:30 UTC
Git commit 3c0e517b1cb0d6b5c00defbe9a843c28a8153976 by Boudewijn Rempt.
Committed on 07/09/2018 at 12:37.
Pushed by rempt into branch 'krita/4.1'.

Add modified() getter to the Document class

M  +6    -0    libs/libkis/Document.cpp
M  +5    -0    libs/libkis/Document.h
M  +1    -0    plugins/extensions/pykrita/sip/krita/Document.sip

https://commits.kde.org/krita/3c0e517b1cb0d6b5c00defbe9a843c28a8153976