Question

I'm trying to use NSOpenPanel to bring up on open file page. It works fine for the most part except for 3 things:

  1. The first issue is that the side bar doesn't appear, although I can still click on it.

  2. The second issue is that when I switch to a folder with less files than the previous ones, the screen isn't cleared and some of the previous files still appear, although they are unclickable.

  3. When I try to switch to the columns view, the app crashes. But all 3 other views work just fine.

Here's the crash log:

AppKit`-[NSTableView setVerticalMotionCanBeginDrag:]:
0x7fff91d4f899:  pushq  %rbp
0x7fff91d4f89a:  movq   %rsp, %rbp
0x7fff91d4f89d:  movq   7385076(%rip), %rax       ; TrustKeychains::systemKcHandle() + 92
0x7fff91d4f8a4:  movq   (%rax,%rdi), %rax
0x7fff91d4f8a8:  movq   7385193(%rip), %rcx       ; tp_policyTrustSettingParams + 92
0x7fff91d4f8af:  movl   $4292870143, %edi
0x7fff91d4f8b4:  andl   (%rax,%rcx), %edi   <- Crash points here with EXC_BAD_ACCESS (code=1, address = 0x18)
0x7fff91d4f8b7:  shll   $21, %edx
0x7fff91d4f8ba:  andl   $2097152, %edx
0x7fff91d4f8c0:  addl   %edi, %edx
0x7fff91d4f8c2:  movl   %edx, (%rax,%rcx)
0x7fff91d4f8c5:  popq   %rbp
0x7fff91d4f8c6:  ret    

The crash log says the crash is in Thread 1.

I was wondering if anyone knew how to fix it. Here is my code

-(IBAction)openDialog:(id)sender{
NSWindow *window = [[viewArray objectAtIndex:currentIndex] window];

NSOpenPanel *openDialog = [NSOpenPanel openPanel];
[openDialog setCanChooseFiles:YES];
[openDialog setCanChooseDirectories:NO];
NSString *homeString = [NSString stringWithFormat:@"file://localhost%@",NSHomeDirectory()];
[openDialog setDirectoryURL:[NSURL URLWithString:homeString]];
NSArray *fileTypes = [[NSArray alloc] initWithObjects:@"xcodeproj", nil];
[openDialog setAllowedFileTypes:fileTypes];

[openDialog beginSheetModalForWindow:window completionHandler:^(NSInteger result){
    if (result == NSFileHandlingPanelOKButton){
        NSURL *doc = [openDialog URL];
        [[NSWorkspace sharedWorkspace] openFile:[doc relativePath]];
    }
}];

}

I put the exact same code in a different XCode project and it works just fine, so I'm not quite sure where the problem is. Thanks!

Was it helpful?

Solution

I found the problem. It turns out in my project I had redefined NSTableView and that was causing all the errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top