Fix roster crash w/o protocol icon

This commit is contained in:
Jaidyn Ann 2021-07-02 13:47:01 -05:00
parent 58e3d99af5
commit 7db93bf596

View File

@ -91,7 +91,8 @@ RosterItem::ObserveInteger(int32 what, int32 val)
} }
void RosterItem::DrawItem(BView* owner, BRect frame, bool complete) void
RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
{ {
if (Text() == NULL) if (Text() == NULL)
return; return;
@ -136,6 +137,7 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
frame.left + 5, frame.top + h - 1 frame.left + 5, frame.top + h - 1
)); ));
// Draw avatar icon // Draw avatar icon
if (fBitmap != NULL) { if (fBitmap != NULL) {
BRect rect(frame.left + 6, frame.top, BRect rect(frame.left + 6, frame.top,
@ -167,12 +169,14 @@ void RosterItem::DrawItem(BView* owner, BRect frame, bool complete)
// Draw protocol bitmpap // Draw protocol bitmpap
BBitmap* protocolBitmap = contactLinker->ProtocolBitmap(); BBitmap* protocolBitmap = contactLinker->ProtocolBitmap();
if (protocolBitmap != NULL) {
BRect rect(frame.right - 19, frame.top + 2, BRect rect(frame.right - 19, frame.top + 2,
frame.right - 2, frame.top + 19 );; frame.right - 2, frame.top + 19 );;
owner->SetDrawingMode(B_OP_ALPHA); owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(protocolBitmap, protocolBitmap->Bounds(), owner->DrawBitmap(protocolBitmap, protocolBitmap->Bounds(),
rect, B_FILTER_BITMAP_BILINEAR); rect, B_FILTER_BITMAP_BILINEAR);
}
owner->SetHighColor(highColor); owner->SetHighColor(highColor);
owner->SetLowColor(lowColor); owner->SetLowColor(lowColor);