forked from qt-creator/qt-creator
QbsProjectManager: Create QbsProfileManager on request
Task-number: QTCREATORBUG-29546 Change-Id: Ib50ce8cacb4ef26346d0b43401f97093c1c75155 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -89,21 +89,27 @@ QString toJSLiteral(const QVariant &val)
|
|||||||
return QString::fromLatin1("Unconvertible type %1").arg(QLatin1String(val.typeName()));
|
return QString::fromLatin1("Unconvertible type %1").arg(QLatin1String(val.typeName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PropertyProvider &defaultPropertyProvider()
|
||||||
static QbsProfileManager *m_instance = nullptr;
|
{
|
||||||
|
static DefaultPropertyProvider theDefaultPropertyProvider;
|
||||||
|
return theDefaultPropertyProvider;
|
||||||
|
}
|
||||||
|
|
||||||
static QString kitNameKeyInQbsSettings(const ProjectExplorer::Kit *kit)
|
static QString kitNameKeyInQbsSettings(const ProjectExplorer::Kit *kit)
|
||||||
{
|
{
|
||||||
return "preferences.qtcreator.kit." + kit->id().toString();
|
return "preferences.qtcreator.kit." + kit->id().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QbsProfileManager::QbsProfileManager() : m_defaultPropertyProvider(new DefaultPropertyProvider)
|
QbsProfileManager::QbsProfileManager()
|
||||||
{
|
{
|
||||||
m_instance = this;
|
|
||||||
|
|
||||||
setObjectName(QLatin1String("QbsProjectManager"));
|
setObjectName(QLatin1String("QbsProjectManager"));
|
||||||
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitsLoaded, this,
|
|
||||||
[this] { m_kitsToBeSetupForQbs = ProjectExplorer::KitManager::kits(); } );
|
if (ProjectExplorer::KitManager::instance()->isLoaded()) {
|
||||||
|
m_kitsToBeSetupForQbs = ProjectExplorer::KitManager::kits();
|
||||||
|
} else {
|
||||||
|
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitsLoaded,
|
||||||
|
this, [this] { m_kitsToBeSetupForQbs = ProjectExplorer::KitManager::kits(); } );
|
||||||
|
}
|
||||||
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitAdded, this,
|
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitAdded, this,
|
||||||
&QbsProfileManager::addProfileFromKit);
|
&QbsProfileManager::addProfileFromKit);
|
||||||
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitUpdated, this,
|
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitUpdated, this,
|
||||||
@@ -114,15 +120,12 @@ QbsProfileManager::QbsProfileManager() : m_defaultPropertyProvider(new DefaultPr
|
|||||||
this, &QbsProfileManager::updateAllProfiles);
|
this, &QbsProfileManager::updateAllProfiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
QbsProfileManager::~QbsProfileManager()
|
QbsProfileManager::~QbsProfileManager() = default;
|
||||||
{
|
|
||||||
delete m_defaultPropertyProvider;
|
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QbsProfileManager *QbsProfileManager::instance()
|
QbsProfileManager *QbsProfileManager::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
static QbsProfileManager theQbsProfileManager;
|
||||||
|
return &theQbsProfileManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QbsProfileManager::ensureProfileForKit(const ProjectExplorer::Kit *k)
|
QString QbsProfileManager::ensureProfileForKit(const ProjectExplorer::Kit *k)
|
||||||
@@ -137,8 +140,8 @@ void QbsProfileManager::updateProfileIfNecessary(const ProjectExplorer::Kit *kit
|
|||||||
{
|
{
|
||||||
// kit in list <=> profile update 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.
|
// Note that the const_cast is safe, as we do not call any non-const methods on the object.
|
||||||
if (m_instance->m_kitsToBeSetupForQbs.removeOne(const_cast<ProjectExplorer::Kit *>(kit)))
|
if (instance()->m_kitsToBeSetupForQbs.removeOne(const_cast<ProjectExplorer::Kit *>(kit)))
|
||||||
m_instance->addProfileFromKit(kit);
|
instance()->addProfileFromKit(kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsProfileManager::updateAllProfiles()
|
void QbsProfileManager::updateAllProfiles()
|
||||||
@@ -154,7 +157,7 @@ void QbsProfileManager::addProfileFromKit(const ProjectExplorer::Kit *k)
|
|||||||
runQbsConfig(QbsConfigOp::Set, kitNameKeyInQbsSettings(k), name);
|
runQbsConfig(QbsConfigOp::Set, kitNameKeyInQbsSettings(k), name);
|
||||||
|
|
||||||
// set up properties:
|
// set up properties:
|
||||||
QVariantMap data = m_defaultPropertyProvider->properties(k, QVariantMap());
|
QVariantMap data = defaultPropertyProvider().properties(k, QVariantMap());
|
||||||
for (PropertyProvider *provider : std::as_const(g_propertyProviders)) {
|
for (PropertyProvider *provider : std::as_const(g_propertyProviders)) {
|
||||||
if (provider->canHandle(k))
|
if (provider->canHandle(k))
|
||||||
data = provider->properties(k, data);
|
data = provider->properties(k, data);
|
||||||
|
@@ -12,7 +12,6 @@ namespace ProjectExplorer { class Kit; }
|
|||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class DefaultPropertyProvider;
|
|
||||||
|
|
||||||
QString toJSLiteral(const QVariant &val);
|
QString toJSLiteral(const QVariant &val);
|
||||||
QVariant fromJSLiteral(const QString &str);
|
QVariant fromJSLiteral(const QString &str);
|
||||||
@@ -43,7 +42,6 @@ private:
|
|||||||
void handleKitUpdate(ProjectExplorer::Kit *kit);
|
void handleKitUpdate(ProjectExplorer::Kit *kit);
|
||||||
void handleKitRemoval(ProjectExplorer::Kit *kit);
|
void handleKitRemoval(ProjectExplorer::Kit *kit);
|
||||||
|
|
||||||
DefaultPropertyProvider *m_defaultPropertyProvider;
|
|
||||||
QList<ProjectExplorer::Kit *> m_kitsToBeSetupForQbs;
|
QList<ProjectExplorer::Kit *> m_kitsToBeSetupForQbs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -66,7 +66,6 @@ static QbsProject *currentEditorProject()
|
|||||||
class QbsProjectManagerPluginPrivate
|
class QbsProjectManagerPluginPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QbsProfileManager manager;
|
|
||||||
QbsBuildConfigurationFactory buildConfigFactory;
|
QbsBuildConfigurationFactory buildConfigFactory;
|
||||||
QbsBuildStepFactory buildStepFactory;
|
QbsBuildStepFactory buildStepFactory;
|
||||||
QbsCleanStepFactory cleanStepFactory;
|
QbsCleanStepFactory cleanStepFactory;
|
||||||
|
Reference in New Issue
Block a user