nagyistoce / maccode

Automatically exported from code.google.com/p/maccode
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

PSMTabBarControl -dealloc crash #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It is not allowed to modify an array while being enumerated.

This is why -dealloc causes crashes with cells left in the _cells array.

Please change -dealloc to:

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];

    //stop any animations that may be running
    [_animationTimer invalidate];
    [_animationTimer release]; _animationTimer = nil;

    [_showHideAnimationTimer invalidate];
    [_showHideAnimationTimer release]; _showHideAnimationTimer = nil;

    //Also unwind the spring, if it's wound.
    [_springTimer invalidate];
    [_springTimer release]; _springTimer = nil;

    //unbind all the items to prevent crashing
    //not sure if this is necessary or not
    NSArray *cells = [NSArray arrayWithArray:_cells];  // create a copy as we
will change the original array while being enumerated
    NSEnumerator *enumerator = [cells objectEnumerator];
    PSMTabBarCell *nextCell;
    while ( (nextCell = [enumerator nextObject]) ) {
        [self removeTabForCell:nextCell];
    }

    [_overflowPopUpButton release];
    [_cells release];
    [_controller release];
    [tabView release];
    [_addTabButton release];
    [partnerView release];
    [_lastMouseDownEvent release];
    [style release];

    [self unregisterDraggedTypes];

    [super dealloc];
}

Original issue reported on code.google.com by mi...@monscheuer.de on 8 Feb 2010 at 8:37