[Haiku-commits] r31084 - haiku/trunk/src/apps/debugger/gui/team_window

bonefish at mail.berlios.de bonefish at mail.berlios.de
Wed Jun 17 15:46:13 CEST 2009


Author: bonefish
Date: 2009-06-17 15:45:07 +0200 (Wed, 17 Jun 2009)
New Revision: 31084
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31084&view=rev

Modified:
   haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp
Log:
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).


Modified: haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp	2009-06-17 13:40:10 UTC (rev 31083)
+++ haiku/trunk/src/apps/debugger/gui/team_window/ThreadListView.cpp	2009-06-17 13:45:07 UTC (rev 31084)
@@ -43,23 +43,47 @@
 
 	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<Team> 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 @@
 {
 	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);




More information about the Haiku-commits mailing list