Date
1 - 4 of 4
Exception not being caught in try statement
Mark Allan
Hi all,
toggle quoted message
Show quoted text
Thanks to everyone for their suggestions. I spent far too much time working around this bug, but have finally got to the bottom of the original issue. It turns out this is a known issue with some other apps as well, and (thanks to https://trac.cyberduck.io/ticket/11231#comment:25 ) can be fixed by removing an obscure preference key from the User Defaults system. I was able to reproduce the issue by setting the __NSDisableSharingTextTabInstance key to YES using the "defaults write" command. I've solved it by removing that key in my -applicationDidFinishLaunching method: [[NSUserDefaults standardUserDefaults] removeObjectForKey: @"__NSDisableSharingTextTabInstance"]; Looks like someone has already submitted a bug report to Apple for it (https://openradar.appspot.com/FB8930278 ) so I'm just posting this here in case it helps anyone else in the future. Best regards, Mark
|
|
Gary L. Wade
Try surrounding the call with beginEditing and endEditing on the text storage. If it still happens, submit a feedback to Apple with the full crash log.
toggle quoted message
Show quoted text
-- Gary L. Wade http://www.garywade.com/ On Mar 26, 2021, at 4:11 AM, Mark Allan via Cocoa-dev <cocoa-dev@...> wrote: |
|
Jon Gotow
What's the architecture of the machine on which exceptions aren't being caught? Is the try block working on Intel and not on M1?
toggle quoted message
Show quoted text
The crash is happening as the RTF reader is setting up the tab stops in the default paragraph format, so I'd assume there's something wonky about the tab stops or other paragraph formatting in your RTF doc. - JOn On Mar 26, 2021, at 5:11 AM, Mark Allan <markjallan@...> wrote: |
|
Mark Allan
Hi folks,
Some users are reporting a crash that I can't reproduce, and in an attempt to gain additional diagnostics from a user, I wrapped the affected line in a try/catch block. For two users it resolve the crash, but for a third, it's still crashing at the same point! The crash occurs when a user attempts to open the "About" window from my app's main menu item. I'm not using the standard about panel as there's a few additional items I need to display, one of which is an NSTextView which I populate with the contents of an RTF file from within the app bundle. I've symbolicated the crash log to find it's happening when populating that TextView. The line in question now reads as follows: @try { [self.aboutBox.creditsTextView readRTFDFromFile:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]]; } @catch (NSException *exception) { NSLog(@"Error loading the contents of the text file for the About Box. %@", exception); //Check we have a file at the expected path if([[NSFileManager defaultManager] fileExistsAtPath:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"]]){ NSLog(@"Yes. Found the RTF credits file"); // check the attributes in case somehow there's no permission to read the file NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"] error:nil]; NSLog(@"RTF file has following attributes %@", fileAttributes); } else { NSLog(@"Nope, file not found"); } } This is the crash log from the newest build (with the try/catch around that line): Performing @selector(showAboutBox:) from sender NSMenuItem 0x600000634540 Any ideas what's going on? Other than the file not being found, why else might the object at line 3 in the backtrace be nil...and more interestingly, why is the exception not being caught? Thanks Mark |
|