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