forked from qt-creator/qt-creator
Debugger: Avoid one use of RunControl::runConfiguration()
Change-Id: Iaf9fb0cee4544121a4df433c3726d98ae0175ff2 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -574,10 +574,8 @@ void DebuggerRunTool::start()
|
||||
++d->engineStopsNeeded;
|
||||
|
||||
connect(m_engine, &DebuggerEngine::attachToCoreRequested, this, [this](const QString &coreFile) {
|
||||
auto runConfig = runControl()->runConfiguration();
|
||||
QTC_ASSERT(runConfig, return);
|
||||
auto rc = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||
rc->setRunConfiguration(runConfig);
|
||||
rc->copyFromRunControl(runControl());
|
||||
auto name = QString(tr("%1 - Snapshot %2").arg(runControl()->displayName()).arg(++d->snapshotCounter));
|
||||
auto debugger = new DebuggerRunTool(rc);
|
||||
debugger->setStartMode(AttachToCore);
|
||||
|
||||
@@ -275,10 +275,12 @@ QMap<Utils::Id, QVariantMap> RunConfiguration::settingsData() const
|
||||
return data;
|
||||
}
|
||||
|
||||
void RunConfiguration::storeAspectData(AspectContainerData *storage) const
|
||||
AspectContainerData RunConfiguration::aspectData() const
|
||||
{
|
||||
AspectContainerData data;
|
||||
for (BaseAspect *aspect : m_aspects)
|
||||
storage->append(aspect->extractData(&m_expander));
|
||||
data.append(aspect->extractData(&m_expander));
|
||||
return data;
|
||||
}
|
||||
|
||||
BuildSystem *RunConfiguration::activeBuildSystem() const
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
}
|
||||
|
||||
QMap<Utils::Id, QVariantMap> settingsData() const; // FIXME: Merge into aspectData?
|
||||
void storeAspectData(Utils::AspectContainerData *storage) const;
|
||||
Utils::AspectContainerData aspectData() const;
|
||||
|
||||
void update();
|
||||
|
||||
|
||||
@@ -301,7 +301,38 @@ static QString stateName(RunControlState s)
|
||||
# undef SN
|
||||
}
|
||||
|
||||
class RunControlPrivate : public QObject
|
||||
class RunControlPrivateData
|
||||
{
|
||||
public:
|
||||
QString displayName;
|
||||
Runnable runnable;
|
||||
IDevice::ConstPtr device;
|
||||
Utils::Icon icon;
|
||||
const MacroExpander *macroExpander = nullptr;
|
||||
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
|
||||
AspectContainerData aspectData;
|
||||
QString buildKey;
|
||||
QMap<Utils::Id, QVariantMap> settingsData;
|
||||
Utils::Id runConfigId;
|
||||
BuildTargetInfo buildTargetInfo;
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
FilePath buildDirectory;
|
||||
Environment buildEnvironment;
|
||||
Kit *kit = nullptr; // Not owned.
|
||||
QPointer<Target> target; // Not owned.
|
||||
QPointer<Project> project; // Not owned.
|
||||
std::function<bool(bool*)> promptToStop;
|
||||
std::vector<RunWorkerFactory> m_factories;
|
||||
|
||||
// A handle to the actual application process.
|
||||
Utils::ProcessHandle applicationProcessHandle;
|
||||
|
||||
RunControlState state = RunControlState::Initialized;
|
||||
|
||||
QList<QPointer<RunWorker>> m_workers;
|
||||
};
|
||||
|
||||
class RunControlPrivate : public QObject, public RunControlPrivateData
|
||||
{
|
||||
public:
|
||||
RunControlPrivate(RunControl *parent, Utils::Id mode)
|
||||
@@ -319,6 +350,8 @@ public:
|
||||
m_workers.clear();
|
||||
}
|
||||
|
||||
void copyData(RunControlPrivateData *other) { RunControlPrivateData::operator=(*other); }
|
||||
|
||||
Q_ENUM(RunControlState)
|
||||
|
||||
void checkState(RunControlState expectedState);
|
||||
@@ -344,33 +377,7 @@ public:
|
||||
bool supportsReRunning() const;
|
||||
|
||||
RunControl *q;
|
||||
QString displayName;
|
||||
Runnable runnable;
|
||||
IDevice::ConstPtr device;
|
||||
Utils::Id runMode;
|
||||
Utils::Icon icon;
|
||||
const MacroExpander *macroExpander = nullptr;
|
||||
QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use.
|
||||
AspectContainerData aspectData;
|
||||
QString buildKey;
|
||||
QMap<Utils::Id, QVariantMap> settingsData;
|
||||
Utils::Id runConfigId;
|
||||
BuildTargetInfo buildTargetInfo;
|
||||
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
|
||||
FilePath buildDirectory;
|
||||
Environment buildEnvironment;
|
||||
Kit *kit = nullptr; // Not owned.
|
||||
QPointer<Target> target; // Not owned.
|
||||
QPointer<Project> project; // Not owned.
|
||||
std::function<bool(bool*)> promptToStop;
|
||||
std::vector<RunWorkerFactory> m_factories;
|
||||
|
||||
// A handle to the actual application process.
|
||||
Utils::ProcessHandle applicationProcessHandle;
|
||||
|
||||
RunControlState state = RunControlState::Initialized;
|
||||
|
||||
QList<QPointer<RunWorker>> m_workers;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
@@ -382,6 +389,12 @@ RunControl::RunControl(Utils::Id mode) :
|
||||
{
|
||||
}
|
||||
|
||||
void RunControl::copyFromRunControl(RunControl *runControl)
|
||||
{
|
||||
QTC_ASSERT(runControl, return);
|
||||
d->copyData(runControl->d.get());
|
||||
}
|
||||
|
||||
void RunControl::setRunConfiguration(RunConfiguration *runConfig)
|
||||
{
|
||||
QTC_ASSERT(runConfig, return);
|
||||
@@ -392,8 +405,7 @@ void RunControl::setRunConfiguration(RunConfiguration *runConfig)
|
||||
d->displayName = runConfig->expandedDisplayName();
|
||||
d->buildKey = runConfig->buildKey();
|
||||
d->settingsData = runConfig->settingsData();
|
||||
|
||||
runConfig->storeAspectData(&d->aspectData);
|
||||
d->aspectData = runConfig->aspectData();
|
||||
|
||||
setTarget(runConfig->target());
|
||||
|
||||
|
||||
@@ -197,6 +197,8 @@ public:
|
||||
void setTarget(Target *target);
|
||||
void setKit(Kit *kit);
|
||||
|
||||
void copyFromRunControl(RunControl *runControl);
|
||||
|
||||
void initiateStart();
|
||||
void initiateReStart();
|
||||
void initiateStop();
|
||||
|
||||
Reference in New Issue
Block a user