Commit 081bf518 authored by Christian Kandeler's avatar Christian Kandeler
Browse files

QbsProjectManager: More fine-grained profile setup.



Setting up a qbs profile, particularly for Qt, can take a measurable
amount of time, so we should not do bulk changes via the kitsChanged()
signal. Instead:
    - For the initial kit loading, delay the profile setup until
      the kit is needed for the first time, i.e. the user attaches it
      to a project.
    - Handle adding, removing and updating a kit separately; in
      particular, do not do anything to other kits.

Change-Id: If09d3c40b21e9a1356dc96089b92a60186a9bcdb
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent cefd1832
......@@ -33,6 +33,7 @@
#include "qbsbuildconfiguration.h"
#include "qbslogsink.h"
#include "qbsprojectfile.h"
#include "qbsprojectmanager.h"
#include "qbsprojectparser.h"
#include "qbsprojectmanagerconstants.h"
#include "qbsnodes.h"
......@@ -47,6 +48,7 @@
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/mimedatabase.h>
#include <cpptools/cppmodelmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildtargetinfo.h>
......@@ -625,6 +627,9 @@ void QbsProject::parse(const QVariantMap &config, const Environment &env, const
registerQbsProjectParser(new QbsProjectParser(this, m_qbsUpdateFutureInterface));
QbsManager * const qbsManager = ExtensionSystem::PluginManager::getObject<QbsManager>();
QTC_ASSERT(qbsManager, return);
qbsManager->updateProfileIfNecessary(activeTarget()->kit());
m_qbsProjectParser->parse(config, env, dir);
emit projectParsingStarted();
}
......
......@@ -50,7 +50,6 @@
#include <qbs.h>
#include <qtprofilesetup.h>
#include <tools/profile.h> // TODO: Do this in qbs.h.
const QChar sep = QLatin1Char('.');
......@@ -68,7 +67,14 @@ QbsManager::QbsManager() :
m_settings = new qbs::Settings(Core::ICore::userResourcePath());
setObjectName(QLatin1String("QbsProjectManager"));
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(pushKitsToQbs()));
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitsLoaded, this,
[this]() { m_kitsToBeSetupForQbs = ProjectExplorer::KitManager::kits(); } );
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitAdded, this,
&QbsManager::addProfileFromKit);
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitUpdated, this,
&QbsManager::handleKitUpdate);
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitRemoved, this,
&QbsManager::handleKitRemoval);
m_logSink = new Internal::QbsLogSink(this);
int level = qbs::LoggerWarning;
......@@ -122,6 +128,12 @@ void QbsManager::setProfileForKit(const QString &name, const ProjectExplorer::Ki
m_settings->setValue(qtcProfilePrefix() + k->id().toString(), name);
}
void QbsManager::updateProfileIfNecessary(ProjectExplorer::Kit *kit)
{
if (m_kitsToBeSetupForQbs.removeOne(kit)) // kit in list <=> yes, it is necessary
addProfileFromKit(kit);
}
void QbsManager::addProfile(const QString &name, const QVariantMap &data)
{
qbs::Profile profile(name, settings());
......@@ -130,15 +142,6 @@ void QbsManager::addProfile(const QString &name, const QVariantMap &data)
profile.setValue(it.key(), it.value());
}
void QbsManager::removeCreatorProfiles()
{
foreach (const QString &key, m_settings->allKeysWithPrefix(qtcProfileGroup())) {
const QString fullKey = qtcProfilePrefix() + key;
qbs::Profile(m_settings->value(fullKey).toString(), m_settings).removeProfile();
m_settings->remove(fullKey);
}
}
void QbsManager::addQtProfileFromKit(const QString &profileName, const ProjectExplorer::Kit *k)
{
const QtSupport::BaseQtVersion * const qt = QtSupport::QtKitInformation::qtVersion(k);
......@@ -182,8 +185,7 @@ void QbsManager::addQtProfileFromKit(const QString &profileName, const ProjectEx
void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k)
{
const QString name = ProjectExplorer::Project::makeUnique(
QString::fromLatin1("qtc_") + k->fileSystemFriendlyName(), m_settings->profiles());
const QString name = QString::fromLatin1("qtc_") + k->fileSystemFriendlyName();
setProfileForKit(name, k);
addQtProfileFromKit(name, k);
......@@ -198,14 +200,19 @@ void QbsManager::addProfileFromKit(const ProjectExplorer::Kit *k)
addProfile(name, data);
}
void QbsManager::pushKitsToQbs()
void QbsManager::handleKitUpdate(ProjectExplorer::Kit *kit)
{
// Get all keys
removeCreatorProfiles();
m_kitsToBeSetupForQbs.removeOne(kit);
addProfileFromKit(kit);
}
// add definitions from our kits
foreach (const ProjectExplorer::Kit *k, ProjectExplorer::KitManager::kits())
addProfileFromKit(k);
void QbsManager::handleKitRemoval(ProjectExplorer::Kit *kit)
{
m_kitsToBeSetupForQbs.removeOne(kit);
const QString key = qtcProfilePrefix() + kit->id().toString();
const QString profileName = m_settings->value(key).toString();
m_settings->remove(key);
qbs::Profile(profileName, m_settings).removeProfile();
}
} // namespace QbsProjectManager
......@@ -35,6 +35,8 @@
#include <projectexplorer/iprojectmanager.h>
#include <QList>
namespace qbs {
class Settings;
class Preferences;
......@@ -73,22 +75,24 @@ public:
QString profileForKit(const ProjectExplorer::Kit *k) const;
void setProfileForKit(const QString &name, const ProjectExplorer::Kit *k);
void updateProfileIfNecessary(ProjectExplorer::Kit *kit);
static qbs::Settings *settings() { return m_settings; }
static Internal::QbsLogSink *logSink() { return m_logSink; }
private slots:
void pushKitsToQbs();
private:
void addProfile(const QString &name, const QVariantMap &data);
void removeCreatorProfiles();
void addQtProfileFromKit(const QString &profileName, const ProjectExplorer::Kit *k);
void addProfileFromKit(const ProjectExplorer::Kit *k);
void handleKitUpdate(ProjectExplorer::Kit *kit);
void handleKitRemoval(ProjectExplorer::Kit *kit);
static Internal::QbsLogSink *m_logSink;
static qbs::Settings *m_settings;
DefaultPropertyProvider *m_defaultPropertyProvider;
QList<ProjectExplorer::Kit *> m_kitsToBeSetupForQbs;
};
} // namespace QbsProjectManager
......
Supports Markdown
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