cmu-phil / tetrad

Repository for the Tetrad Project, www.phil.cmu.edu/tetrad.
GNU General Public License v2.0
404 stars 111 forks source link

Failed opening a tetrad file saved with same version 7.6.1-0 #1712

Closed PSueri closed 8 months ago

PSueri commented 10 months ago

image

Hello, I saved a session with Tetrad 7.6.1-0 today, but i can't load it again.

My java version is 21.0.1

PSueri commented 10 months ago

I have also previously saved a test session and can upload it, even though it is in the same folder.

jdramsey commented 10 months ago

Sorry, I was away from this list for a few days. This is actually a deep problem, and I've been thinking of a way around it. What happens, at least on a Mac, is that people use the control-Q keystroke to quit the program after saving their session. So far as I know Java has no way to detect that a user has done this, and the saving can get caught short, which results in a corrupted file.

You know, it's been a few years since I last checked on this; maybe someone has devised a way to detect this in the interim; I will check.

In the meantime, the way to guard against it is always to use control-Q instead of command-Q to quit the program on a Mac. Or select Exit from the File menu (probably the safest).

I'l ponder this.

If you're using Windows, then I don't yet know what the problem might be.

jdramsey commented 10 months ago

Actually I just asked ChatGpt; it seems Java has added the following option:

public class MyApp { public static void main(String[] args) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { System.out.println("Shutdown hook called. Application is quitting."); // Perform cleanup or other tasks here. }));

    // Rest of your application code
}

}

I'll try it. You know, another thing I've tried to do (Draconian I know) is to completely rethink the Tetrad applications using JavaFx. I actually spend about a month on this; here's my solution so far:

https://github.com/cmu-phil/tetrad-fx

Unfortunately, despite much asking, I haven't gotten any feedback on this project that would suggest I continue developing it :-( Everyone is used to the usual Tetrad app. So I'm putting my energy back into trying to fix the problems with that. But the JavaFx version completely solves this particular problem in a rather helpful way by storing all files in a human-readable format on the user's hard drive instead of using binary serialization, so there's no fear of ever losing anything. I did think it was a good idea; maybe at some point I can convince others of that.

jdramsey commented 9 months ago

I just fixed this in my branch; we're going to publish it in a few days. I added the shutdown hook I mentioned. Now, when you type control-Q on a Mac (or anything similar on another platform that's handled by the OS), you will get a warning message.

We have a few more fixed to get in, but then we will publish 7.6.2.

jdramsey commented 8 months ago

This looks like a dead issue and it should be fixed going into the future, so closing.