Debugger: Avoid one use of RunControl::runConfiguration()

Change-Id: Iaf9fb0cee4544121a4df433c3726d98ae0175ff2
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2022-04-08 15:12:24 +02:00
parent a4a651aa32
commit a26f0ba808
7 changed files with 114 additions and 54 deletions

View File

@@ -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());