Debugger: Change user interface quit and ask user semantics

* UserInterface::SynchronouslyAskUser() is now allowed to return -1 to
  indicate that the user cannot be asked at this point for whatever
  reason. The caller needs to handle that case.
* UserInterfaceListener::UserInterfaceQuitRequested(): Add new parameter
  "quitOption" to specify what is supposed to happen. The previous
  behavior (ask user) is only one of the options. The others are to kill
  the debugged team or to resume it.
This commit is contained in:
Ingo Weinhold
2012-07-27 23:42:01 +02:00
parent f58478507c
commit eba38eb503
4 changed files with 58 additions and 29 deletions
+18 -1
View File
@@ -707,8 +707,23 @@ TeamDebugger::InspectRequested(target_addr_t address,
bool bool
TeamDebugger::UserInterfaceQuitRequested() TeamDebugger::UserInterfaceQuitRequested(QuitOption quitOption)
{ {
bool askUser = false;
switch (quitOption) {
case QUIT_OPTION_ASK_USER:
askUser = true;
break;
case QUIT_OPTION_ASK_KILL_TEAM:
fKillTeamOnQuit = true;
break;
case QUIT_OPTION_ASK_RESUME_TEAM:
break;
}
if (askUser) {
AutoLocker< ::Team> locker(fTeam); AutoLocker< ::Team> locker(fTeam);
BString name(fTeam->Name()); BString name(fTeam->Name());
locker.Unlock(); locker.Unlock();
@@ -734,11 +749,13 @@ TeamDebugger::UserInterfaceQuitRequested()
fKillTeamOnQuit = true; fKillTeamOnQuit = true;
break; break;
case 1: case 1:
case -1:
return false; return false;
case 2: case 2:
// Detach from the team and resume and stopped threads. // Detach from the team and resume and stopped threads.
break; break;
} }
}
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
+2 -1
View File
@@ -69,7 +69,8 @@ private:
UserBreakpoint* breakpoint); UserBreakpoint* breakpoint);
virtual void InspectRequested(target_addr_t address, virtual void InspectRequested(target_addr_t address,
TeamMemoryBlock::Listener* listener); TeamMemoryBlock::Listener* listener);
virtual bool UserInterfaceQuitRequested(); virtual bool UserInterfaceQuitRequested(
QuitOption quitOption);
// JobListener // JobListener
virtual void JobDone(Job* job); virtual void JobDone(Job* job);
@@ -61,10 +61,19 @@ public:
const char* message, const char* choice1, const char* message, const char* choice1,
const char* choice2, const char* choice3) const char* choice2, const char* choice3)
= 0; = 0;
// returns -1, if not implemented or user
// cannot be asked
}; };
class UserInterfaceListener { class UserInterfaceListener {
public:
enum QuitOption {
QUIT_OPTION_ASK_USER,
QUIT_OPTION_ASK_KILL_TEAM,
QUIT_OPTION_ASK_RESUME_TEAM
};
public: public:
virtual ~UserInterfaceListener(); virtual ~UserInterfaceListener();
@@ -95,7 +104,9 @@ public:
target_addr_t address, target_addr_t address,
TeamMemoryBlock::Listener* listener) = 0; TeamMemoryBlock::Listener* listener) = 0;
virtual bool UserInterfaceQuitRequested() = 0; virtual bool UserInterfaceQuitRequested(
QuitOption quitOption
= QUIT_OPTION_ASK_USER) = 0;
}; };
@@ -207,7 +207,7 @@ CommandLineUserInterface::SynchronouslyAskUser(const char* title,
const char* message, const char* choice1, const char* choice2, const char* message, const char* choice1, const char* choice2,
const char* choice3) const char* choice3)
{ {
return 0; return -1;
} }