Running my app on Windows, when I close the last open window the app quits as it should. I have a debug log entry in the App.Closing event that fires and then my app cleanup begins.
On Linux, after closing the last window, the app appears to quit but my debug log does not show the App.Closing event firing. Also, when I look at the Linux System Monitor, it lists the app and shows open application files associated with it.
I can kill the app in the debugger and then the System Manager no longer lists the app.
The App.AllowAutoQuit set to true even though this is supposed to be a default for Linux.
I am using the Xojo2025r2.1 on the Mac. My Linux version is Mint 22.1 Cinnamon. Am I misinformed, or should the app quit gracefully when the last open window is closed?
If I put System.DebugLog("Closing") in App.Closing, I don’t see the message either but my app does quit. I believe System.DebugLog is asynchronous and the app has exited before it has a chance to handle the log message. Maybe try putting Break in App.Closing and see if that is triggered by closing the last window.
I did put the break on the on the first line if the App.Closing event (which happens to be the debug line) but it did not break there.
Even if it did break there, it would not explain why none of the cleanup was being executed. In my App.Close event, I’m closing my database and writing to my prefs file. None of that is happening.
Yeah, seems like it isn’t automatically quitting. I’m not sure. I can’t reproduce it in a trivial project.
If it isn’t quitting, maybe you can close all the windows and then pause in the debugger to examine to make sure there aren’t any windows and AllowAutoQuit is true.
As a workaround/test you could try implementing your own auto quit by adding a method to App:
Public Sub ManualAutoQuit()
#If TargetLinux
If App.WindowCount = 0 Then Quit
#EndIf
End Sub
And then call App.ManualAutoQuit in the Closing event of every window.
I tried this with one of the simple Drag and Drop examples that come with Xojo. I placed the System.Debug statement in the Closing event of the App and it never showed up when I closed the only open window in the app.
For a simple project like this, it is no big deal. The app will quit when the last window is closed. I can see that in the System Manager.
In my project, I rely on the Closing event to close my database and do other clean ups and that never happens. The app does not quit at all as can be seen in the System Manager. I am a Linux noob but I’m guessing that Linux sees there are open files and prevents the quit. Unfortunately, with no open windows, I can’t use the File menu to force the quit.
The solution provided by Travis works fine for my purposes. I will file a bug report.
I agree this should work if that is all I am doing, but I’m also writing out to my preferences file and a few other unrelated things.
The whole point of having the App.Closing event is to allow this kind of cleanup regardless of how the app is quitting. Both Windows and Linux default to the AllowAutoQuit setting to be true. The bug here is that the App.Closing event is not being called in the case of Linux. Or at least the version of Linux I am using. I feel safe using the workaround Travis suggested.
@Stefan_von_Allmen You didn’t mention the project you’re working on, but I found it from post history, downloaded the source, and reproduced it. I was able to reduce the project to a simple example with three controls and no code. I made a video walkthrough, added it to OP’s issue, and made it available here:
The simple project you are displaying would mimic my app in that the main window does have a pagepanel with multiple panels and canvases. I tried having one of the simpler windows in my app be the last one to close, but the problem still exists. That said, none of my windows are as simple as the one in your demo.
Fortunately, the workaround you suggested was simple to add and is working perfectly.