BTextView::SetFontAndColor() no longer crashes with a NULL font pointer.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16560 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1512,25 +1512,28 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode, const rgb_color *
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont *inFont,
|
BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font,
|
||||||
uint32 inMode, const rgb_color *inColor)
|
uint32 fontMode, const rgb_color* color)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
BFont newFont = *inFont;
|
BFont newFont;
|
||||||
NormalizeFont(&newFont);
|
if (font != NULL) {
|
||||||
|
newFont = font;
|
||||||
|
NormalizeFont(&newFont);
|
||||||
|
}
|
||||||
|
|
||||||
// add the style to the style buffer
|
// add the style to the style buffer
|
||||||
fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
|
fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
|
||||||
inMode, &newFont, inColor);
|
fontMode, &newFont, color);
|
||||||
|
|
||||||
if (inMode & B_FONT_FAMILY_AND_STYLE || inMode & B_FONT_SIZE)
|
if (fontMode & B_FONT_FAMILY_AND_STYLE || fontMode & B_FONT_SIZE) {
|
||||||
// recalc the line breaks and redraw with new style
|
// recalc the line breaks and redraw with new style
|
||||||
Refresh(startOffset, endOffset, startOffset != endOffset, false);
|
Refresh(startOffset, endOffset, startOffset != endOffset, false);
|
||||||
else
|
} else {
|
||||||
// the line breaks wont change, simply redraw
|
// the line breaks wont change, simply redraw
|
||||||
DrawLines(LineAt(startOffset), LineAt(endOffset), startOffset, true);
|
DrawLines(LineAt(startOffset), LineAt(endOffset), startOffset, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user