Bug 425066 - Python Document.modified() flag is NOT set in edit operations.
Summary: Python Document.modified() flag is NOT set in edit operations.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Scripting (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Appimage Linux
: NOR minor
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-06 09:13 UTC by Aki
Modified: 2022-09-19 13:08 UTC (History)
1 user (show)

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 Aki 2020-08-06 09:13:14 UTC
SUMMARY:
Document modified flag is NOT set in edit operations.
Haven't tested all document edit methods.


STEPS TO REPRODUCE:

Krita -> Tools -> Scripts -> Scripter

```python
from krita import Krita

# before running
# open / save new document so that modified flag is false.

app = Krita.instance()
doc = app.activeDocument()

print(f"Krita version: {app.version()}")
print(f"before is_modified: {doc.modified()}")

doc.setDocumentInfo(doc.documentInfo() + "\n")
doc.setFramesPerSecond(int(doc.framesPerSecond() + 1))
doc.setFullClipRangeStartTime(doc.fullClipRangeStartTime() + 1)
doc.setFullClipRangeEndTime(doc.fullClipRangeEndTime() + 1)
doc.setFileName(doc.fileName() + ".ILBM")
doc.setName(doc.name()[::-1])

print(f"after is_modified: {doc.modified()}")
```

OBSERVED RESULT:
```
==== Warning: Script not saved! ====
Krita version: 4.3.1-alpha (git 4212182)
before is_modified: False
after is_modified: False
```

EXPECTED RESULT:
```
==== Warning: Script not saved! ====
Krita version: 4.3.1-alpha (git 4212182)
before is_modified: False
after is_modified: True
```

SOFTWARE/OS VERSIONS
Windows: -
macOS: -
Linux/KDE Plasma: Linux (x86_64) release 4.15.0-106-generic
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 5.12.9

ADDITIONAL INFORMATION

Affects:
  - saving of document (no changes to save)
  - close krita (save modified? confirmation)
Comment 1 Scott Petrovic 2020-08-10 13:23:00 UTC
I think the work here is going to be adding a few more areas that mark the document as modified. It looks like these areas do  not change the "isModified" status. This is python code, but we probably can update the C++ code to set the isModified flag when these things happen...

doc.setDocumentInfo(doc.documentInfo() + "\n")
doc.setFramesPerSecond(int(doc.framesPerSecond() + 1))
doc.setFullClipRangeStartTime(doc.fullClipRangeStartTime() + 1)
doc.setFullClipRangeEndTime(doc.fullClipRangeEndTime() + 1)
doc.setFileName(doc.fileName() + ".ILBM")
doc.setName(doc.name()[::-1])
Comment 2 Halla Rempt 2022-09-19 12:52:43 UTC
Git commit 197cbccaf49a9f1e834b268de520e0b178f54045 by Halla Rempt.
Committed on 19/09/2022 at 12:52.
Pushed by rempt into branch 'master'.

Add Document::setModified(bool) to the scripting api

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

https://invent.kde.org/graphics/krita/commit/197cbccaf49a9f1e834b268de520e0b178f54045
Comment 3 Halla Rempt 2022-09-19 13:08:11 UTC
Git commit dae801931bb59d6fcf060bda71e84389c5a3dc76 by Halla Rempt.
Committed on 19/09/2022 at 13:07.
Pushed by rempt into branch 'krita/5.1'.

Add Document::setModified(bool) to the scripting api
(cherry picked from commit 78aedaf4b49bbfdda4473b187f5026d4de43908b)

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

https://invent.kde.org/graphics/krita/commit/dae801931bb59d6fcf060bda71e84389c5a3dc76