forked from qt-creator/qt-creator
ProjectExplorer: Use unique_ptr to store KitInformation
Change-Id: I406b6bed005fb7455e6ee41d81a2f314584a051a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -117,7 +117,7 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
|||||||
|
|
||||||
d = new AndroidPluginPrivate;
|
d = new AndroidPluginPrivate;
|
||||||
|
|
||||||
KitManager::registerKitInformation(new Internal::AndroidGdbServerKitInformation);
|
KitManager::registerKitInformation<Internal::AndroidGdbServerKitInformation>();
|
||||||
|
|
||||||
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
connect(KitManager::instance(), &KitManager::kitsLoaded,
|
||||||
this, &AndroidPlugin::kitsRestored);
|
this, &AndroidPlugin::kitsRestored);
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
|||||||
|
|
||||||
new CMakeToolManager(this);
|
new CMakeToolManager(this);
|
||||||
|
|
||||||
KitManager::registerKitInformation(new CMakeKitInformation);
|
KitManager::registerKitInformation<CMakeKitInformation>();
|
||||||
KitManager::registerKitInformation(new CMakeGeneratorKitInformation);
|
KitManager::registerKitInformation<CMakeGeneratorKitInformation>();
|
||||||
KitManager::registerKitInformation(new CMakeConfigurationKitInformation);
|
KitManager::registerKitInformation<CMakeConfigurationKitInformation>();
|
||||||
|
|
||||||
//menus
|
//menus
|
||||||
ActionContainer *msubproject =
|
ActionContainer *msubproject =
|
||||||
|
|||||||
@@ -3271,7 +3271,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
|||||||
mstart->addSeparator(Constants::G_GENERAL);
|
mstart->addSeparator(Constants::G_GENERAL);
|
||||||
mstart->addSeparator(Constants::G_SPECIAL);
|
mstart->addSeparator(Constants::G_SPECIAL);
|
||||||
|
|
||||||
KitManager::registerKitInformation(new DebuggerKitInformation);
|
KitManager::registerKitInformation<DebuggerKitInformation>();
|
||||||
|
|
||||||
// Task integration.
|
// Task integration.
|
||||||
//: Category under which Analyzer tasks are listed in Issues view
|
//: Category under which Analyzer tasks are listed in Issues view
|
||||||
|
|||||||
@@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/persistentsettings.h>
|
#include <utils/persistentsettings.h>
|
||||||
|
#include <utils/pointeralgorithm.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
|
|
||||||
Kit *m_defaultKit = nullptr;
|
Kit *m_defaultKit = nullptr;
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
QList<KitInformation *> m_informationList;
|
std::vector<std::unique_ptr<KitInformation>> m_informationList;
|
||||||
QList<Kit *> m_kitList;
|
QList<Kit *> m_kitList;
|
||||||
PersistentSettingsWriter *m_writer = nullptr;
|
PersistentSettingsWriter *m_writer = nullptr;
|
||||||
};
|
};
|
||||||
@@ -80,7 +80,6 @@ KitManagerPrivate::~KitManagerPrivate()
|
|||||||
{
|
{
|
||||||
foreach (Kit *k, m_kitList)
|
foreach (Kit *k, m_kitList)
|
||||||
delete k;
|
delete k;
|
||||||
qDeleteAll(m_informationList);
|
|
||||||
delete m_writer;
|
delete m_writer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,22 +246,20 @@ bool KitManager::isLoaded()
|
|||||||
return d->m_initialized;
|
return d->m_initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool greaterPriority(KitInformation *a, KitInformation *b)
|
void KitManager::registerKitInformation(std::unique_ptr<KitInformation> &&ki)
|
||||||
{
|
|
||||||
return a->priority() > b->priority();
|
|
||||||
}
|
|
||||||
|
|
||||||
void KitManager::registerKitInformation(KitInformation *ki)
|
|
||||||
{
|
{
|
||||||
QTC_CHECK(!isLoaded());
|
QTC_CHECK(!isLoaded());
|
||||||
QTC_ASSERT(!d->m_informationList.contains(ki), return );
|
|
||||||
QTC_ASSERT(ki->id().isValid(), return );
|
QTC_ASSERT(ki->id().isValid(), return );
|
||||||
|
QTC_ASSERT(!Utils::contains(d->m_informationList, ki.get()), return );
|
||||||
|
|
||||||
auto it = std::lower_bound(d->m_informationList.begin(),
|
auto it = std::lower_bound(std::begin(d->m_informationList),
|
||||||
d->m_informationList.end(),
|
std::end(d->m_informationList),
|
||||||
ki,
|
ki,
|
||||||
greaterPriority);
|
[](const std::unique_ptr<KitInformation> &a,
|
||||||
d->m_informationList.insert(it, ki);
|
const std::unique_ptr<KitInformation> &b) {
|
||||||
|
return a->priority() > b->priority();
|
||||||
|
});
|
||||||
|
d->m_informationList.insert(it, std::move(ki));
|
||||||
|
|
||||||
if (!isLoaded())
|
if (!isLoaded())
|
||||||
return;
|
return;
|
||||||
@@ -393,7 +390,7 @@ Kit *KitManager::defaultKit()
|
|||||||
|
|
||||||
QList<KitInformation *> KitManager::kitInformation()
|
QList<KitInformation *> KitManager::kitInformation()
|
||||||
{
|
{
|
||||||
return d->m_informationList;
|
return Utils::toRawPointer<QList>(d->m_informationList);
|
||||||
}
|
}
|
||||||
|
|
||||||
KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k)
|
KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k)
|
||||||
@@ -476,7 +473,7 @@ void KitManager::addKit(Kit *k)
|
|||||||
|
|
||||||
{
|
{
|
||||||
KitGuard g(k);
|
KitGuard g(k);
|
||||||
foreach (KitInformation *ki, d->m_informationList) {
|
for (const std::unique_ptr<KitInformation> &ki : d->m_informationList) {
|
||||||
ki->upgrade(k);
|
ki->upgrade(k);
|
||||||
if (!k->hasValue(ki->id()))
|
if (!k->hasValue(ki->id()))
|
||||||
k->setValue(ki->id(), ki->defaultValue(k));
|
k->setValue(ki->id(), ki->defaultValue(k));
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ public:
|
|||||||
static void deregisterKit(Kit *k);
|
static void deregisterKit(Kit *k);
|
||||||
static void setDefaultKit(Kit *k);
|
static void setDefaultKit(Kit *k);
|
||||||
|
|
||||||
static void registerKitInformation(KitInformation *ki);
|
template<typename KI, typename... Args>
|
||||||
|
static void registerKitInformation(Args&&... args) {
|
||||||
|
registerKitInformation(std::make_unique<KI>(std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
|
||||||
static QSet<Core::Id> supportedPlatforms();
|
static QSet<Core::Id> supportedPlatforms();
|
||||||
static QSet<Core::Id> availableFeatures(Core::Id platformId);
|
static QSet<Core::Id> availableFeatures(Core::Id platformId);
|
||||||
@@ -158,6 +161,8 @@ signals:
|
|||||||
private:
|
private:
|
||||||
explicit KitManager(QObject *parent = nullptr);
|
explicit KitManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
static void registerKitInformation(std::unique_ptr<KitInformation> &&ki);
|
||||||
|
|
||||||
// Make sure the this is only called after all
|
// Make sure the this is only called after all
|
||||||
// KitInformation are registered!
|
// KitInformation are registered!
|
||||||
void restoreKits();
|
void restoreKits();
|
||||||
|
|||||||
@@ -556,11 +556,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
IWizardFactory::registerFeatureProvider(new KitFeatureProvider);
|
IWizardFactory::registerFeatureProvider(new KitFeatureProvider);
|
||||||
|
|
||||||
// Register KitInformation:
|
// Register KitInformation:
|
||||||
KitManager::registerKitInformation(new DeviceTypeKitInformation);
|
KitManager::registerKitInformation<DeviceTypeKitInformation>();
|
||||||
KitManager::registerKitInformation(new DeviceKitInformation);
|
KitManager::registerKitInformation<DeviceKitInformation>();
|
||||||
KitManager::registerKitInformation(new ToolChainKitInformation);
|
KitManager::registerKitInformation<ToolChainKitInformation>();
|
||||||
KitManager::registerKitInformation(new SysRootKitInformation);
|
KitManager::registerKitInformation<SysRootKitInformation>();
|
||||||
KitManager::registerKitInformation(new EnvironmentKitInformation);
|
KitManager::registerKitInformation<EnvironmentKitInformation>();
|
||||||
|
|
||||||
IWizardFactory::registerFactoryCreator([]() -> QList<IWizardFactory *> {
|
IWizardFactory::registerFactoryCreator([]() -> QList<IWizardFactory *> {
|
||||||
QList<IWizardFactory *> result;
|
QList<IWizardFactory *> result;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ bool QbsProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
Core::HelpManager::registerDocumentation({Core::ICore::documentationPath() + "/qbs.qch"});
|
Core::HelpManager::registerDocumentation({Core::ICore::documentationPath() + "/qbs.qch"});
|
||||||
|
|
||||||
ProjectManager::registerProjectType<QbsProject>(QmlJSTools::Constants::QBS_MIMETYPE);
|
ProjectManager::registerProjectType<QbsProject>(QmlJSTools::Constants::QBS_MIMETYPE);
|
||||||
KitManager::registerKitInformation(new QbsKitInformation);
|
KitManager::registerKitInformation<QbsKitInformation>();
|
||||||
|
|
||||||
//menus
|
//menus
|
||||||
// Build Menu:
|
// Build Menu:
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
|
|||||||
//create and register objects
|
//create and register objects
|
||||||
ProjectManager::registerProjectType<QmakeProject>(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
ProjectManager::registerProjectType<QmakeProject>(QmakeProjectManager::Constants::PROFILE_MIMETYPE);
|
||||||
|
|
||||||
ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation);
|
ProjectExplorer::KitManager::registerKitInformation<QmakeKitInformation>();
|
||||||
|
|
||||||
IWizardFactory::registerFactoryCreator([] {
|
IWizardFactory::registerFactoryCreator([] {
|
||||||
return QList<IWizardFactory *> {
|
return QList<IWizardFactory *> {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
|
|||||||
|
|
||||||
d = new QtSupportPluginPrivate;
|
d = new QtSupportPluginPrivate;
|
||||||
|
|
||||||
ProjectExplorer::KitManager::registerKitInformation(new QtKitInformation);
|
ProjectExplorer::KitManager::registerKitInformation<QtKitInformation>();
|
||||||
|
|
||||||
(void) new UicGeneratorFactory(this);
|
(void) new UicGeneratorFactory(this);
|
||||||
(void) new QScxmlcGeneratorFactory(this);
|
(void) new QScxmlcGeneratorFactory(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user