Why is this an over
Working with some CoreText code on iOS and I am confused as to why this is an overrelease of the CTFrame. I have confirmed it is an over-release but I am baffled because it is created with a create
method.
for (NSValue *value in [self frameArray]) {
CGRect column = [value CGRectValue];
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddRect(path, NULL, column);
CTFrameRef frame = CTFramesetterCreateFrame(bodyFramesetter, CFRangeMake(position, 0), path, NULL);
CTFrameDraw(frame, context);
position += CTFrameGetVisibleStringRange(frame).length;
CGPathRelease(path);
// ???: Why does this cause an overrelease?
//CFRelease(frame);
}
Update
The code base is 3.2 and the crash does not occur on the first release. It occurs "randomly" at some point while drawing the view. This loop, as you can probably guess is in the -drawRect:
of the view. There is no multi-threading in this application.
结果发现Jason在正确的轨道上,并且问题是将一个空框架设置器传递给CTFramesetterCreateFrame
函数,然后返回NULL。
That's because your drawRect:
method gets called in the end of run loop. That's why your app crashes randomly.
So your solution is to create global link to CTFrame
object and release that object only in dealloc
and when you're creating other CTFrame
object (and replacing your global link).
上一篇: 为Android设置一台电脑蓝牙服务器
下一篇: 为什么这是一个结束