forked from qt-creator/qt-creator
VcsBasePlugin: Remove last instance of addAutoReleasedObject
Change-Id: I6a622faed0bce39f21c5489afc0df623cb32f801 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
VcsPlugin::VcsPlugin() :
|
||||
m_settingsPage(0),
|
||||
m_nickNameModel(0)
|
||||
static VcsPlugin *m_instance = nullptr;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user