嘿。我有一个非常简单的文本输出到缓冲区系统,它会随机崩溃。对于DAYS会很好,然后有时会在几分钟内崩溃几次。调用堆栈是几乎完全对谁使用更高级别的控制其他人一样: http://discussions.apple.com/thread.jspa?messageID=7949746 iPhone app crashed: Assertion failed function evict_glyph_entry_from_strike, file Fonts/CGFontCache.cNSString drawAtPoint iPhone上的崩溃(NSString drawAtPoint)
它崩溃的线(以下以及在drawTextToBuffer()): [的NSString drawAtPoint:CGPointMake(0,0) withFont:clFont];
我有同样的调用“evict_glyph_entry_from_cache”与紧接其后的中止调用。
显然它发生在其他人身上。我可以说我的NSString *在崩溃时非常好。我可以很好地从调试器中读取文本。
static CGColorSpaceRef curColorSpace;
static CGContextRef myContext;
static float w, h;
static int iFontSize;
static NSString* sFontName;
static UIFont* clFont;
static int iLineHeight;
unsigned long* txb; /* 256x256x4 Buffer */
void selectFont(int iSize, NSString* sFont)
{
iFontSize = iSize;
clFont = [UIFont fontWithName:sFont size:iFontSize];
iLineHeight = (int)(ceil([clFont capHeight]));
}
void initText()
{
w = 256;
h = 256;
txb = (unsigned long*)malloc_(w * h * 4);
curColorSpace = CGColorSpaceCreateDeviceRGB();
myContext = CGBitmapContextCreate(txb, w, h, 8, w * 4, curColorSpace, kCGImageAlphaPremultipliedLast);
selectFont(12, @"Helvetica");
}
void drawTextToBuffer(NSString* nsString)
{
CGContextSaveGState(myContext);
CGContextSetRGBFillColor(myContext, 1, 1, 1, 1);
UIGraphicsPushContext(myContext);
/* This line will crash. It crashes even with constant Strings.. At the time of the crash, the pointer to nsString is perfectly fine. The data looks fine! */
[nsString drawAtPoint:CGPointMake(0, 0) withFont:clFont];
UIGraphicsPopContext();
CGContextRestoreGState(myContext);
}
它会发生在其他非Unicode支持方法,如CGContextShowTextAtPoint();这个callstack也是类似的。
这是iPhone上的任何一种已知问题吗?或者,也许,这个原因之外的东西可能会在这个特定的调用(drawAtPoint)中导致异常?
感谢您的快速回答。我会试试看! – Kyle 2010-04-02 07:52:36