Re: Blocked in NSFileCoordinator
Re: Blocked in NSFileCoordinator
- Subject: Re: Blocked in NSFileCoordinator
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Tue, 30 Aug 2011 01:11:31 +0700
On 29 Aug 2011, at 22:05, Kyle Sluder wrote:
> Saving during loading will now deadlock on Lion, since you're trying to do a coordinated write while NSDocumentController still has a coordinated read on your file. Don't save while loading.
>
> Does -takkeEvent: happen in response to NSUndoManager notifications? Something could be poking the NSUndoManager.
No NSUndoManager used.
But it worked in Snow Leopard like this:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
activeDoc = [ sDC openDocumentWithContentsOfURL: absoluteURL display: YES error: &outError ];
... add some data to activeDoc
[ activeDoc saveDocument: nil];
}
But it seems that opening and saving in the same event does not work in Lion (and this open method is deprecated in Lion).
So I replaced this with:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[ sDC openDocumentWithContentsOfURL: absoluteURL display: YES completionHandler: ^(NSDocument *document, BOOL documentWasAlreadyOpen, NSError *error)
{
[ self completeDidFinishLaunching: (MyDocument *)document ];
}
];
}
- (void)completeDidFinishLaunching: (MyDocument *)doc;
{
activeDoc = doc;
... add some data to activeDoc
[ activeDoc saveDocument: nil];
}
And now this bug has disappeared.
Thanks for pointing me in the right direction.
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden