laccore / coretools

PSICAT: Initial Core Description software for Windows and macOS/OSX
https://cse.umn.edu/csd/psicat
Apache License 2.0
14 stars 0 forks source link

Unsaved edits to a closed section are retained on open #10

Closed sorghumking closed 1 month ago

sorghumking commented 4 months ago
  1. Open a PSICAT project and open a section diagram.
  2. Edit the section e.g. add a Lithology interval.
  3. Close the section and choose "No" when prompted to save changes.
  4. Open the section: your "unsaved" edits are still there!

Yikes. The good news is that closing the project and reopening reverts to the correct, last-saved data in the underlying XML data file.

Already found the problem, which is described below for future reference:

When opening a section, we do a "preflight" open of the section to count its Section models so we can set the diagram to read-only if there are 2+ Sections. That section is then opened again in the DiagramController's open() method. This makes the reference count 2 for that section/container in AbstractProject. When the section is closed, the decremented reference count is 1 instead of 0, so the container is never set to null (see AbstractProject.closeContainer()). Thus the modified-but-unsaved container data is retained, and shows up when you open the section again.