gujjula / core-plot

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

CPTTextLayer sizeThatFits hurt by Shadow code #322

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a pie chart an run in the iPad (not the emulator)
2. Do not set a shadow on the pie chart
3. Add labels to the slices

What is the expected output? What do you see instead?
Watching in the debugger, expect ShadowOffset to be 0.0.  It is coming out as 
NAN instead.  This is likely random based upon existing memory.  This causes a 
SIGABT later in the rendering code.

What version of the product are you using? On what operating system?
This is the current mercury trunk version.  I checked the code in browse and it 
looks unmodified.  It ran OK in the iPad emulator, but failed on the iPad 
itself.

Please provide any additional information below.
I modified the code like below and it resolved the issue:

-(CGSize)sizeThatFits
{
    if ( self.text == nil ) return CGSizeZero;
    CGSize textSize = [self.text sizeWithTextStyle:self.textStyle];
    //TRS - When self.shadow is nil, self.shadow.shadowOffset was returning in the iPad with a width of NAN.
    CGSize shadowOffset = CGSizeMake(0.0f, 0.0f);
    CGFloat shadowRadius = 0.0f;
    if (self.shadow != nil)
    {
        CPTShadow *myShadow = self.shadow;
        shadowOffset = myShadow.shadowOffset;
        shadowRadius = myShadow.shadowBlurRadius;
    }
    // Add small margin
    textSize.width += (ABS(shadowOffset.width) + shadowRadius + kCPTTextLayerMarginWidth) * 2.0;
    textSize.width = ceil(textSize.width);

    textSize.height += (ABS(shadowOffset.height) + shadowRadius + kCPTTextLayerMarginWidth) * 2.0;
    textSize.height = ceil(textSize.height);

    return textSize;    
}

Original issue reported on code.google.com by ProfVonL...@gmail.com on 21 Aug 2011 at 7:04

GoogleCodeExporter commented 9 years ago
This is another case of the problem described in issue #319.

Original comment by eskr...@mac.com on 21 Aug 2011 at 8:08