Re: NSDocument "save as" bug
Re: NSDocument "save as" bug
- Subject: Re: NSDocument "save as" bug
- From: Half Activist <email@hidden>
- Date: Tue, 2 Feb 2010 07:51:53 +0100
Hi Gregory,
thanks for your support, I was a bit upset because I'm pretty sure the same instance fails. Because when the crashes began to happen after adding the second document type, I put a breakpoint in awakeFromNib, and by giving a look at the document, I knew that this was a document already opened everything in it was "valid". But to be really certain of it I added a simple awakeFromNibAlreadyCalled instance variable, and it showed that this one instance had its awakeFromNib method called a second time.
PS: I put a breakpoint and dumped self with gdb.
The first time it is called:
(gdb) print (void *) self
$1 = (void *) 0x100675c30
The second time:
(gdb) print (void *) self
$2 = (void *) 0x100675c30
Regards.
On Feb 1, 2010, at 7:55 PM, Gregory Weston wrote:
>
> On Feb 1, 2010, at 12:16 PM, Half Activist wrote:
>
>> I'm not making any assumption on the number of documents that might exist at one time.
>> Even if i have 10 documents opened, the one that i do a "save as" on has its _instance method_ awakeFromNib called a second time:
>> The callstack shows that my document's awakeFromNib is being called during the save panel setup process.
>
> Yes. The call stack shows that awakeFromNib is being sent to *an* instance of your document class. The call stack also shows just before that that a nib is being loaded and the objects therein instantiated. If that's not what's implied by lines 1-3, someone at NeXT did a mind-bogglingly horrible job coming up with method names.
>
>> #1 0x00007fff82927959 in -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] ()
>> #2 0x00007fff82925b49 in loadNib ()
>> #3 0x00007fff8292525c in +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] ()
>> #4 0x00007fff82c93797 in -[NSDocument _savePanelAccessoryViewForWritableTypes:defaultType:] ()
>> #5 0x00007fff82c91192 in -[NSDocument _preparedSavePanelForOperation:] ()
>> #6 0x00007fff82c9022b in -[NSDocument _runModalSavePanelForSaveOperation:delegate:didSaveSelector:contextInfo:] ()
>>
>> Unless specifying several editable document types grants your awakeFromNib an undocumented chance to get called a second time.
>> Furthermore, how do you explain that this works on Leopard but fails on Snow Leopard?
>
> One possible explanation is that Snow Leopard is using a technique to populate the formats menu that involves instantiating your document(s) while Leopard used a different technique. Regardless of the "nothing new" marketing line that was used for 10.6, behind the scenes we know quite a lot changed.
_______________________________________________
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