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.
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
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