Re: help trouble shooting...maybe with resume?
Re: help trouble shooting...maybe with resume?
- Subject: Re: help trouble shooting...maybe with resume?
- From: email@hidden
- Date: Tue, 23 Aug 2011 13:41:03 -0400
On Aug 23, 2011, at 11:00 AM, Jim Thomason wrote:
> Gang,
>
> Unfortunately, this is a very vague question but I'm at a bit of a
> loss and hoping someone could provide some general technique or
> avenues to explore.
>
> Apple recently rejected a new app of mine, with this explanation:
>
> When saving a file, and reopening it by double-clicking the saved file
> in the Finder, the app launches with 2-3 windows: One being the saved
> file, and additional windows with no saved data. Mac OS X 10.7
>
>
> I'm guessing it's due to Lion's resume window features somehow getting
> confused. The app is document based, and it looks at the document
> controller's recently opened documents upon launch. If it finds any,
> it automatically opens the last document used. If the list is empty,
> it automatically creates an untitled document. The snippet of code is
> essentially unchanged from when I originally wrote it for a different
> app way back on Tiger. This is called in the delegate from
> applicationDidFinishLaunching:. applicationShouldOpenUntitledFile:
> returns NO.
>
> Here are my problems - first of all, I can't reproduce the blasted
> bug. Everything seems to always behave fine to me, on 10.7.0 or
> 10.7.1. I've requested more info about how to reproduce the bug but
> haven't heard back yet.
>
> Regardless of whether they get back to me, does what I've described
> sound like it could be the root of my issue? Is there some other
> method for re-opening the last document (or creating a new one) I
> should be using? Is there anything else I can look for or verify that
> might be causing this behavior?
>
> Naturally, it'd help if I could manifest the issue myself, but right
> now I just don't even know where to begin looking for this one. :-(
>
> -Jim…..
Your problem is likely related to how resume works in Lion. I've had some similar issues. In my application's applicationDidFinishLaunching method, I have the following to display a launch window with recently opened documents (similar to Xcode's launch window).
if( [[[NSDocumentController sharedDocumentController] documents] count] == 0 ) {
launchController = [[LaunchController alloc] init];
[launchController showWindow:self];
}
The problem is that the if statement evaluates to true even if the Lion resume feature is going to open some documents. So it appears the resume hasn't gotten far enough by the time applicationDidFinishLaunching is called for the sharedDocumentController to know about the documents it will open.
My hack solution was to execute the code after a delay of 0.75 seconds using dispatch_after and by that time the resume seems to have completed so if resume opened any documents, the if statement evaluates to false. I'd love to know if there's a more proper solution to this as the timing hack is fragile. In my case it just opens another window the user can close so it's not really a crisis.
Jim, my guess is your code is reopening documents when resume is also trying to open them and you end up with extra windows. I can't tell from your report of what the app review team said as to whether your code is opening up extra blank windows or extra windows with the same document (which I would think never happens given Apple's document controller).
HTH,
Dave
_______________________________________________
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