Commit 4bc1b19d authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Warn when ignoring tool chain addition

Warn when ignoring a tool chain addition because a identical
is already configured.

Task-number: QTCREATORBUG-4206
parent 96de9705
......@@ -207,17 +207,18 @@ ToolChain *ToolChainManager::findToolChain(const QString &id) const
return 0;
}
void ToolChainManager::registerToolChain(ToolChain *tc)
bool ToolChainManager::registerToolChain(ToolChain *tc)
{
if (!tc || m_d->m_toolChains.contains(tc))
return;
return true;
foreach (ToolChain *current, m_d->m_toolChains) {
if (*tc == *current)
return;
return false;
}
m_d->m_toolChains.append(tc);
emit toolChainAdded(tc);
return true;
}
void ToolChainManager::deregisterToolChain(ToolChain *tc)
......
......@@ -69,7 +69,7 @@ public:
ToolChain *findToolChain(const QString &id) const;
public slots:
void registerToolChain(ProjectExplorer::ToolChain *tc);
bool registerToolChain(ProjectExplorer::ToolChain *tc);
void deregisterToolChain(ProjectExplorer::ToolChain *tc);
void saveToolChains();
......
......@@ -306,15 +306,34 @@ void ToolChainModel::apply()
}
// Add new (and already updated) tool chains
QStringList removedTcs;
nodes = m_toAddList;
foreach (ToolChainNode *n, nodes) {
ToolChainManager::instance()->registerToolChain(n->toolChain);
if (!ToolChainManager::instance()->registerToolChain(n->toolChain))
removedTcs << n->toolChain->displayName();
}
//
foreach (ToolChainNode *n, m_toAddList) {
markForRemoval(n->toolChain);
}
qDeleteAll(m_toAddList);
if (removedTcs.count() == 1) {
QMessageBox::warning(0,
tr("Duplicate Tool Chain detected"),
tr("The following tool chain was already configured:<br>"
"&nbsp;%1<br>"
"It was not configured again.")
.arg(removedTcs.at(0)));
} else if (!removedTcs.isEmpty()) {
QMessageBox::warning(0,
tr("Duplicate Tool Chains detected"),
tr("The following tool chains were already configured:<br>"
"&nbsp;%1<br>"
"They were not configured again.")
.arg(removedTcs.join(QLatin1String(",<br>&nbsp;"))));
}
}
void ToolChainModel::markForRemoval(ToolChain *tc)
......
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