As many of us have learned, 64bit Mac OS apps will crash on close if we have any code in CancelClose. To solve this, a call to a Cocoa function “terminate” is used:
[code] #If targetMacOS Then
Declare Function NSClassFromString Lib “Cocoa” ( aClassName As CFStringRef ) As Integer
Declare Function sharedApplication Lib “Cocoa” selector “sharedApplication” ( classRef As Integer ) As Integer
Declare Sub terminate Lib “Cocoa” selector “terminate:” ( appRef As Integer, sender As Integer )
Dim appInstance As Integer = sharedApplication( NSClassFromString( "NSApplication" ) )
terminate( appInstance, appInstance )
#EndIf[/code]
There is a bad side effect from this if you are trying to profile you code - the profile summary is discarded since the profiler stub thinks that the app exit improperly.
So, we either get a profiler result with a probable app crash on quit, or we don’t get the profiler report.
Questions - for @Joe Ranieri :
Is the crash on quit being resolved
for others:
Do you use Profiling in your built apps for BETA and, if so, have you run into and worked around this?
I’m not running in the IDE - I need results from actual use cases at the customer location. In the IDE, I can simply add an “If Not DebugBuild Then” block around the terminate declares code and ignore the crash.
Which begs the next question - why doesn’t the profile result get returned even IF the app “crashes” before quit?
a) Write your own profiling
b) use XCode instead (mostly kidding)
I’m interested in this, too, because I have the opposite problem. My app doesn’t quit at all in 64bit. <https://xojo.com/issue/48395> . The chances of getting this fixed are pretty low.
Yes; am still using macOS 10.11 for development; where this API is not required to exit correctly.
However I do use this API when not profiling so that I can get the “Resume” functionality.
I’ve started to use my own profiler; the main reason being is that it writes the results as it goes along. This allows me to get a lossy overview of what the changes do in real time. It still has many many kinks and doesn’t work correctly, so I suspect it needs a rebuild.