Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Failed to updated [sic] bookmark for item" on [NSOpenPanel openPanel] invocation

My Mac app is designed to edit and analyse graphs, which users can create and store in files anywhere on the file system. I go to user to let them open a previously created file with [NSOpenPanel openPanel] and an inline completion handler block. During the menu processing I get this console error message several times:

2017-02-25 13:42:47.394433 pasteurnet3[32901:1263849] [default] Failed to updated bookmark for item (null) [60AF512E-6072-427D-8624-C406B0EF7D5A] - URL:file:///AirDrop with error Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."

This happens just in the creation of the NSOpenPanel, even before sending it the beginWithCompletionHandler: message. FWIW, the menu nonetheless does comes up when eventually requested, allows file selection, and otherwise seems to work. There does seem to be a long delay in the initialisation of the menu object.

I haven't paid attention to this app in a long time but the appearance of the message apparently owes to a MacOS change. I immediately suspected sandboxing, but sandboxing was turned off for the app. If I turn on sandboxing and request the "User-selected file" entitlement it seems to make no difference.

There is nothing special about the object creation except it is done inside a @try block:

@try {
    // Create the File Open Dialog class.
    openDialog_ = [NSOpenPanel openPanel];  // error occurs here
}
@catch (NSException *e){
    NSLog(@"innocuous exception(1) in -initForOpenWithDefaultFile:callBackTo:");
}
@catch (NSString *s){
    NSLog(@"innocuous exception(2) in -initForOpenWithDefaultFile:callBackTo: \"%@\"", s);
}
@catch (...) {
    NSLog(@"innocuous exception(3) in -initForOpenWithDefaultFile:callBackTo: probably a layout error");
}
@finally {
    ;
}

I am not doing anything with bookmarks from within the program nor, for that matter, with AirDrop.

Xcode 8.2.1, Macbook MacOS 10.12.3.

like image 882
Cope Avatar asked Feb 25 '17 17:02

Cope


1 Answers

For me, "Failed to updated bookmark for item (null)" was logged at launch when my app's File > Open Recent menu contained items for files I had opened, then later deleted in the Finder. I don't know if there's a way to get the menu to just remove the items, but I got rid of the messages by choosing File > Open Recent > Clear Menu while running my app.

My app does not use NSDocument. I am adding items to Open Recent using -noteNewRecentDocumentURL.

like image 83
Paul Collins Avatar answered Nov 15 '22 05:11

Paul Collins