forked from qt-creator/qt-creator
BareMetal: Move DebugServerProviderManager closer to new setup system
Change-Id: Ic8029b0436d4c0e86e0f707632139a2074b296eb Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -4,11 +4,9 @@
|
|||||||
|
|
||||||
#include "baremetalplugin.h"
|
#include "baremetalplugin.h"
|
||||||
|
|
||||||
#include "baremetalconstants.h"
|
|
||||||
#include "baremetaldebugsupport.h"
|
#include "baremetaldebugsupport.h"
|
||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
#include "baremetalrunconfiguration.h"
|
#include "baremetalrunconfiguration.h"
|
||||||
#include "baremetaltr.h"
|
|
||||||
|
|
||||||
#include "debugserverprovidermanager.h"
|
#include "debugserverprovidermanager.h"
|
||||||
|
|
||||||
@@ -18,25 +16,10 @@
|
|||||||
|
|
||||||
namespace BareMetal::Internal {
|
namespace BareMetal::Internal {
|
||||||
|
|
||||||
// BareMetalPluginPrivate
|
|
||||||
|
|
||||||
class BareMetalPluginPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DebugServerProviderManager debugServerProviderManager;
|
|
||||||
};
|
|
||||||
|
|
||||||
// BareMetalPlugin
|
// BareMetalPlugin
|
||||||
|
|
||||||
BareMetalPlugin::~BareMetalPlugin()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BareMetalPlugin::initialize()
|
void BareMetalPlugin::initialize()
|
||||||
{
|
{
|
||||||
d = new BareMetalPluginPrivate;
|
|
||||||
|
|
||||||
setupBareMetalDevice();
|
setupBareMetalDevice();
|
||||||
|
|
||||||
setupIarToolChain();
|
setupIarToolChain();
|
||||||
@@ -49,7 +32,7 @@ void BareMetalPlugin::initialize()
|
|||||||
|
|
||||||
void BareMetalPlugin::extensionsInitialized()
|
void BareMetalPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
DebugServerProviderManager::instance()->restoreProviders();
|
setupDebugServerProviderManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // BareMetal::Internal
|
} // BareMetal::Internal
|
||||||
|
|||||||
@@ -13,13 +13,9 @@ class BareMetalPlugin final : public ExtensionSystem::IPlugin
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BareMetal.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BareMetal.json")
|
||||||
|
|
||||||
~BareMetalPlugin() final;
|
|
||||||
|
|
||||||
void initialize() final;
|
void initialize() final;
|
||||||
void extensionsInitialized() final;
|
void extensionsInitialized() final;
|
||||||
|
|
||||||
class BareMetalPluginPrivate *d = nullptr;
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
private slots:
|
private slots:
|
||||||
void testIarOutputParsers_data();
|
void testIarOutputParsers_data();
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ const char countKeyC[] = "DebugServerProvider.Count";
|
|||||||
const char fileVersionKeyC[] = "Version";
|
const char fileVersionKeyC[] = "Version";
|
||||||
const char fileNameKeyC[] = "debugserverproviders.xml";
|
const char fileNameKeyC[] = "debugserverproviders.xml";
|
||||||
|
|
||||||
static DebugServerProviderManager *m_instance = nullptr;
|
|
||||||
|
|
||||||
// DebugServerProviderManager
|
// DebugServerProviderManager
|
||||||
|
|
||||||
DebugServerProviderManager::DebugServerProviderManager()
|
DebugServerProviderManager::DebugServerProviderManager()
|
||||||
@@ -48,7 +46,6 @@ DebugServerProviderManager::DebugServerProviderManager()
|
|||||||
new StLinkUvscServerProviderFactory,
|
new StLinkUvscServerProviderFactory,
|
||||||
new JLinkUvscServerProviderFactory})
|
new JLinkUvscServerProviderFactory})
|
||||||
{
|
{
|
||||||
m_instance = this;
|
|
||||||
m_writer = new Utils::PersistentSettingsWriter(
|
m_writer = new Utils::PersistentSettingsWriter(
|
||||||
m_configFile, "QtCreatorDebugServerProviders");
|
m_configFile, "QtCreatorDebugServerProviders");
|
||||||
|
|
||||||
@@ -69,14 +66,26 @@ DebugServerProviderManager::~DebugServerProviderManager()
|
|||||||
m_providers.clear();
|
m_providers.clear();
|
||||||
qDeleteAll(m_factories);
|
qDeleteAll(m_factories);
|
||||||
delete m_writer;
|
delete m_writer;
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DebugServerProviderManager *m_instance = nullptr;
|
||||||
|
|
||||||
DebugServerProviderManager *DebugServerProviderManager::instance()
|
DebugServerProviderManager *DebugServerProviderManager::instance()
|
||||||
{
|
{
|
||||||
|
if (!m_instance) {
|
||||||
|
m_instance = new DebugServerProviderManager;
|
||||||
|
m_instance->restoreProviders();
|
||||||
|
}
|
||||||
|
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupDebugServerProviderManager(QObject *guard)
|
||||||
|
{
|
||||||
|
DebugServerProviderManager::instance(); // force creation
|
||||||
|
m_instance->setParent(guard);
|
||||||
|
}
|
||||||
|
|
||||||
void DebugServerProviderManager::restoreProviders()
|
void DebugServerProviderManager::restoreProviders()
|
||||||
{
|
{
|
||||||
PersistentSettingsReader reader;
|
PersistentSettingsReader reader;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ namespace Utils { class PersistentSettingsWriter; }
|
|||||||
namespace BareMetal::Internal {
|
namespace BareMetal::Internal {
|
||||||
|
|
||||||
class BareMetalPlugin;
|
class BareMetalPlugin;
|
||||||
class BareMetalPluginPrivate;
|
|
||||||
class IDebugServerProvider;
|
class IDebugServerProvider;
|
||||||
class IDebugServerProviderFactory;
|
class IDebugServerProviderFactory;
|
||||||
|
|
||||||
@@ -25,7 +24,6 @@ class DebugServerProviderManager final : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static DebugServerProviderManager *instance();
|
static DebugServerProviderManager *instance();
|
||||||
~DebugServerProviderManager() final;
|
|
||||||
|
|
||||||
static QList<IDebugServerProvider *> providers();
|
static QList<IDebugServerProvider *> providers();
|
||||||
static QList<IDebugServerProviderFactory *> factories();
|
static QList<IDebugServerProviderFactory *> factories();
|
||||||
@@ -42,9 +40,10 @@ signals:
|
|||||||
void providersLoaded();
|
void providersLoaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveProviders();
|
|
||||||
DebugServerProviderManager();
|
DebugServerProviderManager();
|
||||||
|
~DebugServerProviderManager() final;
|
||||||
|
|
||||||
|
void saveProviders();
|
||||||
void restoreProviders();
|
void restoreProviders();
|
||||||
static void notifyAboutUpdate(IDebugServerProvider *provider);
|
static void notifyAboutUpdate(IDebugServerProvider *provider);
|
||||||
|
|
||||||
@@ -53,9 +52,9 @@ private:
|
|||||||
const Utils::FilePath m_configFile;
|
const Utils::FilePath m_configFile;
|
||||||
const QList<IDebugServerProviderFactory *> m_factories;
|
const QList<IDebugServerProviderFactory *> m_factories;
|
||||||
|
|
||||||
friend class BareMetalPlugin; // for restoreProviders
|
|
||||||
friend class BareMetalPluginPrivate; // for constructor
|
|
||||||
friend class IDebugServerProvider;
|
friend class IDebugServerProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void setupDebugServerProviderManager(QObject *guard);
|
||||||
|
|
||||||
} // BareMetal::Internal
|
} // BareMetal::Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user