• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Debugging a crash in bindings [Solved - sort of]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging a crash in bindings [Solved - sort of]


  • Subject: Re: Debugging a crash in bindings [Solved - sort of]
  • From: Matt Gough <email@hidden>
  • Date: Fri, 3 Mar 2006 16:24:52 +0000


On 3 Mar 2006, at 13:29, Matt Gough wrote:

Sometimes, when releasing a window with a bunch of array controllers in it, my app will crash with the following backtrace:

#0 0xfffeff20 in objc_msgSend_rtp
#1 0x9299e95c in _NSKeyValueObservationInfoGetForwarderForObserver
#2 0x9296d540 in -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:]
#3 0x938dc2b4 in -[NSController removeObserver:forKeyPath:]
#4 0x938b64d8 in -[NSBinder _updateObservingRegistration:]
#5 0x93b4d3a4 in -[NSBinder releaseConnectionWithSynchronizePeerBinders:]
#6 0x936bfe00 in -[NSObject(_NSBindingAdaptorAccess) _releaseBindingAdaptor]


I managed to find the cause of this and fix it, but I am not too happy with the fix as it is a bit fragile.

What it came down to was that one of my array controllers had:

-(void) awakeFromNib
{
[mDomainsController addObserver:self forKeyPath:@"selection" options: 0 context:nil];
[mSourceKindsController addObserver:self forKeyPath:@"selection" options:0 context:nil];
}


(Please no comments about me using mXxxxx for my member variable names)

It seems that one of the controllers mentioned had already been released by the time the binding code came around to tidying up whilst my window was being torn down.

My simple fix was to do:

-(void) awakeFromNib
{
[[mDomainsController retain] addObserver:self forKeyPath:@"selection" options:0 context:nil];
[[mSourceKindsController retain] addObserver:self forKeyPath:@"selection" options:0 context:nil];
}


-(void) dealloc
	{
	[mSourceKindsController removeObserver:self forKeyPath:@"selection"];
	[mDomainsController removeObserver:self forKeyPath:@"selection"];

	[mSourceKindsController release];
	[mDomainsController release];
	[super dealloc];
	}


and this works.

However, I then started wondering whether I should update various other controller classes to retain/release their observees in a similar way.

Of course once I did this, I started leaking some of my controllers as I got into a cyclic retain pattern of things retaining each other.

Is there a better way of doing this sort of thing, without every object having to know how it is being used by other objects?

Interestingly, the original awakFromNib version of things was fine until I rearranged the window in the nib to move some of the controlled tableviews into other views. So it seems as though the order of releasing changed and caused this to pop up.

Thanks for any advice

Matt Gough
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Debugging a crash in bindings (From: Matt Gough <email@hidden>)

  • Prev by Date: Re: _NSArrayControllerTreeNode
  • Next by Date: Re: Eval() ?
  • Previous by thread: Debugging a crash in bindings
  • Next by thread: _NSArrayControllerTreeNode
  • Index(es):
    • Date
    • Thread