QbsProjectManager: Make Kit function argument const.

It's silly to force all callers in the chain to use a non-const pointer
for a Kit that is really const just because of the QList<T *> vs.
QList<const T *> problem. Instead, use a (safe) const_cast for the
list operations.

Change-Id: I929cb9e42957de48d7ad8e1e4b04a7739f9c22bf
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2014-11-24 17:17:27 +01:00
parent 938326ef2c
commit f19ec81a67
2 changed files with 7 additions and 5 deletions

View File

@@ -116,7 +116,7 @@ ProjectExplorer::Project *QbsManager::openProject(const QString &fileName, QStri
return new Internal::QbsProject(this, fileName);
}
QString QbsManager::profileForKit(ProjectExplorer::Kit *k)
QString QbsManager::profileForKit(const ProjectExplorer::Kit *k)
{
if (!k)
return QString();
@@ -129,9 +129,11 @@ void QbsManager::setProfileForKit(const QString &name, const ProjectExplorer::Ki
m_settings->setValue(qtcProfilePrefix() + k->id().toString(), name);
}
void QbsManager::updateProfileIfNecessary(ProjectExplorer::Kit *kit)
void QbsManager::updateProfileIfNecessary(const ProjectExplorer::Kit *kit)
{
if (m_kitsToBeSetupForQbs.removeOne(kit)) // kit in list <=> yes, it is necessary
// kit in list <=> profile update is necessary
// Note that the const_cast is safe, as we do not call any non-const methods on the object.
if (m_kitsToBeSetupForQbs.removeOne(const_cast<ProjectExplorer::Kit *>(kit)))
addProfileFromKit(kit);
}

View File

@@ -72,10 +72,10 @@ public:
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
// QBS profiles management:
QString profileForKit(ProjectExplorer::Kit *k);
QString profileForKit(const ProjectExplorer::Kit *k);
void setProfileForKit(const QString &name, const ProjectExplorer::Kit *k);
void updateProfileIfNecessary(ProjectExplorer::Kit *kit);
void updateProfileIfNecessary(const ProjectExplorer::Kit *kit);
static qbs::Settings *settings() { return m_settings; }
static Internal::QbsLogSink *logSink() { return m_logSink; }