mirror of https://github.com/axmolengine/axmol.git
fix possible crash of label shrinked (#16456)
This commit is contained in:
parent
df3b33cd59
commit
0b1f61b8ce
|
@ -129,6 +129,10 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS
|
||||||
while (actualSize.size.width > constrainSize.width ||
|
while (actualSize.size.width > constrainSize.width ||
|
||||||
actualSize.size.height > constrainSize.height) {
|
actualSize.size.height > constrainSize.height) {
|
||||||
fontSize = fontSize - 1;
|
fontSize = fontSize - 1;
|
||||||
|
if (fontSize < 0) {
|
||||||
|
actualSize = CGRectMake(0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
|
NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
|
||||||
*str = __attributedStringWithFontSize(mutableString, fontSize);
|
*str = __attributedStringWithFontSize(mutableString, fontSize);
|
||||||
|
@ -162,6 +166,10 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS
|
||||||
while (actualSize.size.height > constrainSize.height
|
while (actualSize.size.height > constrainSize.height
|
||||||
||actualSize.size.width > constrainSize.width) {
|
||actualSize.size.width > constrainSize.width) {
|
||||||
fontSize = fontSize - 1;
|
fontSize = fontSize - 1;
|
||||||
|
if (fontSize < 0) {
|
||||||
|
actualSize = CGRectMake(0, 0, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
|
NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease];
|
||||||
*str = __attributedStringWithFontSize(mutableString, fontSize);
|
*str = __attributedStringWithFontSize(mutableString, fontSize);
|
||||||
|
|
Loading…
Reference in New Issue