I am running Mac Sonoma and Xojo 2025R2 (don’t have the $$ for the newest license)
This might be a stupid question, but is there something special about the File->Quit Menu?
I want to clean up a database when the program quits, but when I put in the code (which I know is working because I put it in another menu to test), the command+Q doesn’t work.
I get on my Mac “not responding” when my code is there.
Here is the code:
// for testing only
System.DebugLog "I got here to clean the database"
var cleaningTheDatabaseString as String
var cleanedDatabase as New SQLiteDatabase
cleanedDatabase.DatabaseFile = SpecialFolder.Documents.Child(app.theScheduleDatabaseName)
cleaningTheDatabaseString = "delete FROM theScheduledRecordings WHERE EXISTS (SELECT 1 FROM theScheduledRecordings AS t2 " +_
"WHERE theScheduledRecordings.websiteName = t2.websiteName AND theScheduledRecordings.recordingName = t2.recordingName "+_
"AND theScheduledRecordings.startRecordingTime = t2.startRecordingTime AND theScheduledRecordings.endRecordingTime = t2.endRecordingTime "+_
"AND theScheduledRecordings.rowid > t2.rowid);"
Try
cleanedDatabase.Connect
cleanedDatabase.ExecuteSQL (cleaningTheDatabaseString)
Catch error As IOException
MessageBox("The database file could not be created: " + error.Message)
end try
Return True
Your Mac is complaining because your app is actually “freezing” for a moment—for instance, because an SQL operation is taking too long, or another app is currently locking the same SQL database file, and so on. After all, your MenuHandler code runs on your app’s main thread.
It would be better to wrap your code in a thread. Run this Thread instead of quitting your App. If everything went fine, the Thread can quit your App by using a Timer (because it is not allowed to interact with the UI directly). And if it failed, inform the user.
Here’s a very simple example: untitled.zip (4.3 KB)
I already share the following in this forul. Here it is again:
• In “User interface Desktop Creating menus” I found:
The Exit (or Quit) menu item
The DesktopQuitMenuItem class is intended only for the Quit (or Exit) menu item. When a DesktopQuitMenuItem is selected, your application quits. It also moves the menu item to the application menu for Mac apps.
Why searching after that (when you are a user of the product since 1998 ?
Because Q do not works since (probably) Xojo 2026r2.1.
But this was the last step; before that, I change the Super of the Quit Menu to “DesktopQuitMenuItem”,
Then I had to delete the FileQuit Event (in fact whatever File Quit Event there was in that Project).
So, now you know all (and my failing memory too).
If you cannot Quit your application at debug time, do the above instead of crying “Why is the world so cruel”.
PS: I searched in the Release Notes from 2020 to 2026 (last released version) and do not found an entry for that new Quit Feature. (nor deprecating information about Quit).
However, I may be unlucky in my quest. If you know in what Release Note this information is, please give it to us.