Commit e9718b25 authored by hjk's avatar hjk

Debugger: Partially dissolve DebuggerRunControlFactory

Aspect creation must stay for now as the object pool is the only
central registry for it right now.

Change-Id: Ibe42009db6b0351aaa36e9ac8f0f6f7a0562167e
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent 6f0a600b
......@@ -420,7 +420,18 @@ namespace Internal {
void addCdbOptionPages(QList<IOptionsPage*> *opts);
void addGdbOptionPages(QList<IOptionsPage*> *opts);
QObject *createDebuggerRunControlFactory(QObject *parent);
/// DebuggerRunControlFactory
class DebuggerRunControlFactory : public IRunControlFactory
{
public:
IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override
{
return new DebuggerRunConfigurationAspect(rc);
}
};
static QIcon visibleStartIcon(Id id, bool toolBarStyle)
{
......@@ -1482,7 +1493,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS));
m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle());
m_plugin->addAutoReleasedObject(createDebuggerRunControlFactory(m_plugin));
m_plugin->addAutoReleasedObject(new DebuggerRunControlFactory);
// The main "Start Debugging" action.
act = m_startAction = new QAction(this);
......@@ -3033,6 +3044,28 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd->setAttribute(Command::CA_NonConfigurable);
}
}
auto constraint = [](RunConfiguration *runConfig) {
Runnable runnable = runConfig->runnable();
if (runnable.is<StandardRunnable>()) {
IDevice::ConstPtr device = runnable.as<StandardRunnable>().device;
if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return true;
}
if (DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return true;
QString mainScript = runConfig->property("mainScript").toString();
const bool isDebuggableScript = mainScript.endsWith(".py"); // Only Python for now.
return isDebuggableScript;
};
RunControl::registerWorker<DebuggerRunTool>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<DebuggerRunTool>
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, constraint);
}
DebuggerEngine *currentEngine()
......
......@@ -457,18 +457,6 @@ static bool fixupParameters(DebuggerRunParameters &rp, RunControl *runControl, Q
} // Internal
////////////////////////////////////////////////////////////////////////
//
// DebuggerRunControlFactory
//
////////////////////////////////////////////////////////////////////////
static bool isDebuggableScript(RunConfiguration *runConfig)
{
QString mainScript = runConfig->property("mainScript").toString();
return mainScript.endsWith(".py"); // Only Python for now.
}
static DebuggerRunConfigurationAspect *debuggerAspect(const RunControl *runControl)
{
return runControl->runConfiguration()->extraAspect<DebuggerRunConfigurationAspect>();
......@@ -606,61 +594,14 @@ void DebuggerRunTool::showMessage(const QString &msg, int channel, int timeout)
}
}
namespace Internal {
/// DebuggerRunControlFactory
class DebuggerRunControlFactory : public IRunControlFactory
{
public:
explicit DebuggerRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
{}
RunControl *create(RunConfiguration *runConfig, Core::Id mode, QString *) override
{
QTC_ASSERT(runConfig, return 0);
QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0);
auto runControl = new RunControl(runConfig, mode);
(void) new DebuggerRunTool(runControl);
return runControl;
}
bool canRun(RunConfiguration *runConfig, Core::Id mode) const override
{
if (!(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain))
return false;
Runnable runnable = runConfig->runnable();
if (runnable.is<StandardRunnable>()) {
IDevice::ConstPtr device = runnable.as<StandardRunnable>().device;
if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return true;
}
return DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
|| isDebuggableScript(runConfig);
}
IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override
{
return new DebuggerRunConfigurationAspect(rc);
}
};
QObject *createDebuggerRunControlFactory(QObject *parent)
{
return new DebuggerRunControlFactory(parent);
}
////////////////////////////////////////////////////////////////////////
//
// Externally visible helper.
//
////////////////////////////////////////////////////////////////////////
namespace Internal {
/**
* Used for direct "special" starts from actions in the debugger plugin.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment