From 2898a353e291bcec81146d513edcef221f3da90a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 17 Jun 2009 13:45:07 +0000 Subject: [PATCH] Use a less lazy method to update the threads list view (use the table model listener mechanism to inform about the exact changes instead of rebuilding the complete list). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31084 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../gui/team_window/ThreadListView.cpp | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/apps/debugger/gui/team_window/ThreadListView.cpp b/src/apps/debugger/gui/team_window/ThreadListView.cpp index ebff1a72d5..6785940118 100644 --- a/src/apps/debugger/gui/team_window/ThreadListView.cpp +++ b/src/apps/debugger/gui/team_window/ThreadListView.cpp @@ -43,23 +43,47 @@ public: bool Update() { - for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++) - thread->RemoveReference(); - fThreads.MakeEmpty(); + if (fTeam == NULL) { + for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++) + thread->RemoveReference(); + fThreads.MakeEmpty(); - if (fTeam == NULL) return true; + } AutoLocker locker(fTeam); - for (ThreadList::ConstIterator it = fTeam->Threads().GetIterator(); - Thread* thread = it.Next();) { - if (!fThreads.AddItem(thread)) + ThreadList::ConstIterator it = fTeam->Threads().GetIterator(); + Thread* newThread = it.Next(); + int32 index = 0; + + // remove no longer existing threads + while (Thread* oldThread = fThreads.ItemAt(index)) { + if (oldThread == newThread) { + index++; + newThread = it.Next(); + } else { + // TODO: Not particularly efficient! + fThreads.RemoveItemAt(index); + oldThread->RemoveReference(); + NotifyRowsRemoved(index, 1); + } + } + + // add new threads + int32 countBefore = fThreads.CountItems(); + while (newThread != NULL) { + if (!fThreads.AddItem(newThread)) return false; - thread->AddReference(); + newThread->AddReference(); + newThread = it.Next(); } + int32 count = fThreads.CountItems(); + if (count > countBefore) + NotifyRowsAdded(countBefore, count - countBefore); + return true; } @@ -169,11 +193,8 @@ ThreadListView::MessageReceived(BMessage* message) { switch (message->what) { case MSG_SYNC_THREAD_LIST: - if (fThreadsTableModel != NULL) { - fThreadsTable->SetTableModel(NULL); + if (fThreadsTableModel != NULL) fThreadsTableModel->Update(); - fThreadsTable->SetTableModel(fThreadsTableModel); - } break; default: BGroupView::MessageReceived(message);