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.
This commit is contained in:
Rene Gollent 2016-07-03 13:47:32 -04:00
parent 4221d035d8
commit 05fc1277c4
9 changed files with 54 additions and 6 deletions

View File

@ -66,6 +66,8 @@ public:
{ return fCommandLineArgv; } { return fCommandLineArgv; }
SettingsManager* GetSettingsManager() const SettingsManager* GetSettingsManager() const
{ return fSettingsManager; } { return fSettingsManager; }
UserInterface* GetUserInterface() const
{ return fUserInterface; }
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);

View File

@ -56,6 +56,13 @@ public:
// shut down the UI *now* -- no more user // shut down the UI *now* -- no more user
// feedback // 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 bool IsInteractive() const = 0;
virtual status_t LoadSettings(const TeamUiSettings* settings) virtual status_t LoadSettings(const TeamUiSettings* settings)

View File

@ -166,6 +166,13 @@ CommandLineUserInterface::Terminate()
} }
UserInterface*
CommandLineUserInterface::Clone() const
{
return new(std::nothrow) CommandLineUserInterface;
}
bool bool
CommandLineUserInterface::IsInteractive() const CommandLineUserInterface::IsInteractive() const
{ {

View File

@ -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. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -31,6 +31,8 @@ public:
// shut down the UI *now* -- no more user // shut down the UI *now* -- no more user
// feedback // feedback
virtual UserInterface* Clone() const;
virtual bool IsInteractive() const; virtual bool IsInteractive() const;
virtual status_t LoadSettings(const TeamUiSettings* settings); virtual status_t LoadSettings(const TeamUiSettings* settings);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
@ -194,6 +194,13 @@ GraphicalUserInterface::Terminate()
} }
UserInterface*
GraphicalUserInterface::Clone() const
{
return new(std::nothrow) GraphicalUserInterface;
}
bool bool
GraphicalUserInterface::IsInteractive() const GraphicalUserInterface::IsInteractive() const
{ {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * 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. * Distributed under the terms of the MIT License.
*/ */
#ifndef GRAPHICAL_USER_INTERFACE_H #ifndef GRAPHICAL_USER_INTERFACE_H
@ -30,6 +30,8 @@ public:
// shut down the UI *now* -- no more user // shut down the UI *now* -- no more user
// feedback // feedback
virtual UserInterface* Clone() const;
virtual bool IsInteractive() const; virtual bool IsInteractive() const;
virtual status_t LoadSettings(const TeamUiSettings* settings); virtual status_t LoadSettings(const TeamUiSettings* settings);

View File

@ -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. * 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 bool
ReportUserInterface::IsInteractive() const ReportUserInterface::IsInteractive() const
{ {

View File

@ -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. * Distributed under the terms of the MIT License.
*/ */
#ifndef REPORT_USER_INTERFACE_H #ifndef REPORT_USER_INTERFACE_H
@ -27,6 +27,8 @@ public:
virtual void Show(); virtual void Show();
virtual void Terminate(); virtual void Terminate();
virtual UserInterface* Clone() const;
virtual bool IsInteractive() const; virtual bool IsInteractive() const;
virtual status_t LoadSettings(const TeamUiSettings* settings); virtual status_t LoadSettings(const TeamUiSettings* settings);

View File

@ -184,13 +184,23 @@ TargetHostInterface::MessageReceived(BMessage* message)
TeamDebugger* debugger = FindTeamDebugger(teamID); TeamDebugger* debugger = FindTeamDebugger(teamID);
UserInterface* userInterface = debugger->GetUserInterface()->Clone();
if (userInterface == NULL)
break;
BReference<UserInterface> userInterfaceReference(userInterface, true);
TeamDebuggerOptions options; TeamDebuggerOptions options;
options.requestType = TEAM_DEBUGGER_REQUEST_CREATE;
options.commandLineArgc = debugger->ArgumentCount(); options.commandLineArgc = debugger->ArgumentCount();
options.commandLineArgv = debugger->Arguments(); options.commandLineArgv = debugger->Arguments();
options.settingsManager = debugger->GetSettingsManager(); options.settingsManager = debugger->GetSettingsManager();
options.userInterface = userInterface;
status_t result = StartTeamDebugger(options); status_t result = StartTeamDebugger(options);
if (result == B_OK) if (result == B_OK) {
userInterfaceReference.Detach();
debugger->PostMessage(B_QUIT_REQUESTED); debugger->PostMessage(B_QUIT_REQUESTED);
}
break; break;
} }
default: default: