gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NIB loader problem


From: Fred Kiefer
Subject: Re: NIB loader problem
Date: Sat, 09 Mar 2013 19:58:42 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3

On 09.03.2013 18:35, Luboš Doležel wrote:
I wrote a simple *native* GNUstep app that replicates these steps and
ended up with the same assertion failure:

2013-03-09 18:33:10.258 loader[3383] NSView.m:4683  Assertion failed in
NSSplitView(instance), method initWithCoder:.
NSInternalInconsistencyException
2013-03-09 18:33:10.258 loader[3383] Exception occured while loading
model: NSView.m:4683  Assertion failed in NSSplitView(instance), method
initWithCoder:.  NSInternalInconsistencyException
2013-03-09 18:33:10.258 loader[3383] Failed to load Nib
2013-03-09 18:33:10.260 loader[3383] Cannot load the main model file
'BNMainWindowController'

I used my old NIB loader code (the one I used while writing the GNUstep gui keyed decoding stuff) and loaded your NIB file. It results in the same error you get. Having it locally allows me to see the full backtrace:



#0 -[NSException raise] (self=0xb75a88, _cmd=0x7ffff75368e0 <_OBJC_SELECTOR_TABLE+384>)
    at NSException.m:955
#1 0x00007ffff6ff5e56 in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] (self=<optimized out>, _cmd=<optimized out>, aSelector=<optimized out>,
    object=<optimized out>, fileName=<optimized out>, line=4683,
    format=0x7ffff7536c60 <_OBJC_INSTANCE_3>) at NSAssertionHandler.m:135
#2  0x00007ffff7952f20 in -[NSView initWithCoder:] (self=0xa7fb88,
_cmd=0x7ffff7d390d0 <_OBJC_SELECTOR_TABLE+1456>, aDecoder=<optimized out>)
    at NSView.m:4682
#3  0x00007ffff78f8281 in -[NSSplitView initWithCoder:] (self=0xa7fb88,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSSplitView.m:1382
#4 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#5  0x00007ffff795240b in -[NSView initWithCoder:] (self=0xa7eec8,
_cmd=0x7ffff7549b10 <_OBJC_SELECTOR_TABLE+336>, aDecoder=0x77db18) at NSView.m:4657 #6 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#7  0x00007ffff78d05b4 in -[NSResponder initWithCoder:] (self=0xa7d608,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSResponder.m:383
#8  0x00007ffff79521ab in -[NSView initWithCoder:] (self=0xa7d608,
_cmd=0x7ffff7cab260 <_OBJC_SELECTOR_TABLE+1856>, aDecoder=0x77db18) at NSView.m:4599 #9 0x00007ffff783d92c in -[NSControl initWithCoder:] (self=0xa7d608, _cmd=<optimized out>,
    aDecoder=0x77db18) at NSControl.m:1004
#10 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#11 0x00007ffff795240b in -[NSView initWithCoder:] (self=0xa7bd18,
_cmd=0x7ffff7cab260 <_OBJC_SELECTOR_TABLE+1856>, aDecoder=0x77db18) at NSView.m:4657 #12 0x00007ffff783d92c in -[NSControl initWithCoder:] (self=0xa7bd18, _cmd=<optimized out>,
    aDecoder=0x77db18) at NSControl.m:1004
#13 0x00007ffff7920087 in -[NSTextField initWithCoder:] (self=0xa7bd18,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSTextField.m:758
#14 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#15 0x00007ffff708d6e2 in -[NSKeyedUnarchiver(Internal) _decodeArrayOfObjectsForKey:] ( self=0x77db18, _cmd=0x7ffff750b770 <_OBJC_SELECTOR_TABLE+656>, aKey=<optimized out>)
    at NSKeyedUnarchiver.m:115
#16 0x00007ffff6ff4c86 in -[NSArray initWithCoder:] (self=0xa7bbf8, _cmd=<optimized out>,
    aCoder=0x77db18) at NSArray.m:712
#17 0x00007ffff6f9f4d1 in -[GSMutableArray initWithCoder:] (self=0xa7bbf8,
    _cmd=<optimized out>, aCoder=0x77db18) at GSArray.m:539
#18 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
---Type <return> to continue, or q <return> to quit---
#19 0x00007ffff79a9785 in -[NSCustomView nibInstantiateWithCoder:] (self=0xa756c8,
    _cmd=<optimized out>, coder=0x77db18) at GSNibLoading.m:1123
#20 0x00007ffff79ab470 in -[NSCustomView initWithCoder:] (self=0xa756c8,
    _cmd=<optimized out>, coder=0x77db18) at GSNibLoading.m:1172
#21 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#22 0x00007ffff78d05b4 in -[NSResponder initWithCoder:] (self=0xa6fc38,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSResponder.m:383
#23 0x00007ffff79521ab in -[NSView initWithCoder:] (self=0xa6fc38,
_cmd=0x7ffff7cab260 <_OBJC_SELECTOR_TABLE+1856>, aDecoder=0x77db18) at NSView.m:4599 #24 0x00007ffff783d92c in -[NSControl initWithCoder:] (self=0xa6fc38, _cmd=<optimized out>,
    aDecoder=0x77db18) at NSControl.m:1004
#25 0x00007ffff7920087 in -[NSTextField initWithCoder:] (self=0xa6fc38,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSTextField.m:758
#26 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#27 0x00007ffff7810216 in -[NSNibConnector initWithCoder:] (self=0x9de408,
    _cmd=<optimized out>, aDecoder=0x77db18) at NSBundleAdditions.m:100
#28 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#29 0x00007ffff708d6e2 in -[NSKeyedUnarchiver(Internal) _decodeArrayOfObjectsForKey:] ( self=0x77db18, _cmd=0x7ffff750b770 <_OBJC_SELECTOR_TABLE+656>, aKey=<optimized out>)
    at NSKeyedUnarchiver.m:115
#30 0x00007ffff6ff4c86 in -[NSArray initWithCoder:] (self=0xa6a618, _cmd=<optimized out>,
    aCoder=0x77db18) at NSArray.m:712
#31 0x00007ffff6f9f4d1 in -[GSMutableArray initWithCoder:] (self=0xa6a618,
    _cmd=<optimized out>, aCoder=0x77db18) at GSArray.m:539
#32 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#33 0x00007ffff79ae483 in -[NSIBObjectData initWithCoder:] (self=0x9def18,
    _cmd=<optimized out>, coder=0x77db18) at GSNibLoading.m:1754
#34 0x00007ffff7090dc0 in -[NSKeyedUnarchiver(Private) _decodeObject:] (self=0x77db18,
    _cmd=<optimized out>, index=<optimized out>) at NSKeyedUnarchiver.m:220
#35 0x00007ffff79d9ee8 in -[GSNibLoader loadModelData:externalNameTable:withZone:] ( self=<optimized out>, _cmd=<optimized out>, data=0x9b77b8, context=0x0, zone=0x0)
    at GSNibLoader.m:81
#36 0x00007ffff7810c2b in +[NSBundle(NSBundleAdditions) loadNibFile:externalNameTable:withZone:] (self=<optimized out>, _cmd=<optimized out>, fileName=0x711f88, context=0x0, zone=0x0)
    at NSBundleAdditions.m:235
#37 0x0000000000400ebd in main (argc=2, argv=<optimized out>) at nibloader.m:167


(gdb) up 2
#2  0x00007ffff7952f20 in -[NSView initWithCoder:] (self=0xa7fb88,
_cmd=0x7ffff7d390d0 <_OBJC_SELECTOR_TABLE+1456>, aDecoder=<optimized out>)
    at NSView.m:4682
4682              NSAssert([sub class] != [NSCustomView class],
(gdb) po sub
h=--- v=--- <NSCustomView: 0xa756c8> f={x = 316; y = 0; width = 414; height = 402} b={x = 0; y = 0; width = 0; height = 0}


As you can see the NSCustomView already shows up further up in the back trace (frame #20). What happens here is that the NSCustomView gets decoded as the next responder for some sort of NSTextField. While decoding the custom view we decode another NSTextField (frame #13) and for this we decode the NSNextKeyView (frame #11) an NSControl (frame #9) and again we decode the next responder for this (frame #7) for this NSView we get again the NSNextKeyView (frame #5) and this happens to be the split view that has our NSCustomView as a sub view.

Now the problem here is the way we implemented the keyed coder. When we decode an object we store a reference to it in a map and that reference gets used every time we need to decode the same object. When NSCustomView returns a different object from its initWithCoder: method that mapping will get replaced, but this is too late for your case. as the error happens within that method.

As you can see the problem is order dependent. In your case it may help to move some of the decoding steps around. But this isn't a general solution. The non-keyed unarchiver has the method:
- (void) replaceObject: (id)anObject withObject: (id)replacement

That would allow the NSCustomView initWithCoder: method to replace itself early on, but there isn't anything similar for keyed coding.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]