Commit a83bf58b authored by Erik Verbruggen's avatar Erik Verbruggen

Project Explorer: fix possible nullptr derefs and remove dead

The dead store is not harmfull, but add noise when checking for dead
stores that are due to logic errors.

Change-Id: I18084c357696311b6556c7bc60832a72b3318e92
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent b3bc530c
......@@ -301,16 +301,21 @@ void BuildStepListWidget::updateAddBuildStepMenu()
// Ask the user which one to add
QMenu *menu = m_addButton->menu();
m_addBuildStepHash.clear();
menu->clear();
if (!map.isEmpty()) {
QMap<QString, QPair<Core::Id, IBuildStepFactory *> >::const_iterator it, end;
end = map.constEnd();
for (it = map.constBegin(); it != end; ++it) {
QAction *action = menu->addAction(it.key());
connect(action, SIGNAL(triggered()),
this, SLOT(triggerAddBuildStep()));
m_addBuildStepHash.insert(action, it.value());
IBuildStepFactory *factory = it.value().second;
Core::Id id = it.value().first;
connect(action, &QAction::triggered, [id, factory, this]() {
BuildStep *newStep = factory->create(m_buildStepList, id);
QTC_ASSERT(newStep, return);
int pos = m_buildStepList->count();
m_buildStepList->insertStep(pos, newStep);
});
}
}
}
......@@ -341,17 +346,6 @@ void BuildStepListWidget::addBuildStepWidget(int pos, BuildStep *step)
m_removeMapper, SLOT(map()));
}
void BuildStepListWidget::triggerAddBuildStep()
{
if (QAction *action = qobject_cast<QAction *>(sender())) {
QPair<Core::Id, IBuildStepFactory *> pair = m_addBuildStepHash.value(action);
BuildStep *newStep = pair.second->create(m_buildStepList, pair.first);
QTC_ASSERT(newStep, return);
int pos = m_buildStepList->count();
m_buildStepList->insertStep(pos, newStep);
}
}
void BuildStepListWidget::addBuildStep(int pos)
{
BuildStep *newStep = m_buildStepList->at(pos);
......
......@@ -109,7 +109,6 @@ public:
private slots:
void updateAddBuildStepMenu();
void triggerAddBuildStep();
void addBuildStep(int pos);
void updateSummary();
void updateAdditionalSummary();
......@@ -127,7 +126,6 @@ private:
void addBuildStepWidget(int pos, BuildStep *step);
BuildStepList *m_buildStepList;
QHash<QAction *, QPair<Core::Id, ProjectExplorer::IBuildStepFactory *> > m_addBuildStepHash;
QList<Internal::BuildStepsWidgetData *> m_buildStepsData;
......
......@@ -848,19 +848,19 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// build without dependencies action
d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
cmd = ActionManager::registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
ActionManager::registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
// rebuild without dependencies action
d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
cmd = ActionManager::registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
ActionManager::registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
// deploy without dependencies action
d->m_deployProjectOnlyAction = new QAction(tr("Deploy Without Dependencies"), this);
cmd = ActionManager::registerAction(d->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext);
ActionManager::registerAction(d->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext);
// clean without dependencies action
d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
cmd = ActionManager::registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
ActionManager::registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
// deploy action (context menu)
d->m_deployActionContextMenu = new QAction(tr("Deploy"), this);
......
......@@ -250,14 +250,15 @@ void RunSettingsWidget::aboutToShowAddMenu()
QList<Core::Id> ids = factory->availableCreationIds(m_target);
foreach (Core::Id id, ids) {
QAction *action = new QAction(factory->displayNameForId(id), m_addRunMenu);
FactoryAndId fai;
fai.factory = factory;
fai.id = id;
QVariant v;
v.setValue(fai);
action->setData(v);
connect(action, SIGNAL(triggered()),
this, SLOT(addRunConfiguration()));
connect(action, &QAction::triggered, [factory, id, this]() {
RunConfiguration *newRC = factory->create(m_target, id);
if (!newRC)
return;
QTC_CHECK(newRC->id() == id);
m_target->addRunConfiguration(newRC);
m_target->setActiveRunConfiguration(newRC);
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
});
menuActions.append(action);
}
}
......@@ -269,21 +270,6 @@ void RunSettingsWidget::aboutToShowAddMenu()
m_addRunMenu->addAction(action);
}
void RunSettingsWidget::addRunConfiguration()
{
QAction *act = qobject_cast<QAction *>(sender());
if (!act)
return;
FactoryAndId fai = act->data().value<FactoryAndId>();
RunConfiguration *newRC = fai.factory->create(m_target, fai.id);
if (!newRC)
return;
QTC_CHECK(newRC->id() == fai.id);
m_target->addRunConfiguration(newRC);
m_target->setActiveRunConfiguration(newRC);
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
}
void RunSettingsWidget::cloneRunConfiguration()
{
RunConfiguration* activeRunConfiguration = m_target->activeRunConfiguration();
......@@ -397,27 +383,21 @@ void RunSettingsWidget::aboutToShowDeployMenu()
action->setData(QVariant::fromValue(data));
connect(action, SIGNAL(triggered()),
this, SLOT(addDeployConfiguration()));
connect(action, &QAction::triggered, [factory, id, this]() {
if (!factory->canCreate(m_target, id))
return;
DeployConfiguration *newDc = factory->create(m_target, id);
if (!newDc)
return;
QTC_CHECK(!newDc || newDc->id() == id);
m_target->addDeployConfiguration(newDc);
m_target->setActiveDeployConfiguration(newDc);
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
});
}
}
}
void RunSettingsWidget::addDeployConfiguration()
{
QAction *act = qobject_cast<QAction *>(sender());
if (!act)
return;
DeployFactoryAndId data = act->data().value<DeployFactoryAndId>();
if (!data.factory->canCreate(m_target, data.id))
return;
DeployConfiguration *newDc = data.factory->create(m_target, data.id);
if (!newDc)
return;
QTC_CHECK(!newDc || newDc->id() == data.id);
m_target->addDeployConfiguration(newDc);
m_target->setActiveDeployConfiguration(newDc);
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
}
void RunSettingsWidget::removeDeployConfiguration()
{
DeployConfiguration *dc = m_target->activeDeployConfiguration();
......
......@@ -67,14 +67,12 @@ public:
private slots:
void currentRunConfigurationChanged(int index);
void aboutToShowAddMenu();
void addRunConfiguration();
void cloneRunConfiguration();
void removeRunConfiguration();
void activeRunConfigurationChanged();
void renameRunConfiguration();
void currentDeployConfigurationChanged(int index);
void aboutToShowDeployMenu();
void addDeployConfiguration();
void removeDeployConfiguration();
void activeDeployConfigurationChanged();
void renameDeployConfiguration();
......
......@@ -165,14 +165,16 @@ LibraryWizardDialog::LibraryWizardDialog(const QString &templateName,
Utils::WizardProgressItem *filesItem = wizardProgress()->item(m_filesPageId);
filesItem->setTitle(tr("Details"));
if (m_targetPageId != -1) {
targetItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< modulesItem << filesItem);
targetItem->setNextShownItem(0);
} else {
introItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< modulesItem << filesItem);
introItem->setNextShownItem(0);
if (targetItem) {
if (m_targetPageId != -1) {
targetItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< modulesItem << filesItem);
targetItem->setNextShownItem(0);
} else {
introItem->setNextItems(QList<Utils::WizardProgressItem *>()
<< modulesItem << filesItem);
introItem->setNextShownItem(0);
}
}
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotCurrentIdChanged(int)));
......
......@@ -212,7 +212,7 @@ void ShortCutManager::updateActions(Core::IEditor* currentEditor)
&& document->isModified());
QString quotedName;
if (currentEditor)
if (currentEditor && document)
quotedName = '"' + document->displayName() + '"';
m_saveAsAction.setText(tr("Save %1 As...").arg(quotedName));
......
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