aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-02-28 12:27:13 +0100
committerhjk <hjk@qt.io>2020-03-02 09:56:10 +0000
commit722705e1e7f875bd1b449a6ca447911e68b581ad (patch)
treed3a9c38153eea5cfb7427d912aee2c58f20cc00d /src/plugins/autotest
parent9da71b940ad848e7103d5fd86970721c2cfa9480 (diff)
AutoTest: Use normal object for settings
Ownership is clear here. However, since this is accessed via the static plugin interface, this needed some change that access. Change-Id: I9488a242442303dee89006240f787677afab730a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r--src/plugins/autotest/autotestplugin.cpp41
-rw-r--r--src/plugins/autotest/autotestplugin.h6
-rw-r--r--src/plugins/autotest/testframeworkmanager.cpp2
-rw-r--r--src/plugins/autotest/testframeworkmanager.h2
-rw-r--r--src/plugins/autotest/testsettingspage.cpp2
-rw-r--r--src/plugins/autotest/testsettingspage.h4
6 files changed, 26 insertions, 31 deletions
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp
index df73f237c6b..0158b3b3f74 100644
--- a/src/plugins/autotest/autotestplugin.cpp
+++ b/src/plugins/autotest/autotestplugin.cpp
@@ -90,8 +90,8 @@ public:
~AutotestPluginPrivate() override;
AutotestPlugin *q = nullptr;
+
TestFrameworkManager *m_frameworkManager = nullptr;
- TestSettingsPage *m_testSettingPage = nullptr;
TestNavigationWidgetFactory *m_navigationWidgetFactory = nullptr;
TestResultsPane *m_resultsPane = nullptr;
QMap<QString, ChoicePair> m_runconfigCache;
@@ -101,30 +101,31 @@ public:
void onRunSelectedTriggered();
void onRunFileTriggered();
void onRunUnderCursorTriggered(TestRunMode mode);
+
+ TestSettings m_settings;
+ TestSettingsPage m_testSettingPage{&m_settings};
};
-static AutotestPlugin *s_instance = nullptr;
+static AutotestPluginPrivate *dd = nullptr;
static QHash<ProjectExplorer::Project *, TestProjectSettings *> s_projectSettings;
AutotestPlugin::AutotestPlugin()
- : m_settings(new TestSettings)
{
// needed to be used in QueuedConnection connects
qRegisterMetaType<TestResult>();
qRegisterMetaType<TestTreeItem *>();
qRegisterMetaType<TestCodeLocationAndType>();
-
- s_instance = this;
}
AutotestPlugin::~AutotestPlugin()
{
- delete d;
+ delete dd;
}
AutotestPluginPrivate::AutotestPluginPrivate(AutotestPlugin *parent)
: q(parent)
{
+ dd = this; // Needed as the code below access it via the static plugin interface
m_frameworkManager = TestFrameworkManager::instance();
initializeMenuEntries();
m_frameworkManager->registerTestFramework(new QtTestFramework);
@@ -133,7 +134,6 @@ AutotestPluginPrivate::AutotestPluginPrivate(AutotestPlugin *parent)
m_frameworkManager->registerTestFramework(new BoostTestFramework);
m_frameworkManager->synchronizeSettings(ICore::settings());
- m_testSettingPage = new TestSettingsPage(q->settings());
m_navigationWidgetFactory = new TestNavigationWidgetFactory;
m_resultsPane = TestResultsPane::instance();
@@ -146,7 +146,7 @@ AutotestPluginPrivate::AutotestPluginPrivate(AutotestPlugin *parent)
});
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
- m_frameworkManager->activateFrameworksFromSettings(q->settings());
+ m_frameworkManager->activateFrameworksFromSettings(&m_settings);
TestTreeModel::instance()->synchronizeTestFrameworks();
connect(ProjectExplorer::SessionManager::instance(),
@@ -160,13 +160,12 @@ AutotestPluginPrivate::~AutotestPluginPrivate()
{
delete m_navigationWidgetFactory;
delete m_resultsPane;
- delete m_testSettingPage;
delete m_frameworkManager;
}
-QSharedPointer<TestSettings> AutotestPlugin::settings()
+TestSettings *AutotestPlugin::settings()
{
- return s_instance->m_settings;
+ return &dd->m_settings;
}
TestProjectSettings *AutotestPlugin::projectSettings(ProjectExplorer::Project *project)
@@ -247,7 +246,7 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri
Q_UNUSED(arguments)
Q_UNUSED(errorString)
- d = new AutotestPluginPrivate(this);
+ dd = new AutotestPluginPrivate(this);
return true;
}
@@ -263,7 +262,7 @@ void AutotestPlugin::extensionsInitialized()
Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_UCURSOR);
connect(action, &QAction::triggered,
- std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, d, TestRunMode::Run));
+ std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Run));
contextMenu->addSeparator();
contextMenu->addAction(command);
@@ -273,7 +272,7 @@ void AutotestPlugin::extensionsInitialized()
command = ActionManager::registerAction(action, Constants::ACTION_RUN_DBG_UCURSOR);
connect(action, &QAction::triggered,
- std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, d, TestRunMode::Debug));
+ std::bind(&AutotestPluginPrivate::onRunUnderCursorTriggered, dd, TestRunMode::Debug));
contextMenu->addAction(command);
contextMenu->addSeparator();
}
@@ -392,25 +391,25 @@ void AutotestPlugin::updateMenuItemsEnabledState()
void AutotestPlugin::cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice)
{
- if (s_instance)
- s_instance->d->m_runconfigCache.insert(buildTargetKey, choice);
+ if (dd)
+ dd->m_runconfigCache.insert(buildTargetKey, choice);
}
ChoicePair AutotestPlugin::cachedChoiceFor(const QString &buildTargetKey)
{
- return s_instance ? s_instance->d->m_runconfigCache.value(buildTargetKey) : ChoicePair();
+ return dd ? dd->m_runconfigCache.value(buildTargetKey) : ChoicePair();
}
void AutotestPlugin::clearChoiceCache()
{
- if (s_instance)
- s_instance->d->m_runconfigCache.clear();
+ if (dd)
+ dd->m_runconfigCache.clear();
}
void AutotestPlugin::popupResultsPane()
{
- if (s_instance)
- s_instance->d->m_resultsPane->popup(Core::IOutputPane::NoModeSwitch);
+ if (dd)
+ dd->m_resultsPane->popup(Core::IOutputPane::NoModeSwitch);
}
QVector<QObject *> AutotestPlugin::createTestObjects() const
diff --git a/src/plugins/autotest/autotestplugin.h b/src/plugins/autotest/autotestplugin.h
index b34fd95c361..c30db79e12c 100644
--- a/src/plugins/autotest/autotestplugin.h
+++ b/src/plugins/autotest/autotestplugin.h
@@ -29,8 +29,6 @@
#include <extensionsystem/iplugin.h>
-#include <QMap>
-
namespace ProjectExplorer {
class Project;
class RunConfiguration;
@@ -65,7 +63,7 @@ public:
void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;
- static QSharedPointer<TestSettings> settings();
+ static TestSettings *settings();
static TestProjectSettings *projectSettings(ProjectExplorer::Project *project);
static void updateMenuItemsEnabledState();
static void cacheRunConfigChoice(const QString &buildTargetKey, const ChoicePair &choice);
@@ -75,8 +73,6 @@ public:
private:
QVector<QObject *> createTestObjects() const override;
- class AutotestPluginPrivate *d = nullptr;
- const QSharedPointer<TestSettings> m_settings;
};
} // namespace Internal
diff --git a/src/plugins/autotest/testframeworkmanager.cpp b/src/plugins/autotest/testframeworkmanager.cpp
index 43eb59d8476..6a5b48d185f 100644
--- a/src/plugins/autotest/testframeworkmanager.cpp
+++ b/src/plugins/autotest/testframeworkmanager.cpp
@@ -91,7 +91,7 @@ bool TestFrameworkManager::registerTestFramework(ITestFramework *framework)
return true;
}
-void TestFrameworkManager::activateFrameworksFromSettings(QSharedPointer<Internal::TestSettings> settings)
+void TestFrameworkManager::activateFrameworksFromSettings(const Internal::TestSettings *settings)
{
FrameworkIterator it = m_registeredFrameworks.begin();
FrameworkIterator end = m_registeredFrameworks.end();
diff --git a/src/plugins/autotest/testframeworkmanager.h b/src/plugins/autotest/testframeworkmanager.h
index fd0c4bea470..f983a6bb54d 100644
--- a/src/plugins/autotest/testframeworkmanager.h
+++ b/src/plugins/autotest/testframeworkmanager.h
@@ -57,7 +57,7 @@ public:
virtual ~TestFrameworkManager();
bool registerTestFramework(ITestFramework *framework);
- void activateFrameworksFromSettings(QSharedPointer<Internal::TestSettings> settings);
+ void activateFrameworksFromSettings(const Internal::TestSettings *settings);
QString frameworkNameForId(const Core::Id &id) const;
QList<Core::Id> registeredFrameworkIds() const;
QList<Core::Id> sortedRegisteredFrameworkIds() const;
diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp
index 1f0ddca7c5f..4fdfbdf5d3a 100644
--- a/src/plugins/autotest/testsettingspage.cpp
+++ b/src/plugins/autotest/testsettingspage.cpp
@@ -140,7 +140,7 @@ void TestSettingsWidget::onFrameworkItemChanged()
m_ui.frameworksWarn->setVisible(true);
}
-TestSettingsPage::TestSettingsPage(const QSharedPointer<TestSettings> &settings)
+TestSettingsPage::TestSettingsPage(TestSettings *settings)
: m_settings(settings)
{
setId("A.AutoTest.0.General");
diff --git a/src/plugins/autotest/testsettingspage.h b/src/plugins/autotest/testsettingspage.h
index a1005004769..8834511313c 100644
--- a/src/plugins/autotest/testsettingspage.h
+++ b/src/plugins/autotest/testsettingspage.h
@@ -57,14 +57,14 @@ class TestSettingsPage : public Core::IOptionsPage
{
Q_OBJECT
public:
- explicit TestSettingsPage(const QSharedPointer<TestSettings> &settings);
+ explicit TestSettingsPage(TestSettings *settings);
QWidget *widget() override;
void apply() override;
void finish() override { }
private:
- QSharedPointer<TestSettings> m_settings;
+ TestSettings *m_settings;
QPointer<TestSettingsWidget> m_widget;
};