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.

Hope this helps someone somewhere in the future ;-)

Anyway thanks again to everybody helping out with this.

Gilles

 


On 30 janv. 2013, at 12:41, Mike Abdullah <cocoa...@mikeabdullah.net> wrote:

> 
> On 29 Jan 2013, at 16:18, Gilles Celli <gilles.ce...@ecgs.lu> wrote:
> 
>> I looked a little bit today here with my application, and the term 
>> unresponsive for the Open Panel is not appropriate:
>> it should be "stays open" when reading /processing the big data file and 
>> then the panel closes.
>> 
>> The main processing time is when converting date/time to 
>> NSTimeIntervalSince1970, and extracting data values..so a big ASCII data 
>> file can have > 500000 lines 
>> 
>> Simply put, the Open Panel should be closed, but it stays open until the 
>> data file has been processed and the data displayed as a graph.
>> 
>> There should be a way to close NSDocument openPanel but didn't find anything 
>> about it…
>> 
>> Any help is as always greatly appreciated :-)
> 
> So I ran a quick little test here. Our app already uses asynchronous document 
> opening. I simply whacked in a sleep(5) call to make sure that opening 
> documents takes a long time. With that in place:
> 
> 1. Bring up the Open Panel (File > Open, no custom code here)
> 2. Select a document
> 3. Click Open
> 4. The panel disappears shortly after
> 5. After a delay, the document appears
> 
> Thus I conclude that if you are seeing the open panel hang around, you're 
> likely doing something wrong to block the main thread.
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to