forked from qt-creator/qt-creator
RunConfiguration: Simplify adding of ExtraAspects
This makes the code a bit simpler, at the cost of the factories not having access to the fully specialized RunConfiguration anymore. This is apparently never used and the factories can still use the Id to decide what to do if they really need to. Change-Id: I7d94f85e984ac87e62c6d341c1038e1538aa15df Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -50,7 +50,6 @@ public:
|
|||||||
: ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig")
|
: ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig")
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(tr("AutoTest Debug"));
|
setDefaultDisplayName(tr("AutoTest Debug"));
|
||||||
addExtraAspects();
|
|
||||||
|
|
||||||
// disable QmlDebugger that is enabled by default
|
// disable QmlDebugger that is enabled by default
|
||||||
// might change if debugging QuickTest gets enabled
|
// might change if debugging QuickTest gets enabled
|
||||||
|
@@ -69,7 +69,6 @@ public:
|
|||||||
: RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig")
|
: RunConfiguration(parent, "ClangStaticAnalyzer.DummyRunConfig")
|
||||||
{
|
{
|
||||||
setDefaultDisplayName(tr("Clang Static Analyzer"));
|
setDefaultDisplayName(tr("Clang Static Analyzer"));
|
||||||
addExtraAspects();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "kitinformation.h"
|
#include "kitinformation.h"
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/outputformatter.h>
|
#include <utils/outputformatter.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
|
|
||||||
@@ -204,16 +205,16 @@ void IRunConfigurationAspect::resetProjectToGlobalSettings()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
RunConfiguration::RunConfiguration(Target *target, Core::Id id) :
|
||||||
ProjectConfiguration(target, id),
|
ProjectConfiguration(target, id)
|
||||||
m_aspectsInitialized(false)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(target);
|
Q_ASSERT(target);
|
||||||
ctor();
|
ctor();
|
||||||
|
|
||||||
|
addExtraAspects();
|
||||||
}
|
}
|
||||||
|
|
||||||
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) :
|
||||||
ProjectConfiguration(target, source),
|
ProjectConfiguration(target, source)
|
||||||
m_aspectsInitialized(true)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(target);
|
Q_ASSERT(target);
|
||||||
ctor();
|
ctor();
|
||||||
@@ -231,12 +232,8 @@ RunConfiguration::~RunConfiguration()
|
|||||||
|
|
||||||
void RunConfiguration::addExtraAspects()
|
void RunConfiguration::addExtraAspects()
|
||||||
{
|
{
|
||||||
if (m_aspectsInitialized)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
|
foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects<IRunControlFactory>())
|
||||||
addExtraAspect(factory->createRunConfigurationAspect(this));
|
addExtraAspect(factory->createRunConfigurationAspect(this));
|
||||||
m_aspectsInitialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect)
|
||||||
@@ -326,8 +323,6 @@ Abi RunConfiguration::abi() const
|
|||||||
|
|
||||||
bool RunConfiguration::fromMap(const QVariantMap &map)
|
bool RunConfiguration::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
addExtraAspects();
|
|
||||||
|
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
||||||
aspect->fromMap(map);
|
aspect->fromMap(map);
|
||||||
|
|
||||||
@@ -354,16 +349,12 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
|
|
||||||
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
QList<IRunConfigurationAspect *> RunConfiguration::extraAspects() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_aspectsInitialized, return QList<IRunConfigurationAspect *>());
|
|
||||||
return m_aspects;
|
return m_aspects;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const
|
IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_aspectsInitialized, return nullptr);
|
return Utils::findOrDefault(m_aspects, Utils::equal(&IRunConfigurationAspect::id, id));
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
|
||||||
if (aspect->id() == id)
|
|
||||||
return aspect;
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -443,7 +434,6 @@ RunConfiguration *IRunConfigurationFactory::create(Target *parent, Core::Id id)
|
|||||||
RunConfiguration *rc = doCreate(parent, id);
|
RunConfiguration *rc = doCreate(parent, id);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
rc->addExtraAspects();
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -276,7 +276,6 @@ public:
|
|||||||
|
|
||||||
template <typename T> T *extraAspect() const
|
template <typename T> T *extraAspect() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_aspectsInitialized, return nullptr);
|
|
||||||
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
foreach (IRunConfigurationAspect *aspect, m_aspects)
|
||||||
if (T *result = qobject_cast<T *>(aspect))
|
if (T *result = qobject_cast<T *>(aspect))
|
||||||
return result;
|
return result;
|
||||||
@@ -286,7 +285,6 @@ public:
|
|||||||
virtual Runnable runnable() const;
|
virtual Runnable runnable() const;
|
||||||
virtual Abi abi() const;
|
virtual Abi abi() const;
|
||||||
|
|
||||||
void addExtraAspects();
|
|
||||||
void addExtraAspect(IRunConfigurationAspect *aspect);
|
void addExtraAspect(IRunConfigurationAspect *aspect);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -304,8 +302,9 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void ctor();
|
void ctor();
|
||||||
|
|
||||||
|
void addExtraAspects();
|
||||||
|
|
||||||
QList<IRunConfigurationAspect *> m_aspects;
|
QList<IRunConfigurationAspect *> m_aspects;
|
||||||
bool m_aspectsInitialized;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT IRunConfigurationFactory : public QObject
|
class PROJECTEXPLORER_EXPORT IRunConfigurationFactory : public QObject
|
||||||
|
@@ -398,7 +398,6 @@ void Target::addRunConfiguration(RunConfiguration *rc)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(rc && !d->m_runConfigurations.contains(rc), return);
|
QTC_ASSERT(rc && !d->m_runConfigurations.contains(rc), return);
|
||||||
Q_ASSERT(rc->target() == this);
|
Q_ASSERT(rc->target() == this);
|
||||||
rc->addExtraAspects();
|
|
||||||
|
|
||||||
// Check that we don't have a configuration with the same displayName
|
// Check that we don't have a configuration with the same displayName
|
||||||
QString configurationDisplayName = rc->displayName();
|
QString configurationDisplayName = rc->displayName();
|
||||||
|
Reference in New Issue
Block a user