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: Gilles Celli <email@hidden>
- Date: Thu, 31 Jan 2013 16:06:16 +0100
Hmm well Mike you were right!
I was too enthusiastic yesterday by claiming that I fixed my Open Panel problem… I tried it here on my old Mac Mini with OS X 10.7 and the Open Panel
still stays open even with my newer code with windowDidLoad tec.…strangely enough but at home it did work with my iMac 27" and OS X 10.8.2…will need to try tonight…
One possibility is that that large file gets cached, but not really purged….
I will try the way of subclassing NSDocumentController (I just find out how to do it by instantiating my new NSDocumentContoller class into MainMenu.nib)…
Will let you know how it goes….I'm getting mad :-0
On 31 Jan 2013, at 01:33, Mike Abdullah wrote:
>
> 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