As odd as it sounds, I need to trigger a crash for testing. I tried various forms of calling a declare that doesn’t exist, but that just gets logged to console instead.
Declare Function DoesNotExist Lib "Cocoa.framework" selector "doesNotExist" (Target As Ptr) As Integer
Var Result As Integer = DoesNotExist(Nil)
No luck so far. defaults write com.thezazstudios.myapp NSApplicationCrashOnExceptions -bool YES doesn’t seem to change anything with the given code. And I don’t know enough of the standard C library to write a valid call. Writing an invalid call causes the compiler to fail.
Try calling a function that an object doiesn’t respond to.
declare sub setFrame lib "AppKit" selector "setFrame:" ( NSWindowInstance as integer, frameRect as NSRect )
Dim r as NSRect
setFrame( me.truewindow.handle, r )
Or do something like releasing an object, while it is still in use.
Declare sub NSObjectRelease lib "Foundation" selector "release" ( NSObjectInstance as integer )
NSObjectRelease( me.handle )
I simply typed these in the forum, so there may be typos.
// example of how to deliberately throw an error
#Pragma BreakOnExceptions False
Var e As New RuntimeException
e.ErrorNumber = 1000
e.Message = "A custom exception was thrown!"
Raise e
#Pragma BreakOnExceptions Default
Did a mod choose a solution for me? What the heck? I definitely didn’t pick one. I was coming back to select a solution now because I just got around to test, and I find a solution has already been selected? That’s not cool.
Can someone explain what Norman’s code is doing and why it causes a crash? Also, is Norman’s crash something that you can catch and recover from? I’m not getting what this is all about.
A nil pointer access will always crash.
That is normal, can’t really be caught in Xojo.
Except maybe our SignalHandlerMBS class, but that wouldn’t prevent the app exiting.