Skip to content

Conversation

@ericksson
Copy link
Contributor

Fixes https://bugs.launchpad.net/pinta/+bug/1435226

The implementation was committing tool state first, which can finalize editable shapes and push a history item, marking the document dirty right before closing.

This was changed so that:

  • If the document is not dirty, close it immediately without committing
  • Only commit pending changes when the document is dirty and we might prompt to save

This prevents creating a last-second history item that triggers the prompt after a successful save.

Tested locally the fact that the bug was still reproducing before the change and does not reproduce after this. The image is still correctly saved after using any tool, saving and closing the app.

@cameronwhite
Copy link
Member

Thanks for investigating this!
I agree we shouldn't be committing before checking the dirty state, since after saving the tool will have rolled back any history items added while committing, and the state will be marked as clean

document.Workspace.History.SetClean ();

I'm thinking we should also go further though and remove the tools.Commit() entirely here - this already happens in the actual code for saving the file so it seems unnecessary to do it up front.

This would avoid adding the "Finalize" history item if the user decides to cancel closing the document, for example:

Screen.Recording.2025-08-09.at.10.19.50.AM.mp4

…one that and this prevents adding an additional Finalize history item
@ericksson ericksson force-pushed the fix-image-dirty-state-on-close branch from 573dcb7 to 9fe48ac Compare August 9, 2025 23:32
@ericksson
Copy link
Contributor Author

Thank you! I didn't catch that detail. I wonder why this call was added in the CloseDocumentationAction class to begin with. Maybe as an extra precaution in case some tool doesn't call Commit.

With the call to tools.Commit () removed entirely everything still seems to work, but the Finalize state is still in the History when cancelling that save dialogue. I proposed a fix in 87c57b6, though there maybe could be a better way to handle that, but I couldn't figure out anything else.

@ericksson
Copy link
Contributor Author

While trying to replicate the example in your screen recording, I noticed that upon canceling or saving the current tab, the shape is Finalized and added to the other tab that is already opened. This is a bug that seems like it was there before the changes in this PR, but it seems like a pretty bad one. I proposed a fix in e8a281e

This fix and the fix for Finalize above can probably be split into a separate PR if needed.

So far, these are the changes in this PR:

  • No Tool commit on close document prompt.
  • Suppressed commit when switching active document during tab close.
  • Ignored transient tab selection changes during close.
  • Shape finalization and shape drawing and handles prevented on wrong tab.

@cameronwhite
Copy link
Member

It looks like there are some merge conflicts, so I suspect your branch is behind the latest master branch?

I wasn't able to reproduce the Finalize state is still in the History when cancelling that save dialogue issue, but perhaps I'm missing some steps or it was fixed by some other changes

Would you also maybe be able to record a screen grab of the other issue with shape is Finalized and added to the other tab? e.g. does the other document need to also have shapes in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants