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

1

6

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.

Tb answered 25/2, 2017 at 17:39 Comment(1)
I saw this in an application of mine that used Qt, when I upgraded to Sierra and Qt 5.8. I had assumed this was a Qt problem, but apparently it isn't. I'm not claiming this as a solution, but since it appears to be looking for a top level directory called AirDrop, I experimented with creating one. This at least got rid of the warnings, and trying that might be a useful experiment. I've not been able to find any explanation of why a file open dialog might want to look at /AirDrop, so all I'm really doing here is sharing some experience.Chrischrism
W
1

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.

Wintergreen answered 15/6, 2017 at 17:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.