Close Datasheet and Crashes

I’ve found that if I have a form and a Datasheet open, there’s a very high likelihood of a crash if the Datasheet is the active window and I click its close button.

If the form is active and I click the close button of the Datasheet without activating it, the Datasheet closes properly.

This is repeatable in several databases that I’ve tried it on. By avoiding closing an active Datasheet window I have reduced crashes greatly.

I’ve only worked with it on Big Sur.

Since I reported this earlier, the behavior has continued and is easily repeatable. I have been wondering why nobody else, except Jim, had commented one way or the other. I had not discovered the difference that occurs when a datasheet has been activated and not activated, but I see that also.

1 Like

Six days ago I couldn’t duplicate this, now today I can. It seems to only happen on my Big Sur machine, and only on b18. Works fine on b17. Two steps forward, one step back.

Speaking from the point of view of almost complete ignorance of what is happening under the hood, it seems like a solution might be suggested by noticing that the close window menu statement (and command-W), and the closewindow statement in a procedure all correctly close the datasheet. I would bet those three all execute the same code. But I have no idea what the red dot code is.

If only it was that simple. Clicking the red dot triggers Apple code, which then turns around and calls a method windowWillClose: in the application’s code if it exists (kind of like Panorama will call your .Initialize code if it exists). For a Panorama data sheet, this method contains 10 lines of code – none of which has been modified since August 20, 2018.

The AppKit system, which is based on the 35 year old NeXT OS, breaks programs up into small modular sections. There’s code for the overall app, for working with generic documents, for working with a specific type of document, for working with generic windows, for working with a specific type of window. Usually this is a big advantage because each section of code only works with a very limited area of the project. But it can make figuring out overall operation very difficult – a simple task like closing a window will trigger dozens of small interconnected methods across multiple object classes. It’s often difficult to even figure out what code is being used for a particular task, let alone track down where the problem is. In fact, in many cases figuring out what code is involved is 95% of the problem, once you’ve figured that out, the solution is often obvious.

You pretty much win that bet. Both the Close Window menu command and the closewindow statement work by sending an internal performClose: message to the current window. According to Apple, that’s also what clicking on the red circle does. However, I have no visibility into the code that handles the click and sends this message.

Bottom line – the code in Panorama that handles closing the window IS exactly the same no matter what triggered the close. So rather than suggesting a solution, you’re just making me realize how frustrating and difficult this problem is going to be. :frowning:

Gee, when does that ever happen with programming?

You have great empathy from many of us, believe me. The Herculean effort is recognized and appreciated.

This happens to me also in Big Sur 11.5.1 using Pan b18

I am using key shortcuts like cmd-W (or cmd-shift-W) usually or close windows procedurally, but I made a quick test today. When I use the red dot click, I am NOT seeing those crashes here on my MBP with (German) MacOS 11.5.1.

I am seeing this problem on 11.5.1. Actually, I think last week when I didn’t see the problem I was using 11.4.

I’ve done some further sleuthing. I’m not in sight of a fix, but it appears that this may be a more general bug that is not directly related to window closing.

I saw this today. I have a file which normally has only one window open, but occasionally I will need to make a change on the Datasheet. So I opened the sheet today, and when I made the changes and clicked on the red button, it crashed. I tried this several times, including restarting the computer. Finally I closed the sheet through the File menu, and it closed properly.

Before I ran into this, I had my most troublesome file open, which opens another file secretly, and bringing up that file opens the Datasheet. But that sheet closes normally with the red button, as the only other window open is the other file. I guess it is the combination of the sheet and another form open that causes the crash, so it may have to do with changing the focus from the sheet to a form in the file. I could imagine that could get screwed up.

Looks like this problem is now resolved:

Agreed, that and the active cell in the data sheet are both fixed