diff --git a/src/apps/debugger/TeamDebugger.cpp b/src/apps/debugger/TeamDebugger.cpp index 4f3caa5415..f0853fb296 100644 --- a/src/apps/debugger/TeamDebugger.cpp +++ b/src/apps/debugger/TeamDebugger.cpp @@ -707,39 +707,56 @@ TeamDebugger::InspectRequested(target_addr_t address, bool -TeamDebugger::UserInterfaceQuitRequested() +TeamDebugger::UserInterfaceQuitRequested(QuitOption quitOption) { - AutoLocker< ::Team> locker(fTeam); - BString name(fTeam->Name()); - locker.Unlock(); + bool askUser = false; + switch (quitOption) { + case QUIT_OPTION_ASK_USER: + askUser = true; + break; - 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; - - int32 choice = fUserInterface->SynchronouslyAskUser("Quit Debugger", - message, killLabel, "Cancel", resumeLabel); - - switch (choice) { - case 0: + case QUIT_OPTION_ASK_KILL_TEAM: fKillTeamOnQuit = true; break; - case 1: - return false; - case 2: - // Detach from the team and resume and stopped threads. + + case QUIT_OPTION_ASK_RESUME_TEAM: break; } + if (askUser) { + AutoLocker< ::Team> locker(fTeam); + BString name(fTeam->Name()); + locker.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; + + int32 choice = fUserInterface->SynchronouslyAskUser("Quit Debugger", + message, killLabel, "Cancel", resumeLabel); + + switch (choice) { + case 0: + fKillTeamOnQuit = true; + break; + case 1: + case -1: + return false; + case 2: + // Detach from the team and resume and stopped threads. + break; + } + } + PostMessage(B_QUIT_REQUESTED); return true; diff --git a/src/apps/debugger/TeamDebugger.h b/src/apps/debugger/TeamDebugger.h index 468c243abf..189a448fc1 100644 --- a/src/apps/debugger/TeamDebugger.h +++ b/src/apps/debugger/TeamDebugger.h @@ -69,7 +69,8 @@ private: UserBreakpoint* breakpoint); virtual void InspectRequested(target_addr_t address, TeamMemoryBlock::Listener* listener); - virtual bool UserInterfaceQuitRequested(); + virtual bool UserInterfaceQuitRequested( + QuitOption quitOption); // JobListener virtual void JobDone(Job* job); diff --git a/src/apps/debugger/user_interface/UserInterface.h b/src/apps/debugger/user_interface/UserInterface.h index 054aba752a..2f69266a02 100644 --- a/src/apps/debugger/user_interface/UserInterface.h +++ b/src/apps/debugger/user_interface/UserInterface.h @@ -61,10 +61,19 @@ public: const char* message, const char* choice1, const char* choice2, const char* choice3) = 0; + // returns -1, if not implemented or user + // cannot be asked }; class UserInterfaceListener { +public: + enum QuitOption { + QUIT_OPTION_ASK_USER, + QUIT_OPTION_ASK_KILL_TEAM, + QUIT_OPTION_ASK_RESUME_TEAM + }; + public: virtual ~UserInterfaceListener(); @@ -95,7 +104,9 @@ public: target_addr_t address, TeamMemoryBlock::Listener* listener) = 0; - virtual bool UserInterfaceQuitRequested() = 0; + virtual bool UserInterfaceQuitRequested( + QuitOption quitOption + = QUIT_OPTION_ASK_USER) = 0; }; diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index a381d676a9..9e27749494 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -207,7 +207,7 @@ CommandLineUserInterface::SynchronouslyAskUser(const char* title, const char* message, const char* choice1, const char* choice2, const char* choice3) { - return 0; + return -1; }