From 05fc1277c47440dc36134816d70e5723c99cfcd2 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 3 Jul 2016 13:47:32 -0400 Subject: [PATCH] Debugger: Fix team restart request. UserInterface: - Add Clone() function to set of required virtuals. This asks the subclass to create a new instance of its respective type. {CommandLine,Graphical,Report}UserInterface: - Implement the above function. TeamDebugger: - Add accessor for the currently active UI. TargetHostInterface: - Set correct request type when setting up the options for a team restart. - Ask the TeamDebugger for its user interface and clone it in order to fill in that aspect of the debug options. This fixes a regression introduced in commit 880a64, which inadvertently resulted in team restarts no longer working. --- headers/private/debugger/controllers/TeamDebugger.h | 2 ++ .../private/debugger/user_interface/UserInterface.h | 7 +++++++ .../user_interface/cli/CommandLineUserInterface.cpp | 7 +++++++ .../user_interface/cli/CommandLineUserInterface.h | 4 +++- .../user_interface/gui/GraphicalUserInterface.cpp | 9 ++++++++- .../user_interface/gui/GraphicalUserInterface.h | 4 +++- .../user_interface/report/ReportUserInterface.cpp | 11 ++++++++++- .../user_interface/report/ReportUserInterface.h | 4 +++- .../target_host_interface/TargetHostInterface.cpp | 12 +++++++++++- 9 files changed, 54 insertions(+), 6 deletions(-) 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: