I need to be able to catch a rarely occuring ObjC exception in my code. While this always worked in 32 bit builds, it doesn’t in 64 bit builds.
Here’s the code I use (it’s part of macOSlib’s NSPasteboard class):
declare function dataForType lib CocoaLib selector "dataForType:" (obj_id as Ptr, type as CFStringRef) as Ptr dim p as Ptr try p = dataForType (pasteboardRef, "public.rtf") catch exc as ObjCException break end try
In 32 bit, the exception is caught.
In 64 bit, the exception is not caught, which leads to the entire event being aborted (i.e. the exception is passed on to the top of the calling stack, which is the event handler in the Xojo framework. This breaks my app severely.
Is this a know problem? I am using 2019r3.2
Is there a work-around? Can I somehow catch ObjC exception in my own code? Maybe with a plugin?
Note: If I use MBS’s
NSPasteboardMBS.dataForType function, I get the exception properly and can catch it. So, the exception is clearly properly raised, and MBS can catch it, even in 64 bit.
This seems to be a fundamental bug in the 64 bit code generation. I’m surprised it hasn’t been noticed and fixed so far - or has it, since 2020?