When you kill an item, it is no longer active.

TMBox::Pulse() will now only invalidate the view if something changed - this
completely removes the flickering that was visible with our app_server.
Fixed typo.
Added a ToDo comment since TMDescView::fItem is not correctly updated.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13144 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-06-15 05:39:39 +00:00
parent d145df451e
commit 9695be8f49
@@ -115,6 +115,7 @@ TMWindow::MessageReceived(BMessage *msg)
fBackground->fListView->CurrentSelection()); fBackground->fListView->CurrentSelection());
kill_team(item->GetInfo()->team); kill_team(item->GetInfo()->team);
fKillApp->SetEnabled(false); fKillApp->SetEnabled(false);
fDescView->SetItem(NULL);
} }
break; break;
case TM_SELECTED_TEAM: { case TM_SELECTED_TEAM: {
@@ -193,14 +194,15 @@ void
TMBox::Pulse() TMBox::Pulse()
{ {
CALLED(); CALLED();
int32 cookie = 0; bool changed = false;
team_info info;
for (int32 i = 0; i < fListView->CountItems(); i++) { for (int32 i = 0; i < fListView->CountItems(); i++) {
TMListItem *item = (TMListItem*)fListView->ItemAt(i); TMListItem *item = (TMListItem*)fListView->ItemAt(i);
item->fFound = false; item->fFound = false;
} }
int32 cookie = 0;
team_info info;
while (get_next_team_info(&cookie, &info) == B_OK) { while (get_next_team_info(&cookie, &info) == B_OK) {
if (info.team <=16) if (info.team <=16)
continue; continue;
@@ -218,16 +220,20 @@ TMBox::Pulse()
TMListItem *item = new TMListItem(info); TMListItem *item = new TMListItem(info);
fListView->AddItem(item, 0); fListView->AddItem(item, 0);
item->fFound = true; item->fFound = true;
changed = true;
} }
} }
for (int32 i = fListView->CountItems() - 1; i >= 0; i--) { for (int32 i = fListView->CountItems() - 1; i >= 0; i--) {
TMListItem *item = (TMListItem*)fListView->ItemAt(i); TMListItem *item = (TMListItem*)fListView->ItemAt(i);
if (!item->fFound) if (!item->fFound) {
delete fListView->RemoveItem(i); delete fListView->RemoveItem(i);
changed = true;
}
} }
fListView->Invalidate(); if (changed)
fListView->Invalidate();
} }
@@ -244,6 +250,9 @@ TMDescView::TMDescView(BRect rect)
void void
TMDescView::Draw(BRect rect) TMDescView::Draw(BRect rect)
{ {
// Accessing fItem this way is not a good idea, since it's not correctly
// updated - if the team goes away in the meantime, we're doomed to crash
// (the item could have been deleted in TMBox::Pulse())
if (fItem) { if (fItem) {
BRect frame(rect); BRect frame(rect);
frame.OffsetBy(2,3); frame.OffsetBy(2,3);
@@ -263,7 +272,7 @@ TMDescView::Draw(BRect rect)
if (fItem->IsSystemServer()) { if (fItem->IsSystemServer()) {
MovePenTo(frame.right+9, frame.top + 1 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) *3 / 4) + MovePenTo(frame.right+9, frame.top + 1 + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) *3 / 4) +
(finfo.ascent + finfo.descent) - 1); (finfo.ascent + finfo.descent) - 1);
DrawString("(This team is a system component"); DrawString("(This team is a system component)");
} }
} else { } else {
BFont font = be_plain_font; BFont font = be_plain_font;