BareMetal: Don't rely on global object pool anymore

Change-Id: Iaaf0828cbcc3b3df9ec1774579381e36be82e3c7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2018-01-26 17:23:45 +01:00
parent 2052d6fc03
commit 8a8426d7ba
6 changed files with 40 additions and 33 deletions

View File

@@ -39,8 +39,7 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory(QObject *parent) BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory()
: IDeviceFactory(parent)
{ {
} }

View File

@@ -36,7 +36,7 @@ class BareMetalDeviceConfigurationFactory
Q_OBJECT Q_OBJECT
public: public:
BareMetalDeviceConfigurationFactory(QObject *parent = 0); BareMetalDeviceConfigurationFactory();
QString displayNameForId(Core::Id type) const; QString displayNameForId(Core::Id type) const;
QList<Core::Id> availableCreationIds() const; QList<Core::Id> availableCreationIds() const;

View File

@@ -41,17 +41,21 @@
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <QAction>
#include <QMessageBox>
#include <QMainWindow>
#include <QMenu>
#include <QtPlugin>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalPluginRunData
{
public:
BareMetalDeviceConfigurationFactory deviceConfigurationFactory;
BareMetalRunConfigurationFactory runConfigurationFactory;
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
GdbServerProvidersSettingsPage gdbServerProviderSettinsPage;
GdbServerProviderManager gdbServerProviderManager;
};
BareMetalPlugin::BareMetalPlugin() BareMetalPlugin::BareMetalPlugin()
{ {
setObjectName(QLatin1String("BareMetalPlugin")); setObjectName(QLatin1String("BareMetalPlugin"));
@@ -59,30 +63,27 @@ BareMetalPlugin::BareMetalPlugin()
BareMetalPlugin::~BareMetalPlugin() BareMetalPlugin::~BareMetalPlugin()
{ {
delete m_runData;
} }
bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorString) bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorString)
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
Q_UNUSED(errorString) Q_UNUSED(errorString)
addAutoReleasedObject(new BareMetalDeviceConfigurationFactory); m_runData = new BareMetalPluginRunData;
addAutoReleasedObject(new BareMetalRunConfigurationFactory);
addAutoReleasedObject(new BareMetalCustomRunConfigurationFactory);
addAutoReleasedObject(new GdbServerProvidersSettingsPage);
addAutoReleasedObject(new GdbServerProviderManager);
auto constraint = [](RunConfiguration *runConfig) { auto constraint = [](RunConfiguration *runConfig) {
const QByteArray idStr = runConfig->id().name(); const QByteArray idStr = runConfig->id().name();
return runConfig->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix); return runConfig->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix);
}; };
RunControl::registerWorker<BareMetalDebugSupport> RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint); (ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<BareMetalDebugSupport> RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint); (ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
return true; return true;
} }
void BareMetalPlugin::extensionsInitialized() void BareMetalPlugin::extensionsInitialized()

View File

@@ -31,6 +31,8 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalPluginRunData;
class BareMetalPlugin : public ExtensionSystem::IPlugin class BareMetalPlugin : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
@@ -38,10 +40,14 @@ class BareMetalPlugin : public ExtensionSystem::IPlugin
public: public:
BareMetalPlugin(); BareMetalPlugin();
~BareMetalPlugin();
bool initialize(const QStringList &arguments, QString *errorString); private:
void extensionsInitialized(); ~BareMetalPlugin() final;
bool initialize(const QStringList &arguments, QString *errorString) final;
void extensionsInitialized() final;
BareMetalPluginRunData *m_runData;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -51,9 +51,8 @@ const char fileNameKeyC[] = "/gdbserverproviders.xml";
static GdbServerProviderManager *m_instance = 0; static GdbServerProviderManager *m_instance = 0;
GdbServerProviderManager::GdbServerProviderManager(QObject *parent) GdbServerProviderManager::GdbServerProviderManager()
: QObject(parent) : m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
, m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
, m_factories({new DefaultGdbServerProviderFactory, , m_factories({new DefaultGdbServerProviderFactory,
new OpenOcdGdbServerProviderFactory, new OpenOcdGdbServerProviderFactory,
new StLinkUtilGdbServerProviderFactory}) new StLinkUtilGdbServerProviderFactory})

View File

@@ -36,6 +36,7 @@ namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalPlugin; class BareMetalPlugin;
class BareMetalPluginRunData;
class GdbServerProvider; class GdbServerProvider;
class GdbServerProviderFactory; class GdbServerProviderFactory;
@@ -63,7 +64,7 @@ signals:
private: private:
void saveProviders(); void saveProviders();
explicit GdbServerProviderManager(QObject *parent = 0); GdbServerProviderManager();
void restoreProviders(); void restoreProviders();
static void notifyAboutUpdate(GdbServerProvider *); static void notifyAboutUpdate(GdbServerProvider *);
@@ -73,7 +74,8 @@ private:
const Utils::FileName m_configFile; const Utils::FileName m_configFile;
const QList<GdbServerProviderFactory *> m_factories; const QList<GdbServerProviderFactory *> m_factories;
friend class BareMetalPlugin; // for constructor friend class BareMetalPlugin; // for restoreProviders
friend class BareMetalPluginRunData; // for constructor
friend class GdbServerProvider; friend class GdbServerProvider;
}; };