* ThreadListView:

- Got rid of superfluous SetTeam().
  - Aded SetThread() to select a thread.
* TeamWindow: When a thread hits a debug event and no thread is selected or
  the selected thread is running, select the stopped thread and switch to the
  "Threads" tab view.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31390 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-07-03 12:25:09 +00:00
parent 4e23bc0383
commit e59fc195db
3 changed files with 65 additions and 31 deletions

View File

@ -27,6 +27,12 @@
#include "StackTraceView.h"
enum {
MAIN_TAB_INDEX_THREADS = 0,
MAIN_TAB_INDEX_IMAGES = 1
};
// #pragma mark - TeamWindow
@ -286,6 +292,8 @@ function, function->GetSourceCode(), function->SourceCodeState());
void
TeamWindow::_Init()
{
::Team* team = fDebugModel->GetTeam();
BScrollView* sourceScrollView;
BLayoutBuilder::Group<>(this, B_VERTICAL)
@ -317,7 +325,7 @@ TeamWindow::_Init()
threadGroup->SetName("Threads");
fTabView->AddTab(threadGroup);
BLayoutBuilder::Split<>(threadGroup)
.Add(fThreadListView = ThreadListView::Create(this))
.Add(fThreadListView = ThreadListView::Create(team, this))
.Add(fStackTraceView = StackTraceView::Create(this));
// add images tab
@ -325,8 +333,7 @@ TeamWindow::_Init()
imagesGroup->SetName("Images");
fTabView->AddTab(imagesGroup);
BLayoutBuilder::Split<>(imagesGroup)
.Add(fImageListView = ImageListView::Create(fDebugModel->GetTeam(),
this))
.Add(fImageListView = ImageListView::Create(team, this))
.Add(fImageFunctionsView = ImageFunctionsView::Create(this));
// add local variables tab
@ -337,8 +344,6 @@ TeamWindow::_Init()
tab = fRegisterView = RegisterView::Create(fDebugModel->GetArchitecture());
fLocalsTabView->AddTab(tab);
fThreadListView->SetTeam(fDebugModel->GetTeam());
fRunButton->SetMessage(new BMessage(MSG_THREAD_RUN));
fStepOverButton->SetMessage(new BMessage(MSG_THREAD_STEP_OVER));
fStepIntoButton->SetMessage(new BMessage(MSG_THREAD_STEP_INTO));
@ -377,6 +382,8 @@ TeamWindow::_SetActiveThread(::Thread* thread)
locker.Unlock();
fThreadListView->SetThread(fActiveThread);
_SetActiveStackTrace(stackTrace);
_UpdateCpuState();
}
@ -597,11 +604,28 @@ TeamWindow::_UpdateRunButtons()
void
TeamWindow::_HandleThreadStateChanged(thread_id threadID)
{
// ATM we're only interested in the currently selected thread
if (fActiveThread == NULL || threadID != fActiveThread->ID())
AutoLocker<TeamDebugModel> locker(fDebugModel);
::Thread* thread = fDebugModel->GetTeam()->ThreadByID(threadID);
if (thread == NULL)
return;
AutoLocker<TeamDebugModel> locker(fDebugModel);
// If the thread has been stopped and we don't have an active thread yet
// (or it isn't stopped), switch to this thread. Otherwise ignore the event.
if (thread->State() == THREAD_STATE_STOPPED
&& (fActiveThread == NULL
|| (thread != fActiveThread
&& fActiveThread->State() != THREAD_STATE_STOPPED))) {
_SetActiveThread(thread);
} else if (thread != fActiveThread) {
// otherwise ignore the event, if the thread is not the active one
return;
}
// Switch to the threads tab view when the thread has stopped.
if (thread->State() == THREAD_STATE_STOPPED)
fTabView->Select(MAIN_TAB_INDEX_THREADS);
_UpdateRunButtons();
}

View File

@ -129,10 +129,11 @@ private:
// #pragma mark - ThreadListView
ThreadListView::ThreadListView(Listener* listener)
ThreadListView::ThreadListView(Team* team, Listener* listener)
:
BGroupView(B_VERTICAL),
fTeam(NULL),
fTeam(team),
fThread(NULL),
fThreadsTable(NULL),
fThreadsTableModel(NULL),
fListener(listener)
@ -143,16 +144,16 @@ ThreadListView::ThreadListView(Listener* listener)
ThreadListView::~ThreadListView()
{
SetTeam(NULL);
fTeam->RemoveListener(this);
fThreadsTable->SetTableModel(NULL);
delete fThreadsTableModel;
}
/*static*/ ThreadListView*
ThreadListView::Create(Listener* listener)
ThreadListView::Create(Team* team, Listener* listener)
{
ThreadListView* self = new ThreadListView(listener);
ThreadListView* self = new ThreadListView(team, listener);
try {
self->_Init();
@ -173,26 +174,29 @@ ThreadListView::UnsetListener()
void
ThreadListView::SetTeam(Team* team)
ThreadListView::SetThread(Thread* thread)
{
if (team == fTeam)
if (thread == fThread)
return;
if (fTeam != NULL) {
fTeam->RemoveListener(this);
fThreadsTable->SetTableModel(NULL);
delete fThreadsTableModel;
fThreadsTableModel = NULL;
if (fThread != NULL)
fThread->ReleaseReference();
fThread = thread;
if (fThread != NULL) {
fThread->AcquireReference();
for (int32 i = 0; Thread* other = fThreadsTableModel->ThreadAt(i);
i++) {
if (fThread == other) {
fThreadsTable->SelectRow(i, false);
return;
}
}
}
fTeam = team;
if (fTeam != NULL) {
fThreadsTableModel = new(std::nothrow) ThreadsTableModel(fTeam);
fThreadsTable->SetTableModel(fThreadsTableModel);
fThreadsTable->ResizeAllColumnsToPreferred();
fTeam->AddListener(this);
}
fThreadsTable->DeselectAllRows();
}
@ -256,6 +260,11 @@ ThreadListView::_Init()
fThreadsTable->SetSelectionMode(B_SINGLE_SELECTION_LIST);
fThreadsTable->AddTableListener(this);
fThreadsTableModel = new(std::nothrow) ThreadsTableModel(fTeam);
fThreadsTable->SetTableModel(fThreadsTableModel);
fThreadsTable->ResizeAllColumnsToPreferred();
fTeam->AddListener(this);
}

View File

@ -20,15 +20,15 @@ public:
class Listener;
public:
ThreadListView(Listener* listener);
ThreadListView(Team* team, Listener* listener);
~ThreadListView();
static ThreadListView* Create(Listener* listener);
static ThreadListView* Create(Team* team, Listener* listener);
// throws
void UnsetListener();
void SetTeam(Team* team);
void SetThread(Thread* thread);
virtual void MessageReceived(BMessage* message);
@ -47,6 +47,7 @@ private:
private:
Team* fTeam;
Thread* fThread;
Table* fThreadsTable;
ThreadsTableModel* fThreadsTableModel;
Listener* fListener;