forked from qt-creator/qt-creator
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:
@@ -116,7 +116,7 @@ ProjectExplorer::Project *QbsManager::openProject(const QString &fileName, QStri
|
|||||||
return new Internal::QbsProject(this, fileName);
|
return new Internal::QbsProject(this, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QbsManager::profileForKit(ProjectExplorer::Kit *k)
|
QString QbsManager::profileForKit(const ProjectExplorer::Kit *k)
|
||||||
{
|
{
|
||||||
if (!k)
|
if (!k)
|
||||||
return QString();
|
return QString();
|
||||||
@@ -129,9 +129,11 @@ void QbsManager::setProfileForKit(const QString &name, const ProjectExplorer::Ki
|
|||||||
m_settings->setValue(qtcProfilePrefix() + k->id().toString(), name);
|
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);
|
addProfileFromKit(kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ public:
|
|||||||
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
|
ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
|
||||||
|
|
||||||
// QBS profiles management:
|
// QBS profiles management:
|
||||||
QString profileForKit(ProjectExplorer::Kit *k);
|
QString profileForKit(const ProjectExplorer::Kit *k);
|
||||||
void setProfileForKit(const QString &name, 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 qbs::Settings *settings() { return m_settings; }
|
||||||
static Internal::QbsLogSink *logSink() { return m_logSink; }
|
static Internal::QbsLogSink *logSink() { return m_logSink; }
|
||||||
|
|||||||
Reference in New Issue
Block a user