Avoid macOS debug messages about invalid glyph index
Don't use NSLayoutManager lineFragmentRectForGlyphAtIndex:effectiveRange when NSTextView is empty, as this result in debug error messages. Fall back to using the font height in this case instead, as this seems to be the only thing to do in this case. Closes #18793.
This commit is contained in:
@@ -1235,9 +1235,20 @@ wxSize wxNSTextViewControl::GetBestSize() const
|
|||||||
// any non-empty control) and then multiply it by the number of lines
|
// any non-empty control) and then multiply it by the number of lines
|
||||||
// we want to have by default, which is currently just hardcoded as 5
|
// we want to have by default, which is currently just hardcoded as 5
|
||||||
// for compatibility with the behaviour of the previous versions.
|
// for compatibility with the behaviour of the previous versions.
|
||||||
NSRect rect = [layoutManager lineFragmentRectForGlyphAtIndex: 0
|
CGFloat height;
|
||||||
effectiveRange: nil];
|
if ( [[m_textView string] length] )
|
||||||
size.y = (int)(5*rect.size.height + [m_textView textContainerInset].height);
|
{
|
||||||
|
NSRect rect = [layoutManager lineFragmentRectForGlyphAtIndex: 0
|
||||||
|
effectiveRange: nil];
|
||||||
|
height = rect.size.height;
|
||||||
|
}
|
||||||
|
else // The control is empty.
|
||||||
|
{
|
||||||
|
// Not really clear what else could we use here.
|
||||||
|
height = GetWXPeer()->GetCharHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
size.y = (int)(5*height + [m_textView textContainerInset].height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
Reference in New Issue
Block a user