"Save before exit?" always shows, even right after save

4.13.0-2022-02-07, although this has been happening for some time.

If I save, then try to exit, I always get the “Some data have been modified. Do you want to save them before exit?”

Is there a way to figure out what nodes Slicer thinks have been modified since last save?

2 Likes

Good catch! There was a bug in the logic that marks the scene as saved (introduced during recent improvement of scene save error handling). I’ll fix the issue and also include a code snippet that lists modified nodes since the last save.

1 Like

I think you can see what nodes it thinks have been modified since last save by opening the save dialog and the items that are unchecked are the things that haven’t been modified since last save. Here I saved everything and then reopened the save dialog (hence unchecked items) and noticed the mrml scene was still checked. So maybe something about the mrml scene is then reason for the continued alert of still unsaved data.

image

Yeah, it would always say just the MRML file had been modified. I was more curious if a node saved in the MRML was getting marked as modified.

1 Like

Awesome! Sounds great, thanks.

Saving of scene or data is offered on application exit if either

  • any nodes in the scene were modified (this logic got fixed today), or
  • bulk data in any storable node is modified.

From tomorrow in Slicer Preview Release you can get the lists of these modified nodes like this:

# Modified nodes that are stored in the scene
nodesModifiedInScene = vtk.vtkCollection()
slicer.mrmlScene.GetModifiedSinceRead(nodesModifiedInScene)
for nodeIndex in range(nodesModifiedInScene.GetNumberOfItems()):
    print(nodesModifiedInScene.GetItemAsObject(nodeIndex).GetID())

# Nodes that contain modified bulk data (stored in files)
modifiedStorableNodes = vtk.vtkCollection()
slicer.mrmlScene.GetStorableNodesModifiedSinceRead(modifiedStorableNodes)
for nodeIndex in range(modifiedStorableNodes.GetNumberOfItems()):
    print(modifiedStorableNodes.GetItemAsObject(nodeIndex).GetID())
1 Like