Filled up the quitting code path a bit. The TeamDebugger throws up an alert

asking what to do with the debugged team. Killing it is not yet implemented.
Then it notifies the application about the quit request. That in turn tears
down the TeamDebugger and if no other ones are left, it quits itself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31201 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-06-23 12:14:05 +00:00
parent 73b8cef5e6
commit 04743aeb5f
3 changed files with 74 additions and 2 deletions
+15 -1
View File
@@ -177,6 +177,19 @@ public:
virtual void MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_DEBUGGER_QUIT_REQUESTED:
{
TeamDebugger* debugger = NULL;
if (message->FindPointer("debugger",
(void**)&debugger) == B_OK
&& fTeamDebuggers.HasItem(debugger)) {
fTeamDebuggers.RemoveItem(debugger);
debugger->DeleteSelf();
if (fTeamDebuggers.CountItems() == 0)
PostMessage(B_QUIT_REQUESTED);
}
break;
}
default:
BApplication::MessageReceived(message);
break;
@@ -257,7 +270,8 @@ printf("debugger for team %ld created and initialized successfully!\n", team);
virtual bool QuitRequested()
{
// TODO:...
return true;
// return true;
return BApplication::QuitRequested();
}
private:
+53 -1
View File
@@ -11,6 +11,7 @@
#include <new>
#include <Alert.h>
#include <Application.h>
#include <Message.h>
#include <AutoLocker.h>
@@ -183,6 +184,14 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
}
void
TeamDebugger::DeleteSelf()
{
Lock();
Quit();
}
void
TeamDebugger::MessageReceived(BMessage* message)
{
@@ -310,7 +319,50 @@ TeamDebugger::ClearBreakpointRequested(target_addr_t address)
bool
TeamDebugger::TeamWindowQuitRequested(TeamWindow* window)
{
// TODO:...
// TODO: Is this what shall happen?
if (!fTeam->Lock())
return true;
BString name(fTeam->Name());
fTeam->Unlock();
BString message;
message << "What shall be done about the debugged team '";
message << name;
message << "'?";
name.Remove(0, name.FindLast('/') + 1);
BString killLabel("Kill ");
killLabel << name;
BString resumeLabel("Resume ");
resumeLabel << name;
BAlert* alert = new BAlert("Quit Debugger", message.String(),
killLabel.String(), "Cancel", resumeLabel.String());
switch (alert->Go()) {
case 0:
// TODO: Implement killing the team.
alert = new BAlert("TODO", "That is not nice and I won't do it "
"either! Test failed. Nice to know how you think about these "
"matters.", "Ugh!");
alert->Go();
break;
case 1:
return false;
case 2:
// Detach from the team and resume and stopped threads. Seems to be
// the default action anyways.
break;
}
BMessage quitMessage(MSG_DEBUGGER_QUIT_REQUESTED);
quitMessage.AddPointer("debugger", this);
be_app->PostMessage(&quitMessage);
return true;
}
+6
View File
@@ -19,6 +19,10 @@
class DebuggerInterface;
class TeamDebugModel;
enum {
MSG_DEBUGGER_QUIT_REQUESTED = 'dbqt'
};
class TeamDebugger : private BLooper, private TeamWindow::Listener,
private JobListener, private Team::Listener {
@@ -31,6 +35,8 @@ public:
team_id TeamID() const { return fTeamID; }
void DeleteSelf();
private:
virtual void MessageReceived(BMessage* message);