Re: NSDocument's Open File Panel unresponsive when opening large file from disc
Re: NSDocument's Open File Panel unresponsive when opening large file from disc
- Subject: Re: NSDocument's Open File Panel unresponsive when opening large file from disc
- From: Mike Abdullah <email@hidden>
- Date: Thu, 31 Jan 2013 00:33:18 +0000
On 30 Jan 2013, at 21:29, Gilles Celli <email@hidden> wrote:
> Well I think I found it: now the Open Panel disappears when opening large files in my document-based app.
> Now the process of the data file is done in the subclassed NSWindowController windowDidLoad method.
>
> I've found something here on the Cocoa mailing list from 2002!:
> http://www.cocoabuilder.com/archive/cocoa/53353-grief-with-nsdocument-windowcontrollerdidloadnib.html
>
> and this sentence was the most important:
> "If you do subclass NSWindowController you should instead override NSWindowController's windowWillLoad and windowDidLoad methods."
>
> Also here:
> https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html
>
> The fix to close the Open Panel immediately when the user clicked "Open" to open small and large files:
>
> 1. Read the content of the data file into NSString with NSDocument readFromURL:ofType:error
> 2. NSDocument's makeWindowControllers creates a new windowController object and I'm passing the data file
> 3. In the subclassed NSWindowController windowDidLoad / windowWillLoad method the data file is processed before displayed as a graph.
>
> This works now as expected, no more Open Panel staying open.
> Maybe I should even move the data processing to windowWillLoad, (tested it and this works too).
>
> My mistake was that I processed the data file inside readFromURL:ofType:error and then makeWindowControllers passed the processed data file
> to the subclassed NSWindowController and everything was setup via awakeFromNib.
> I didn't use NSWindowController's windowDidLoad or windowWillLoad method.
It sounds suspiciously like you've just papered over the problem to me. It sounds like you've gotten the open panel to go away, but now have a period of limbo where the app is unresponsive as it loads the window controllers and their windows.
_______________________________________________
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