Better undo/redo for Krita
Open, Needs TriagePublic


  1. Snapshot Docker.
    1. Users should be able to save the current state of document as a snapshot. Use KisDocument::clone() to obtain a (relatively) shallow copy of the document.
    2. The docker should display a list of snapshots (shallow copies) of the document, and allow users to replace the current document with any of the snapshots taken.
    3. A user manual should be written on how to use this docker. After finishing the docker, a tutorial video should be recorded.
  2. Copy-on-Write Vector Layers.
    1. Current implementations of vector layers:
      1. Data are stored using d-pointers that are not shared
      2. Subclasses’ d-pointers are inherited from those of the parent class
      3. Have at least two constructors for each class to prevent creating multiple data instances
        1. ChildClass() : ParentClass(new ChildClassPrivate(this))
        2. ChildClass(ChildClassPrivate * dd) : ParentClass(dd)
      4. All shapes are descended from KoShape, including KisShapeLayer itself
    2. Possible implementations:
      1. Similar implementation to the one in KisTile, which manually calls KisTileData::acquire() when an edit is needed.
      2. Qt’s implicit sharing, using the Qt class QSharedDataPointer. This class is reentrant (guaranteed to be safe when different threads access different instances). This is the preferred method. However, this is not thread-safe and may cause problems if the same instance is accessed from multiple threads. More work needs to be done to ensure thread-safety.
      3. C++11’s shared_ptr, as demonstrated by Sean Parent. However, in KDE guidelines, Qt libraries are preferred over std. This should be attempted only if QSharedDataPointer cannot work.


Week 1-4 (May 27 - June 23)
Write core code to replace the current document with another KisDocument
Unit test for replacing the current document with another KisDocument
This involves emitting signals to GUI
Probably begin writing the snapshot docker

Week 5 (June 24 - June 30)
Snapshot Docker
Write user manuals
Make a tutorial/demo video

Week 6 (July 1 - July 7)
Build a testing release, and collect feedback from the community
Possible questions:
Is snapshot taking helpful to your workflow?
Is it efficient?
Other features wanted?
Improve the docker using the feedback

Week 7-8 (July 8 - July 21)
Start working on Copy-on-Write vector layers
The re-written classes should have the same API as the old ones, where possible.
Start using implicit sharing for members of KoShapePrivate
What have been stored using pointers may be now stored using shallow copies, for example, QSharedPointer<KoShapeStrokeModel> stroke could be replaced with KoShapeStrokeModel stroke
Make api documents on how implicit-sharing works for these components, and possibly a “guideline” or example on how to use implicit sharing in other classes.

Week 9-10 (July 22 - August 4)
Implicit sharing for the KoShape hierarchy
According to the discussion above, I may need to replace Qt’s macro with code written by myself in all descendents
Write and run unit tests
Try to merge the changes into master

Week 11 (August 5 - August 11)
Write undo commands that switch between states to replace the original ones that stores actions

Week 12 + Remaining 1 day (August 12 - August 19)
Used for buffering

tusooaw created this task.Wed, May 8, 4:42 PM
tusooaw updated the task description. (Show Details)Wed, May 8, 4:45 PM