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 Internal {
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory(QObject *parent)
: IDeviceFactory(parent)
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory()
{
}

View File

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

View File

@@ -41,17 +41,21 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h>
#include <QAction>
#include <QMessageBox>
#include <QMainWindow>
#include <QMenu>
#include <QtPlugin>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
class BareMetalPluginRunData
{
public:
BareMetalDeviceConfigurationFactory deviceConfigurationFactory;
BareMetalRunConfigurationFactory runConfigurationFactory;
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
GdbServerProvidersSettingsPage gdbServerProviderSettinsPage;
GdbServerProviderManager gdbServerProviderManager;
};
BareMetalPlugin::BareMetalPlugin()
{
setObjectName(QLatin1String("BareMetalPlugin"));
@@ -59,6 +63,7 @@ BareMetalPlugin::BareMetalPlugin()
BareMetalPlugin::~BareMetalPlugin()
{
delete m_runData;
}
bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorString)
@@ -66,11 +71,7 @@ bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorStr
Q_UNUSED(arguments)
Q_UNUSED(errorString)
addAutoReleasedObject(new BareMetalDeviceConfigurationFactory);
addAutoReleasedObject(new BareMetalRunConfigurationFactory);
addAutoReleasedObject(new BareMetalCustomRunConfigurationFactory);
addAutoReleasedObject(new GdbServerProvidersSettingsPage);
addAutoReleasedObject(new GdbServerProviderManager);
m_runData = new BareMetalPluginRunData;
auto constraint = [](RunConfiguration *runConfig) {
const QByteArray idStr = runConfig->id().name();

View File

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

View File

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

View File

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