ProjectExplorer: Hide parts of BuildStep's QObject-ness from users

This lets the compiler catch issues like QTCREATORBUG-22818 and
saves visible casts on the user side.

Change-Id: I5a307a55364daa0bec039a4c38cc9827841ff9c1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-08-16 12:16:17 +02:00
parent e425706c4d
commit 9d206a2bc4
6 changed files with 16 additions and 7 deletions

View File

@@ -193,7 +193,7 @@ bool AndroidDeployQtStep::init()
<< "Min target API" << minTargetApi; << "Min target API" << minTargetApi;
// Try to re-use user-provided information from an earlier step of the same type. // Try to re-use user-provided information from an earlier step of the same type.
auto bsl = qobject_cast<BuildStepList *>(parent()); BuildStepList *bsl = stepList();
QTC_ASSERT(bsl, return false); QTC_ASSERT(bsl, return false);
auto androidDeployQtStep = bsl->firstOfType<AndroidDeployQtStep>(); auto androidDeployQtStep = bsl->firstOfType<AndroidDeployQtStep>();
QTC_ASSERT(androidDeployQtStep, return false); QTC_ASSERT(androidDeployQtStep, return false);

View File

@@ -262,8 +262,9 @@ BuildStepConfigWidget *CMakeBuildStep::createConfigWidget()
QString CMakeBuildStep::defaultBuildTarget() const QString CMakeBuildStep::defaultBuildTarget() const
{ {
const auto pc = qobject_cast<BuildStepList *>(parent()); const BuildStepList *const bsl = stepList();
const Core::Id parentId = pc ? pc->id() : Core::Id(); QTC_ASSERT(bsl, return {});
const Core::Id parentId = bsl->id();
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) if (parentId == ProjectExplorer::Constants::BUILDSTEPS_CLEAN)
return cleanTarget(); return cleanTarget();
if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) if (parentId == ProjectExplorer::Constants::BUILDSTEPS_DEPLOY)

View File

@@ -286,6 +286,11 @@ void BuildStep::setEnabled(bool b)
emit enabledChanged(); emit enabledChanged();
} }
BuildStepList *BuildStep::stepList() const
{
return qobject_cast<BuildStepList *>(parent());
}
bool BuildStep::enabled() const bool BuildStep::enabled() const
{ {
return m_enabled; return m_enabled;

View File

@@ -69,6 +69,8 @@ public:
bool enabled() const; bool enabled() const;
void setEnabled(bool b); void setEnabled(bool b);
BuildStepList *stepList() const;
BuildConfiguration *buildConfiguration() const; BuildConfiguration *buildConfiguration() const;
DeployConfiguration *deployConfiguration() const; DeployConfiguration *deployConfiguration() const;
ProjectConfiguration *projectConfiguration() const; ProjectConfiguration *projectConfiguration() const;
@@ -122,6 +124,8 @@ protected:
bool isCanceled() const; bool isCanceled() const;
private: private:
using ProjectConfiguration::parent;
virtual void doRun() = 0; virtual void doRun() = 0;
virtual void doCancel(); virtual void doCancel();

View File

@@ -80,7 +80,7 @@ bool QmakeMakeStep::init()
// Ignore all but the first make step for a non-top-level build. See QTCREATORBUG-15794. // Ignore all but the first make step for a non-top-level build. See QTCREATORBUG-15794.
m_ignoredNonTopLevelBuild = (bc->fileNodeBuild() || bc->subNodeBuild()) m_ignoredNonTopLevelBuild = (bc->fileNodeBuild() || bc->subNodeBuild())
&& static_cast<BuildStepList *>(parent())->firstOfType<QmakeMakeStep>() != this; && stepList()->firstOfType<QmakeMakeStep>() != this;
ProcessParameters *pp = processParameters(); ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander()); pp->setMacroExpander(bc->macroExpander());
@@ -173,8 +173,7 @@ bool QmakeMakeStep::init()
// A user doing "make clean" indicates they want a proper rebuild, so make sure to really // A user doing "make clean" indicates they want a proper rebuild, so make sure to really
// execute qmake on the next build. // execute qmake on the next build.
if (static_cast<BuildStepList *>(parent())->id() if (stepList()->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
== ProjectExplorer::Constants::BUILDSTEPS_CLEAN) {
const auto qmakeStep = bc->qmakeStep(); const auto qmakeStep = bc->qmakeStep();
if (qmakeStep) if (qmakeStep)
qmakeStep->setForced(true); qmakeStep->setForced(true);

View File

@@ -442,7 +442,7 @@ void QMakeStep::setSeparateDebugInfo(bool enable)
FilePath QMakeStep::makeCommand() const FilePath QMakeStep::makeCommand() const
{ {
auto ms = qobject_cast<BuildStepList *>(parent())->firstOfType<MakeStep>(); auto ms = stepList()->firstOfType<MakeStep>();
return ms ? ms->effectiveMakeCommand().executable() : FilePath(); return ms ? ms->effectiveMakeCommand().executable() : FilePath();
} }