Crashing upon closing application following database query

I am running a database query and saving the results in a property of the window called rs (RowSet). It then follows with a MessageBox to alert RowSet has been received successfully. After dismissing the message, if I attempt closing the application, it crashes and doesn’t close gracefully as expected.

What could be going wrong here? My initial thought was if the application was busy (main thread) doing something in the background; however, there are no other threads or timers running. How could I check if something is running in the background stopping the application from closing properly?
I have stepped through the code and nothing runs after the message box is displayed, so no idea what could be causing the issue.

  rs = App.Database.SelectSQL(sql)
Catch error As DatabaseException
End Try

MessageBox("Rowset received")

Do you have code in app.unhandledException to catch anything you haven’t anticipated?

I have just tested this and the code in the app.unhandledException is not triggering

Var msg As String = "An error occurred: "

Return True

Ok, well what you’ve got there might be causing the crash.

You’re calling Quit and then returning True to not crash, but it may be interfering with the quit.

FWIW, if you don’t return true in that event, you’ll get the same effect, the app will show a dialog and then quit, so I suggest just removing that code.

Before we get any further, let’s clarify… is this a:

  1. Hang - where the app just stops responding
  2. Exception - where it shows that dialog with a message
  3. Crash - where your app just disappears without a message

Ok thanks, I just tried the following and it’s still not triggering:

Var msg As String = "An error occurred. Please notify the author.  Stack: "

Regarding your question, it’s hanging (not responding). See gif below:

xojo hang

I have managed to identify something. When creating a MS SQL Server database instance as a property of the Application and connecting to the database in the Opening event of the application, it causes the hanging you see above after querying from the database and saving the RowSet as a property of the Window.

But when I instantiate the database manually as a property of the Window and connect to it with a separate connection method, the application does not hang after querying it.

So, it looks like the issue is related to the RowSet being saved as a property of the Window while the database is a property of the Application. I’m not sure why this would be an issue though?

I found the issue:

The issue was caused from the fact I didn’t specify the DatabaseName property of the database object before connecting to it. I have intentionally left it out in other apps previously, as I usually qualify the database name in the queries I run.
If omitting the DatabaseName can cause issues, I would have expected an exception to be raised. Or maybe this is a bug?