Made Team BReferenceable. Since teams are usually destroyed before their main

thread, we were accessing already destroyed Team objects.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35591 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-02-23 20:37:36 +00:00
parent de699cf2f1
commit 7506431527
3 changed files with 12 additions and 4 deletions

View File

@ -9,6 +9,7 @@
#include <debug_support.h>
#include <ObjectList.h>
#include <Referenceable.h>
#include <util/DoublyLinkedList.h>
#include "Thread.h"
@ -19,7 +20,7 @@ class SharedImage;
struct system_profiler_team_added;
class Team {
class Team : public BReferenceable {
public:
Team();
~Team();

View File

@ -51,6 +51,7 @@ Thread::Thread(thread_id threadID, const char* name, Team* team)
fProfileResult(NULL),
fLazyImages(true)
{
fTeam->AcquireReference();
}
@ -66,6 +67,8 @@ Thread::~Thread()
delete image;
while (ThreadImage* image = fOldImages.RemoveHead())
delete image;
fTeam->ReleaseReference();
}

View File

@ -101,7 +101,7 @@ class ThreadManager : private ProfiledEntity {
public:
ThreadManager(port_id debuggerPort)
:
fTeams(20, true),
fTeams(20),
fThreads(20, true),
fKernelTeam(NULL),
fDebuggerPort(debuggerPort),
@ -117,6 +117,9 @@ public:
if (fSummaryProfileResult != NULL)
fSummaryProfileResult->ReleaseReference();
for (int32 i = 0; Team* team = fTeams.ItemAt(i); i++)
team->ReleaseReference();
}
status_t Init()
@ -193,7 +196,8 @@ public:
if (Team* team = FindTeam(teamID)) {
if (team == fKernelTeam)
fKernelTeam = NULL;
fTeams.RemoveItem(team, true);
fTeams.RemoveItem(team);
team->ReleaseReference();
}
}
@ -308,7 +312,7 @@ private:
? _InitUndebuggedTeam(team, addedInfo)
: _InitDebuggedTeam(team, teamID);
if (error != B_OK) {
delete team;
team->ReleaseReference();
return error;
}