diff --git a/headers/private/debugger/controllers/TeamDebugger.h b/headers/private/debugger/controllers/TeamDebugger.h index c1056ce804..f4b2258b4f 100644 --- a/headers/private/debugger/controllers/TeamDebugger.h +++ b/headers/private/debugger/controllers/TeamDebugger.h @@ -66,6 +66,8 @@ public: { return fCommandLineArgv; } SettingsManager* GetSettingsManager() const { return fSettingsManager; } + UserInterface* GetUserInterface() const + { return fUserInterface; } virtual void MessageReceived(BMessage* message); diff --git a/headers/private/debugger/user_interface/UserInterface.h b/headers/private/debugger/user_interface/UserInterface.h index 53f6a5baf2..17a7a16332 100644 --- a/headers/private/debugger/user_interface/UserInterface.h +++ b/headers/private/debugger/user_interface/UserInterface.h @@ -56,6 +56,13 @@ public: // shut down the UI *now* -- no more user // feedback + virtual UserInterface* Clone() const = 0; + // returns a new instance of the + // appropriate user interface subclass. + // primarily needed in order to + // reconstruct the necessary information + // for initiating a team restart. + virtual bool IsInteractive() const = 0; virtual status_t LoadSettings(const TeamUiSettings* settings) diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 47027d2ebd..28eefbf415 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -166,6 +166,13 @@ CommandLineUserInterface::Terminate() } +UserInterface* +CommandLineUserInterface::Clone() const +{ + return new(std::nothrow) CommandLineUserInterface; +} + + bool CommandLineUserInterface::IsInteractive() const { diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index e908e2dcd1..c6d68acfe0 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2015, Rene Gollent, rene@gollent.com. + * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -31,6 +31,8 @@ public: // shut down the UI *now* -- no more user // feedback + virtual UserInterface* Clone() const; + virtual bool IsInteractive() const; virtual status_t LoadSettings(const TeamUiSettings* settings); diff --git a/src/apps/debugger/user_interface/gui/GraphicalUserInterface.cpp b/src/apps/debugger/user_interface/gui/GraphicalUserInterface.cpp index 1ff85e9fa8..a6e50afdc9 100644 --- a/src/apps/debugger/user_interface/gui/GraphicalUserInterface.cpp +++ b/src/apps/debugger/user_interface/gui/GraphicalUserInterface.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011-2014, Rene Gollent, rene@gollent.com. + * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -194,6 +194,13 @@ GraphicalUserInterface::Terminate() } +UserInterface* +GraphicalUserInterface::Clone() const +{ + return new(std::nothrow) GraphicalUserInterface; +} + + bool GraphicalUserInterface::IsInteractive() const { diff --git a/src/apps/debugger/user_interface/gui/GraphicalUserInterface.h b/src/apps/debugger/user_interface/gui/GraphicalUserInterface.h index c86436f63c..d031fb373d 100644 --- a/src/apps/debugger/user_interface/gui/GraphicalUserInterface.h +++ b/src/apps/debugger/user_interface/gui/GraphicalUserInterface.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2014-2015, Rene Gollent, rene@gollent.com. + * Copyright 2014-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef GRAPHICAL_USER_INTERFACE_H @@ -30,6 +30,8 @@ public: // shut down the UI *now* -- no more user // feedback + virtual UserInterface* Clone() const; + virtual bool IsInteractive() const; virtual status_t LoadSettings(const TeamUiSettings* settings); diff --git a/src/apps/debugger/user_interface/report/ReportUserInterface.cpp b/src/apps/debugger/user_interface/report/ReportUserInterface.cpp index 57fcdf7534..d0dfda0162 100644 --- a/src/apps/debugger/user_interface/report/ReportUserInterface.cpp +++ b/src/apps/debugger/user_interface/report/ReportUserInterface.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015, Rene Gollent, rene@gollent.com. + * Copyright 2015-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -84,6 +84,15 @@ ReportUserInterface::Terminate() } +UserInterface* +ReportUserInterface::Clone() const +{ + // the report interface does not support cloning, since + // it won't ever be asked to interactively restart. + return NULL; +} + + bool ReportUserInterface::IsInteractive() const { diff --git a/src/apps/debugger/user_interface/report/ReportUserInterface.h b/src/apps/debugger/user_interface/report/ReportUserInterface.h index 8b06d30e3a..23ba082c4f 100644 --- a/src/apps/debugger/user_interface/report/ReportUserInterface.h +++ b/src/apps/debugger/user_interface/report/ReportUserInterface.h @@ -1,5 +1,5 @@ /* - * Copyright 2015, Rene Gollent, rene@gollent.com. + * Copyright 2015-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef REPORT_USER_INTERFACE_H @@ -27,6 +27,8 @@ public: virtual void Show(); virtual void Terminate(); + virtual UserInterface* Clone() const; + virtual bool IsInteractive() const; virtual status_t LoadSettings(const TeamUiSettings* settings); diff --git a/src/kits/debugger/target_host_interface/TargetHostInterface.cpp b/src/kits/debugger/target_host_interface/TargetHostInterface.cpp index d4034f3a9f..85b3d09d1b 100644 --- a/src/kits/debugger/target_host_interface/TargetHostInterface.cpp +++ b/src/kits/debugger/target_host_interface/TargetHostInterface.cpp @@ -184,13 +184,23 @@ TargetHostInterface::MessageReceived(BMessage* message) TeamDebugger* debugger = FindTeamDebugger(teamID); + UserInterface* userInterface = debugger->GetUserInterface()->Clone(); + if (userInterface == NULL) + break; + + BReference userInterfaceReference(userInterface, true); + TeamDebuggerOptions options; + options.requestType = TEAM_DEBUGGER_REQUEST_CREATE; options.commandLineArgc = debugger->ArgumentCount(); options.commandLineArgv = debugger->Arguments(); options.settingsManager = debugger->GetSettingsManager(); + options.userInterface = userInterface; status_t result = StartTeamDebugger(options); - if (result == B_OK) + if (result == B_OK) { + userInterfaceReference.Detach(); debugger->PostMessage(B_QUIT_REQUESTED); + } break; } default: