gujjula / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

NSNotification crash if using CPGraphHostingView::collapsesLayers #269

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set collapsesLayers = true for a CPGraphHostingView.
2. Remove the CPGraphHostingView, then create and add a replacement.

What is the expected output? What do you see instead?
The new graphHostingView should appear, but it eventually crashes if the 
operation is repeated.

What version of the product are you using? On what operating system?
CorePlot 0.2.2 for iOS

Please provide any additional information below.

Adding "[[NSNotificationCenter defaultCenter] removeObserver:self];" to the 
dealloc method should fix the problem (not tested).

Here's the code that adds the observer.  There is no removeObserver call in 
this class.

-(void)updateNotifications
{
    if ( collapsesLayers ) {
        [[NSNotificationCenter defaultCenter] removeObserver:self];
        if ( hostedGraph ) {
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(graphNeedsRedraw:) name:CPGraphNeedsRedrawNotification object:hostedGraph];
        }
    }
}

Original issue reported on code.google.com by glenn.w....@gmail.com on 16 Mar 2011 at 7:27

GoogleCodeExporter commented 9 years ago
I have verified that the suggested fix works.  A quick fix: subclass 
CPGraphHostingView and add the removeObserver call to its dealloc.

Original comment by glenn.w....@gmail.com on 16 Mar 2011 at 8:14

GoogleCodeExporter commented 9 years ago
I added the call to dealloc.

Original comment by drewmcco...@mac.com on 17 Mar 2011 at 9:51