summaryrefslogtreecommitdiff
path: root/src/plugins/vcsbase
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2018-02-19 14:15:05 +0100
committerhjk <hjk@qt.io>2018-02-20 15:03:37 +0000
commit492a17b65b749c992876d3e01be094f6481053c1 (patch)
tree034a484b232b46906f85358bc7b4b3dbb3bbe1c0 /src/plugins/vcsbase
parent432ae65944701980a8fc792d25d792e40968db08 (diff)
downloadqt-creator-492a17b65b749c992876d3e01be094f6481053c1.tar.gz
VcsBasePlugin: Remove last instance of addAutoReleasedObject
Change-Id: I6a622faed0bce39f21c5489afc0df623cb32f801 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r--src/plugins/vcsbase/vcsoutputwindow.cpp6
-rw-r--r--src/plugins/vcsbase/vcsoutputwindow.h8
-rw-r--r--src/plugins/vcsbase/vcsplugin.cpp37
-rw-r--r--src/plugins/vcsbase/vcsplugin.h7
4 files changed, 34 insertions, 24 deletions
diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp
index 8598a6c798..5afe3e2051 100644
--- a/src/plugins/vcsbase/vcsoutputwindow.cpp
+++ b/src/plugins/vcsbase/vcsoutputwindow.cpp
@@ -476,6 +476,12 @@ void VcsOutputWindow::appendMessage(const QString &text)
append(text, Message, true);
}
+void VcsOutputWindow::destroy()
+{
+ delete m_instance;
+ m_instance = nullptr;
+}
+
VcsOutputWindow *VcsOutputWindow::instance()
{
if (!m_instance)
diff --git a/src/plugins/vcsbase/vcsoutputwindow.h b/src/plugins/vcsbase/vcsoutputwindow.h
index 685f03277b..099eaba4c9 100644
--- a/src/plugins/vcsbase/vcsoutputwindow.h
+++ b/src/plugins/vcsbase/vcsoutputwindow.h
@@ -32,14 +32,14 @@
namespace Utils { class FileName; }
namespace VcsBase {
+namespace Internal { class VcsPlugin; }
+
class VCSBASE_EXPORT VcsOutputWindow : public Core::IOutputPane
{
Q_OBJECT
Q_PROPERTY(QString repository READ repository WRITE setRepository)
public:
- ~VcsOutputWindow() override;
-
QWidget *outputWidget(QWidget *parent) override;
QList<QWidget *> toolBarWidgets() const override;
QString displayName() const override;
@@ -115,7 +115,11 @@ public slots:
static void appendMessage(const QString &text);
private:
+ friend class Internal::VcsPlugin;
+ static void destroy();
+
VcsOutputWindow();
+ ~VcsOutputWindow() override;
};
} // namespace VcsBase
diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp
index 43fa11b729..8e21d1cbae 100644
--- a/src/plugins/vcsbase/vcsplugin.cpp
+++ b/src/plugins/vcsbase/vcsplugin.cpp
@@ -48,7 +48,6 @@
#include <utils/macroexpander.h>
-#include <QtPlugin>
#include <QDebug>
using namespace Core;
@@ -57,11 +56,16 @@ using namespace ProjectExplorer;
namespace VcsBase {
namespace Internal {
-VcsPlugin *VcsPlugin::m_instance = 0;
+class VcsPluginPrivate
+{
+public:
+ CommonOptionsPage m_settingsPage;
+ QStandardItemModel *m_nickNameModel = nullptr;
+};
+
+static VcsPlugin *m_instance = nullptr;
-VcsPlugin::VcsPlugin() :
- m_settingsPage(0),
- m_nickNameModel(0)
+VcsPlugin::VcsPlugin()
{
m_instance = this;
}
@@ -69,7 +73,8 @@ VcsPlugin::VcsPlugin() :
VcsPlugin::~VcsPlugin()
{
VcsProjectCache::destroy();
- m_instance = 0;
+ VcsOutputWindow::destroy();
+ m_instance = nullptr;
}
bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
@@ -77,6 +82,8 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
+ d = new VcsPluginPrivate;
+
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
bool result = true;
if (auto se = qobject_cast<VcsBaseSubmitEditor *>(editor))
@@ -84,11 +91,9 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
return result;
});
- m_settingsPage = new CommonOptionsPage;
- addAutoReleasedObject(VcsOutputWindow::instance());
- connect(m_settingsPage, &CommonOptionsPage::settingsChanged,
+ connect(&d->m_settingsPage, &CommonOptionsPage::settingsChanged,
this, &VcsPlugin::settingsChanged);
- connect(m_settingsPage, &CommonOptionsPage::settingsChanged,
+ connect(&d->m_settingsPage, &CommonOptionsPage::settingsChanged,
this, &VcsPlugin::slotSettingsChanged);
slotSettingsChanged();
@@ -140,24 +145,24 @@ VcsPlugin *VcsPlugin::instance()
CommonVcsSettings VcsPlugin::settings() const
{
- return m_settingsPage->settings();
+ return d->m_settingsPage.settings();
}
/* Delayed creation/update of the nick name model. */
QStandardItemModel *VcsPlugin::nickNameModel()
{
- if (!m_nickNameModel) {
- m_nickNameModel = NickNameDialog::createModel(this);
+ if (!d->m_nickNameModel) {
+ d->m_nickNameModel = NickNameDialog::createModel(this);
populateNickNameModel();
}
- return m_nickNameModel;
+ return d->m_nickNameModel;
}
void VcsPlugin::populateNickNameModel()
{
QString errorMessage;
if (!NickNameDialog::populateModelFromMailCapFile(settings().nickNameMailMap,
- m_nickNameModel,
+ d->m_nickNameModel,
&errorMessage)) {
qWarning("%s", qPrintable(errorMessage));
}
@@ -165,7 +170,7 @@ void VcsPlugin::populateNickNameModel()
void VcsPlugin::slotSettingsChanged()
{
- if (m_nickNameModel)
+ if (d->m_nickNameModel)
populateNickNameModel();
}
diff --git a/src/plugins/vcsbase/vcsplugin.h b/src/plugins/vcsbase/vcsplugin.h
index 575426e5d5..a45ef6472e 100644
--- a/src/plugins/vcsbase/vcsplugin.h
+++ b/src/plugins/vcsbase/vcsplugin.h
@@ -38,8 +38,6 @@ class VcsBaseSubmitEditor;
namespace Internal {
class CommonVcsSettings;
-class CommonOptionsPage;
-class CoreListener;
class VcsPlugin : public ExtensionSystem::IPlugin
{
@@ -69,12 +67,9 @@ signals:
private:
void slotSettingsChanged();
-
void populateNickNameModel();
- static VcsPlugin *m_instance;
- CommonOptionsPage *m_settingsPage;
- QStandardItemModel *m_nickNameModel;
+ class VcsPluginPrivate *d = nullptr;
};
} // namespace Internal