After editing an image multiple times (e.g. rotate) and then undoing,
the thumbnail displays a previous edit state between the undos.
This is caused by connecting to `QUndoStack` signal `indexChanged`
which emits before some undo operations are finished and the new
thumbnail is created too early.
This patch emits the `modified`/`saved` signals for a document only
after the undo image operation is finished. It also solves the problem
displaying a wrong thumbnail in another mode after undoing all edits.
Depends on D11714
BUG: 356998