From d0f646a9adf0eeaf4dfd347f598ee114fa465282 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 5 Jan 2016 15:38:56 +0000 Subject: [PATCH] Fix for a problem with CoreText when laying out very long text strings --- modules/juce_graphics/native/juce_mac_Fonts.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/juce_graphics/native/juce_mac_Fonts.mm b/modules/juce_graphics/native/juce_mac_Fonts.mm index de1597b151..dcff0be5e8 100644 --- a/modules/juce_graphics/native/juce_mac_Fonts.mm +++ b/modules/juce_graphics/native/juce_mac_Fonts.mm @@ -219,10 +219,13 @@ namespace CoreTextTypeLayout CGColorSpaceRef rgbColourSpace = CGColorSpaceCreateDeviceRGB(); #endif - CFStringRef cfText = text.getText().toCFString(); CFMutableAttributedStringRef attribString = CFAttributedStringCreateMutable (kCFAllocatorDefault, 0); - CFAttributedStringReplaceString (attribString, CFRangeMake (0, 0), cfText); - CFRelease (cfText); + + if (CFStringRef cfText = text.getText().toCFString()) + { + CFAttributedStringReplaceString (attribString, CFRangeMake (0, 0), cfText); + CFRelease (cfText); + } const int numCharacterAttributes = text.getNumAttributes(); const CFIndex attribStringLen = CFAttributedStringGetLength (attribString);