forked from qt-creator/qt-creator
ProjectExplorer: Fixup aspectized MakeStep
- Postpone OverrideMakeflag label creation until it is needed. This also fixes a leak as in the un-shown case when it never got a parent. - Use the widget as guard object in update connections. The widget (and the aspects' widgets parented to it) gets destroyed e.g. when the active build configuration is switched. - For extra snake oil, put the step widget in a QPointer in updateDetail. Fixes: QTCREATORBUG-24469 Change-Id: I919cf4956848f7c95ad0441096079ec40666b04e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -70,24 +70,31 @@ namespace Internal {
|
|||||||
class OverrideMakeflagsAspect final : public BaseBoolAspect
|
class OverrideMakeflagsAspect final : public BaseBoolAspect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OverrideMakeflagsAspect()
|
OverrideMakeflagsAspect() {}
|
||||||
{
|
|
||||||
const QString text = tr("Override MAKEFLAGS");
|
|
||||||
setLabel(text, LabelPlacement::AtCheckBox);
|
|
||||||
|
|
||||||
m_nonOverrideWarning = new QLabel;
|
void setWarningVisible(bool on)
|
||||||
m_nonOverrideWarning->setToolTip("<html><body><p>" +
|
{
|
||||||
tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.")
|
if (m_nonOverrideWarning)
|
||||||
.arg(text) + "</p></body></html>");
|
m_nonOverrideWarning->setVisible(on);
|
||||||
m_nonOverrideWarning->setPixmap(Icons::WARNING.pixmap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToLayout(LayoutBuilder &builder) final
|
void addToLayout(LayoutBuilder &builder) final
|
||||||
{
|
{
|
||||||
|
if (!m_nonOverrideWarning) {
|
||||||
|
const QString text = tr("Override MAKEFLAGS");
|
||||||
|
setLabel(text, LabelPlacement::AtCheckBox);
|
||||||
|
m_nonOverrideWarning = new QLabel;
|
||||||
|
m_nonOverrideWarning->setToolTip("<html><body><p>" +
|
||||||
|
tr("<code>MAKEFLAGS</code> specifies parallel jobs. Check \"%1\" to override.")
|
||||||
|
.arg(text) + "</p></body></html>");
|
||||||
|
m_nonOverrideWarning->setPixmap(Icons::WARNING.pixmap());
|
||||||
|
}
|
||||||
|
|
||||||
BaseBoolAspect::addToLayout(builder);
|
BaseBoolAspect::addToLayout(builder);
|
||||||
builder.addItem(m_nonOverrideWarning.data());
|
builder.addItem(m_nonOverrideWarning.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
QPointer<QLabel> m_nonOverrideWarning;
|
QPointer<QLabel> m_nonOverrideWarning;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -461,7 +468,8 @@ BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|||||||
return param.summaryInWorkdir(displayName());
|
return param.summaryInWorkdir(displayName());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto updateDetails = [this, widget] {
|
auto updateDetails = [this, widget = QPointer<Internal::MakeStepConfigWidget>(widget)] {
|
||||||
|
QTC_ASSERT(widget, return);
|
||||||
const bool jobCountVisible = isJobCountSupported();
|
const bool jobCountVisible = isJobCountSupported();
|
||||||
m_userJobCountAspect->setVisible(jobCountVisible);
|
m_userJobCountAspect->setVisible(jobCountVisible);
|
||||||
m_overrideMakeflagsAspect->setVisible(jobCountVisible);
|
m_overrideMakeflagsAspect->setVisible(jobCountVisible);
|
||||||
@@ -469,10 +477,8 @@ BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|||||||
const bool jobCountEnabled = !userArgsContainsJobCount();
|
const bool jobCountEnabled = !userArgsContainsJobCount();
|
||||||
m_userJobCountAspect->setEnabled(jobCountEnabled);
|
m_userJobCountAspect->setEnabled(jobCountEnabled);
|
||||||
m_overrideMakeflagsAspect->setEnabled(jobCountEnabled);
|
m_overrideMakeflagsAspect->setEnabled(jobCountEnabled);
|
||||||
|
m_overrideMakeflagsAspect->setWarningVisible(makeflagsJobCountMismatch()
|
||||||
QTC_ASSERT(m_overrideMakeflagsAspect->m_nonOverrideWarning, return);
|
&& !jobCountOverridesMakeflags());
|
||||||
m_overrideMakeflagsAspect->m_nonOverrideWarning->setVisible(
|
|
||||||
makeflagsJobCountMismatch() && !jobCountOverridesMakeflags());
|
|
||||||
widget->m_disableInSubDirsCheckBox->setChecked(!enabledForSubDirs());
|
widget->m_disableInSubDirsCheckBox->setChecked(!enabledForSubDirs());
|
||||||
|
|
||||||
widget->recreateSummary();
|
widget->recreateSummary();
|
||||||
@@ -480,10 +486,10 @@ BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|||||||
|
|
||||||
updateDetails();
|
updateDetails();
|
||||||
|
|
||||||
connect(m_makeCommandAspect, &BaseStringAspect::changed, this, updateDetails);
|
connect(m_makeCommandAspect, &BaseStringAspect::changed, widget, updateDetails);
|
||||||
connect(m_userArgumentsAspect, &BaseStringAspect::changed, this, updateDetails);
|
connect(m_userArgumentsAspect, &BaseStringAspect::changed, widget, updateDetails);
|
||||||
connect(m_userJobCountAspect, &BaseIntegerAspect::changed, this, updateDetails);
|
connect(m_userJobCountAspect, &BaseIntegerAspect::changed, widget, updateDetails);
|
||||||
connect(m_overrideMakeflagsAspect, &BaseBoolAspect::changed, this, updateDetails);
|
connect(m_overrideMakeflagsAspect, &BaseBoolAspect::changed, widget, updateDetails);
|
||||||
|
|
||||||
connect(widget->m_targetsList, &QListWidget::itemChanged, this,
|
connect(widget->m_targetsList, &QListWidget::itemChanged, this,
|
||||||
[this, updateDetails](QListWidgetItem *item) {
|
[this, updateDetails](QListWidgetItem *item) {
|
||||||
@@ -492,13 +498,13 @@ BuildStepConfigWidget *MakeStep::createConfigWidget()
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
|
||||||
this, updateDetails);
|
widget, updateDetails);
|
||||||
|
|
||||||
connect(target(), &Target::kitChanged, this, updateDetails);
|
connect(target(), &Target::kitChanged, widget, updateDetails);
|
||||||
|
|
||||||
connect(buildConfiguration(), &BuildConfiguration::environmentChanged, this, updateDetails);
|
connect(buildConfiguration(), &BuildConfiguration::environmentChanged, widget, updateDetails);
|
||||||
connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, this, updateDetails);
|
connect(buildConfiguration(), &BuildConfiguration::buildDirectoryChanged, widget, updateDetails);
|
||||||
connect(target(), &Target::parsingFinished, this, updateDetails);
|
connect(target(), &Target::parsingFinished, widget, updateDetails);
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user