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()));
|
||||
}
|
||||
|
||||
|
||||
static QbsProfileManager *m_instance = nullptr;
|
||||
static PropertyProvider &defaultPropertyProvider()
|
||||
{
|
||||
static DefaultPropertyProvider theDefaultPropertyProvider;
|
||||
return theDefaultPropertyProvider;
|
||||
}
|
||||
|
||||
static QString kitNameKeyInQbsSettings(const ProjectExplorer::Kit *kit)
|
||||
{
|
||||
return "preferences.qtcreator.kit." + kit->id().toString();
|
||||
}
|
||||
|
||||
QbsProfileManager::QbsProfileManager() : m_defaultPropertyProvider(new DefaultPropertyProvider)
|
||||
QbsProfileManager::QbsProfileManager()
|
||||
{
|
||||
m_instance = this;
|
||||
|
||||
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,
|
||||
&QbsProfileManager::addProfileFromKit);
|
||||
connect(ProjectExplorer::KitManager::instance(), &ProjectExplorer::KitManager::kitUpdated, this,
|
||||
@@ -114,15 +120,12 @@ QbsProfileManager::QbsProfileManager() : m_defaultPropertyProvider(new DefaultPr
|
||||
this, &QbsProfileManager::updateAllProfiles);
|
||||
}
|
||||
|
||||
QbsProfileManager::~QbsProfileManager()
|
||||
{
|
||||
delete m_defaultPropertyProvider;
|
||||
m_instance = nullptr;
|
||||
}
|
||||
QbsProfileManager::~QbsProfileManager() = default;
|
||||
|
||||
QbsProfileManager *QbsProfileManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
static QbsProfileManager theQbsProfileManager;
|
||||
return &theQbsProfileManager;
|
||||
}
|
||||
|
||||
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
|
||||
// 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)))
|
||||
m_instance->addProfileFromKit(kit);
|
||||
if (instance()->m_kitsToBeSetupForQbs.removeOne(const_cast<ProjectExplorer::Kit *>(kit)))
|
||||
instance()->addProfileFromKit(kit);
|
||||
}
|
||||
|
||||
void QbsProfileManager::updateAllProfiles()
|
||||
@@ -154,7 +157,7 @@ void QbsProfileManager::addProfileFromKit(const ProjectExplorer::Kit *k)
|
||||
runQbsConfig(QbsConfigOp::Set, kitNameKeyInQbsSettings(k), name);
|
||||
|
||||
// set up properties:
|
||||
QVariantMap data = m_defaultPropertyProvider->properties(k, QVariantMap());
|
||||
QVariantMap data = defaultPropertyProvider().properties(k, QVariantMap());
|
||||
for (PropertyProvider *provider : std::as_const(g_propertyProviders)) {
|
||||
if (provider->canHandle(k))
|
||||
data = provider->properties(k, data);
|
||||
|
@@ -12,7 +12,6 @@ namespace ProjectExplorer { class Kit; }
|
||||
|
||||
namespace QbsProjectManager {
|
||||
namespace Internal {
|
||||
class DefaultPropertyProvider;
|
||||
|
||||
QString toJSLiteral(const QVariant &val);
|
||||
QVariant fromJSLiteral(const QString &str);
|
||||
@@ -43,7 +42,6 @@ private:
|
||||
void handleKitUpdate(ProjectExplorer::Kit *kit);
|
||||
void handleKitRemoval(ProjectExplorer::Kit *kit);
|
||||
|
||||
DefaultPropertyProvider *m_defaultPropertyProvider;
|
||||
QList<ProjectExplorer::Kit *> m_kitsToBeSetupForQbs;
|
||||
};
|
||||
|
||||
|
@@ -66,7 +66,6 @@ static QbsProject *currentEditorProject()
|
||||
class QbsProjectManagerPluginPrivate
|
||||
{
|
||||
public:
|
||||
QbsProfileManager manager;
|
||||
QbsBuildConfigurationFactory buildConfigFactory;
|
||||
QbsBuildStepFactory buildStepFactory;
|
||||
QbsCleanStepFactory cleanStepFactory;
|
||||
|
Reference in New Issue
Block a user