From 5891e232e27afd5850a6e757cf1826b07eeaeb9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 1 Mar 2006 17:39:08 +0000 Subject: [PATCH] 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 --- src/kits/interface/BTextView/TextView.cpp | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/kits/interface/BTextView/TextView.cpp b/src/kits/interface/BTextView/TextView.cpp index afabbfb1f7..e5642910a4 100644 --- a/src/kits/interface/BTextView/TextView.cpp +++ b/src/kits/interface/BTextView/TextView.cpp @@ -1512,25 +1512,28 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode, const rgb_color * void -BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont *inFont, - uint32 inMode, const rgb_color *inColor) +BTextView::SetFontAndColor(int32 startOffset, int32 endOffset, const BFont* font, + uint32 fontMode, const rgb_color* color) { CALLED(); - - BFont newFont = *inFont; - NormalizeFont(&newFont); - + + BFont newFont; + if (font != NULL) { + newFont = font; + NormalizeFont(&newFont); + } + // add the style to the style buffer fStyles->SetStyleRange(startOffset, endOffset, fText->Length(), - inMode, &newFont, inColor); - - if (inMode & B_FONT_FAMILY_AND_STYLE || inMode & B_FONT_SIZE) + fontMode, &newFont, color); + + if (fontMode & B_FONT_FAMILY_AND_STYLE || fontMode & B_FONT_SIZE) { // recalc the line breaks and redraw with new style Refresh(startOffset, endOffset, startOffset != endOffset, false); - else + } else { // the line breaks wont change, simply redraw DrawLines(LineAt(startOffset), LineAt(endOffset), startOffset, true); - + } }