Code execution order not followed

The App.Opening event calls a number of methods. To start all the methods are in the App. They all work fine. But the last two methods are in other classes. They are never run. What am I missing?

sub App.Opening

//these methods are all in App
MBSReg
GetAppSupFolder
GetCurrentDate
GetRetPlanParams
InitDBModule

//these methods not part of App
Window1.Win1Init
XLModuleStart

the last 2 would need to be Shared Methods in classes
if they are regular methods, also known as instance methods, you’d need an instance, created using NEW, to invoke them

It can be that your application is encountering a NSException during launch. Since 10.14, Apple thought it could reduce the number of crash reports, by… Not crashing when certain things go wrong… This leaves lots of weirdness happening, but crash reports are down.

There’s some code somewhere which tells Apple to crash your application if it encounters a NSException, I highly recommend you find it and add it to your app.

This reminds me of some company that archives bugs rather than fix them :sweat_smile:.
These behaviours of moving the issues on the users side are sad.

2 Likes

Should have said in the original post: M1 Mac running Ventura with Xojo 2022r4.1.
I made Window1.Win1Init method into a shared method as Norman suggested and it ran after doing things like changing “me.” to “Window1.” and making another Window1 method it called into a share method.
Then I decided I could put the Win1Init method into the Window1.Opening event. The Window1.Opening event never fires. The Activated event fires. Will now go check if that is a known bug.
Sam, haven’t started to look at your suggestion.

Started to remove controls from Window1 one at a time. Soon discovered that removing a container allowed the Window1.Opening event (and some others) to fire. Then started to disable code from Opening events of controls in the container one at a time. Soon found that the following code in a DesktopPopupMenu.Opening event was the problem:

Declare Sub setNumberOfVisibleItems Lib “AppKit” Selector “setNumberOfVisibleItems:” (controlHandle As Ptr, count As Integer)
setNumberOfVisibleItems(me.Handle, 30)

This stuff is hard. Turns out I originally had this control as a DesktopComboBox and the above code allows setting the maximum number of rows greater than 15. I changed to a DesktopPopupMenu and didn’t remove this code. My error cost a number of days.

Sam, thanks for telling me about NSException not always causing crashes in the recent MacOS versions. This is covered more in TOF. Now I just have to get the fix working.

Which would be a NSException if the NSPopupButton doesn’t support the function “setNumberOfVisibleItems:”.

Probably needs to check if the item supports the selector and only call it if it does

I’d even bet someone has code for this laying about somewhere :stuck_out_tongue: