ProjectExplorer: Modernize even more

Use unique_ptr for all *Private classes, except for those
in singletons.

Change-Id: Ib56c31ddedc6e9cf321f15de1f1e697a27ad4089
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tobias Hunger
2018-07-16 13:59:39 +02:00
parent 48850dfa4d
commit 80c2ce118d
50 changed files with 130 additions and 144 deletions

View File

@@ -75,7 +75,7 @@ public:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
AbiWidget::AbiWidget(QWidget *parent) : QWidget(parent), AbiWidget::AbiWidget(QWidget *parent) : QWidget(parent),
d(new Internal::AbiWidgetPrivate) d(std::make_unique<Internal::AbiWidgetPrivate>())
{ {
auto *layout = new QHBoxLayout(this); auto *layout = new QHBoxLayout(this);
layout->setMargin(0); layout->setMargin(0);
@@ -152,10 +152,7 @@ AbiWidget::AbiWidget(QWidget *parent) : QWidget(parent),
setAbis(QList<Abi>(), Abi::hostAbi()); setAbis(QList<Abi>(), Abi::hostAbi());
} }
AbiWidget::~AbiWidget() AbiWidget::~AbiWidget() = default;
{
delete d;
}
static Abi selectAbi(const Abi &current, const QList<Abi> &abiList) static Abi selectAbi(const Abi &current, const QList<Abi> &abiList)
{ {

View File

@@ -29,6 +29,8 @@
#include <QWidget> #include <QWidget>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class Abi; class Abi;
@@ -64,7 +66,7 @@ private:
void emitAbiChanged(const Abi &current); void emitAbiChanged(const Abi &current);
Internal::AbiWidgetPrivate *const d; const std::unique_ptr<Internal::AbiWidgetPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -165,14 +165,10 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
} }
ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent), ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent),
d(new ApplicationLauncherPrivate(this)) d(std::make_unique<ApplicationLauncherPrivate>(this))
{ { }
}
ApplicationLauncher::~ApplicationLauncher() ApplicationLauncher::~ApplicationLauncher() = default;
{
delete d;
}
void ApplicationLauncher::setProcessChannelMode(QProcess::ProcessChannelMode mode) void ApplicationLauncher::setProcessChannelMode(QProcess::ProcessChannelMode mode)
{ {

View File

@@ -34,6 +34,8 @@
#include <QProcess> #include <QProcess>
#include <memory>
namespace Utils { class ProcessHandle; } namespace Utils { class ProcessHandle; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -79,7 +81,7 @@ signals:
void finished(bool success); void finished(bool success);
private: private:
Internal::ApplicationLauncherPrivate *d; std::unique_ptr<Internal::ApplicationLauncherPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -64,7 +64,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
QWidget *parent, QWidget *parent,
const Core::WizardDialogParameters &parameters) : const Core::WizardDialogParameters &parameters) :
Core::BaseFileWizard(factory, parameters.extraValues(), parent), Core::BaseFileWizard(factory, parameters.extraValues(), parent),
d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage)) d(std::make_unique<BaseProjectWizardDialogPrivate>(new Utils::ProjectIntroPage))
{ {
setPath(parameters.defaultPath()); setPath(parameters.defaultPath());
setSelectedPlatform(parameters.selectedPlatform()); setSelectedPlatform(parameters.selectedPlatform());
@@ -77,7 +77,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto
QWidget *parent, QWidget *parent,
const Core::WizardDialogParameters &parameters) : const Core::WizardDialogParameters &parameters) :
Core::BaseFileWizard(factory, parameters.extraValues(), parent), Core::BaseFileWizard(factory, parameters.extraValues(), parent),
d(new BaseProjectWizardDialogPrivate(introPage, introId)) d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId))
{ {
setPath(parameters.defaultPath()); setPath(parameters.defaultPath());
setSelectedPlatform(parameters.selectedPlatform()); setSelectedPlatform(parameters.selectedPlatform());
@@ -96,10 +96,7 @@ void BaseProjectWizardDialog::init()
connect(this, &QDialog::accepted, this, &BaseProjectWizardDialog::slotAccepted); connect(this, &QDialog::accepted, this, &BaseProjectWizardDialog::slotAccepted);
} }
BaseProjectWizardDialog::~BaseProjectWizardDialog() BaseProjectWizardDialog::~BaseProjectWizardDialog() = default;
{
delete d;
}
QString BaseProjectWizardDialog::projectName() const QString BaseProjectWizardDialog::projectName() const
{ {

View File

@@ -30,6 +30,8 @@
#include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizard.h>
#include <coreplugin/basefilewizardfactory.h> #include <coreplugin/basefilewizardfactory.h>
#include <memory>
namespace Utils { class ProjectIntroPage; } namespace Utils { class ProjectIntroPage; }
namespace ProjectExplorer { namespace ProjectExplorer {
@@ -82,7 +84,7 @@ private:
void slotAccepted(); void slotAccepted();
bool validateCurrentPage() override; bool validateCurrentPage() override;
BaseProjectWizardDialogPrivate *d; std::unique_ptr<BaseProjectWizardDialogPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -103,6 +103,7 @@ static BuildManager *m_instance = nullptr;
BuildManager::BuildManager(QObject *parent, QAction *cancelBuildAction) BuildManager::BuildManager(QObject *parent, QAction *cancelBuildAction)
: QObject(parent) : QObject(parent)
{ {
QTC_CHECK(!m_instance);
m_instance = this; m_instance = this;
d = new BuildManagerPrivate; d = new BuildManagerPrivate;
@@ -166,6 +167,7 @@ BuildManager::~BuildManager()
delete d->m_outputWindow; delete d->m_outputWindow;
delete d; delete d;
d = nullptr;
} }
void BuildManager::aboutToRemoveProject(Project *p) void BuildManager::aboutToRemoveProject(Project *p)

View File

@@ -45,7 +45,7 @@ public:
using namespace Internal; using namespace Internal;
DeploymentDataView::DeploymentDataView(Target *target, QWidget *parent) : NamedWidget(parent), DeploymentDataView::DeploymentDataView(Target *target, QWidget *parent) : NamedWidget(parent),
d(new DeploymentDataViewPrivate) d(std::make_unique<DeploymentDataViewPrivate>())
{ {
d->ui.setupUi(this); d->ui.setupUi(this);
d->ui.deploymentDataView->setTextElideMode(Qt::ElideMiddle); d->ui.deploymentDataView->setTextElideMode(Qt::ElideMiddle);
@@ -60,10 +60,7 @@ DeploymentDataView::DeploymentDataView(Target *target, QWidget *parent) : NamedW
updateDeploymentDataModel(); updateDeploymentDataModel();
} }
DeploymentDataView::~DeploymentDataView() DeploymentDataView::~DeploymentDataView() = default;
{
delete d;
}
void DeploymentDataView::updateDeploymentDataModel() void DeploymentDataView::updateDeploymentDataModel()
{ {

View File

@@ -28,6 +28,8 @@
#include "namedwidget.h" #include "namedwidget.h"
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class Target; class Target;
@@ -44,7 +46,7 @@ public:
private: private:
void updateDeploymentDataModel(); void updateDeploymentDataModel();
Internal::DeploymentDataViewPrivate * const d; const std::unique_ptr<Internal::DeploymentDataViewPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -46,6 +46,7 @@
#include <QVariantList> #include <QVariantList>
#include <limits> #include <limits>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
@@ -348,7 +349,7 @@ const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map)
return factory; return factory;
} }
DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate) DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManagerPrivate>())
{ {
if (isInstance) { if (isInstance) {
QTC_ASSERT(!m_instance, return); QTC_ASSERT(!m_instance, return);
@@ -370,7 +371,6 @@ DeviceManager::~DeviceManager()
delete d->writer; delete d->writer;
if (m_instance == this) if (m_instance == this)
m_instance = nullptr; m_instance = nullptr;
delete d;
} }
IDevice::ConstPtr DeviceManager::deviceAt(int idx) const IDevice::ConstPtr DeviceManager::deviceAt(int idx) const

View File

@@ -31,6 +31,8 @@
#include <QObject> #include <QObject>
#include <memory>
namespace QSsh { class SshHostKeyDatabase; } namespace QSsh { class SshHostKeyDatabase; }
namespace Utils { class FileName; } namespace Utils { class FileName; }
@@ -101,7 +103,7 @@ private:
static Utils::FileName systemSettingsFilePath(const QString &deviceFileRelativePath); static Utils::FileName systemSettingsFilePath(const QString &deviceFileRelativePath);
static void copy(const DeviceManager *source, DeviceManager *target, bool deep); static void copy(const DeviceManager *source, DeviceManager *target, bool deep);
Internal::DeviceManagerPrivate * const d; const std::unique_ptr<Internal::DeviceManagerPrivate> d;
static DeviceManager *m_instance; static DeviceManager *m_instance;

View File

@@ -44,7 +44,7 @@ public:
} // namespace Internal } // namespace Internal
DeviceManagerModel::DeviceManagerModel(const DeviceManager *deviceManager, QObject *parent) : DeviceManagerModel::DeviceManagerModel(const DeviceManager *deviceManager, QObject *parent) :
QAbstractListModel(parent), d(new Internal::DeviceManagerModelPrivate) QAbstractListModel(parent), d(std::make_unique<Internal::DeviceManagerModelPrivate>())
{ {
d->deviceManager = deviceManager; d->deviceManager = deviceManager;
handleDeviceListChanged(); handleDeviceListChanged();
@@ -58,10 +58,7 @@ DeviceManagerModel::DeviceManagerModel(const DeviceManager *deviceManager, QObje
this, &DeviceManagerModel::handleDeviceListChanged); this, &DeviceManagerModel::handleDeviceListChanged);
} }
DeviceManagerModel::~DeviceManagerModel() DeviceManagerModel::~DeviceManagerModel() = default;
{
delete d;
}
void DeviceManagerModel::setFilter(const QList<Core::Id> &filter) void DeviceManagerModel::setFilter(const QList<Core::Id> &filter)
{ {

View File

@@ -30,6 +30,8 @@
#include <QAbstractListModel> #include <QAbstractListModel>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { class DeviceManagerModelPrivate; } namespace Internal { class DeviceManagerModelPrivate; }
class IDevice; class IDevice;
@@ -62,7 +64,7 @@ private:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool matchesTypeFilter(const IDevice::ConstPtr &dev) const; bool matchesTypeFilter(const IDevice::ConstPtr &dev) const;
Internal::DeviceManagerModelPrivate * const d; const std::unique_ptr<Internal::DeviceManagerModelPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -316,19 +316,14 @@ DeviceProcessItem DeviceProcessesDialogPrivate::selectedProcess() const
*/ */
DeviceProcessesDialog::DeviceProcessesDialog(QWidget *parent) DeviceProcessesDialog::DeviceProcessesDialog(QWidget *parent)
: QDialog(parent), d(new Internal::DeviceProcessesDialogPrivate(new KitChooser(this), this)) : QDialog(parent), d(std::make_unique<Internal::DeviceProcessesDialogPrivate>(new KitChooser(this), this))
{ { }
}
DeviceProcessesDialog::DeviceProcessesDialog(KitChooser *chooser, QWidget *parent) DeviceProcessesDialog::DeviceProcessesDialog(KitChooser *chooser, QWidget *parent)
: QDialog(parent), d(new Internal::DeviceProcessesDialogPrivate(chooser, this)) : QDialog(parent), d(std::make_unique<Internal::DeviceProcessesDialogPrivate>(chooser, this))
{ { }
}
DeviceProcessesDialog::~DeviceProcessesDialog() DeviceProcessesDialog::~DeviceProcessesDialog() = default;
{
delete d;
}
void DeviceProcessesDialog::addAcceptButton(const QString &label) void DeviceProcessesDialog::addAcceptButton(const QString &label)
{ {

View File

@@ -31,6 +31,8 @@
#include <QDialog> #include <QDialog>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class DeviceProcessItem; class DeviceProcessItem;
@@ -58,7 +60,7 @@ public:
private: private:
void setKitVisible(bool); void setKitVisible(bool);
Internal::DeviceProcessesDialogPrivate * const d; const std::unique_ptr<Internal::DeviceProcessesDialogPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -51,14 +51,10 @@ public:
using namespace Internal; using namespace Internal;
DeviceProcessList::DeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) DeviceProcessList::DeviceProcessList(const IDevice::ConstPtr &device, QObject *parent)
: QAbstractItemModel(parent), d(new DeviceProcessListPrivate(device)) : QAbstractItemModel(parent), d(std::make_unique<DeviceProcessListPrivate>(device))
{ { }
}
DeviceProcessList::~DeviceProcessList() DeviceProcessList::~DeviceProcessList() = default;
{
delete d;
}
QModelIndex DeviceProcessList::parent(const QModelIndex &) const QModelIndex DeviceProcessList::parent(const QModelIndex &) const
{ {

View File

@@ -30,6 +30,8 @@
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QList> #include <QList>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { class DeviceProcessListPrivate; } namespace Internal { class DeviceProcessListPrivate; }
@@ -86,7 +88,7 @@ private:
void setFinished(); void setFinished();
Internal::DeviceProcessListPrivate * const d; const std::unique_ptr<Internal::DeviceProcessListPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -50,7 +50,8 @@ public:
DeviceTestDialog::DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, DeviceTestDialog::DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration,
QWidget *parent) QWidget *parent)
: QDialog(parent), d(new DeviceTestDialogPrivate(deviceConfiguration->createDeviceTester())) : QDialog(parent)
, d(std::make_unique<DeviceTestDialogPrivate>(deviceConfiguration->createDeviceTester()))
{ {
d->ui.setupUi(this); d->ui.setupUi(this);
@@ -64,10 +65,7 @@ DeviceTestDialog::DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration,
d->deviceTester->testDevice(deviceConfiguration); d->deviceTester->testDevice(deviceConfiguration);
} }
DeviceTestDialog::~DeviceTestDialog() DeviceTestDialog::~DeviceTestDialog() = default;
{
delete d;
}
void DeviceTestDialog::reject() void DeviceTestDialog::reject()
{ {

View File

@@ -29,6 +29,8 @@
#include <QDialog> #include <QDialog>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
@@ -37,7 +39,7 @@ class DeviceTestDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, QWidget *parent = 0); DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, QWidget *parent = nullptr);
~DeviceTestDialog() override; ~DeviceTestDialog() override;
void reject() override; void reject() override;
@@ -50,7 +52,7 @@ private:
void addText(const QString &text, const QString &color, bool bold); void addText(const QString &text, const QString &color, bool bold);
class DeviceTestDialogPrivate; class DeviceTestDialogPrivate;
DeviceTestDialogPrivate * const d; const std::unique_ptr<DeviceTestDialogPrivate> d;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -165,7 +165,7 @@ IDevice::IDevice() : d(new Internal::IDevicePrivate)
} }
IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id) IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id)
: d(new Internal::IDevicePrivate) : d(std::make_unique<Internal::IDevicePrivate>())
{ {
d->type = type; d->type = type;
d->origin = origin; d->origin = origin;
@@ -177,15 +177,12 @@ IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id
IDevice::IDevice(const IDevice &other) IDevice::IDevice(const IDevice &other)
: QEnableSharedFromThis<IDevice>(other) : QEnableSharedFromThis<IDevice>(other)
, d(new Internal::IDevicePrivate) , d(std::make_unique<Internal::IDevicePrivate>())
{ {
*d = *other.d; *d = *other.d;
} }
IDevice::~IDevice() IDevice::~IDevice() = default;
{
delete d;
}
/*! /*!
Specifies a free-text name for the device to be displayed in GUI elements. Specifies a free-text name for the device to be displayed in GUI elements.

View File

@@ -38,6 +38,7 @@
#include <QVariantMap> #include <QVariantMap>
#include <functional> #include <functional>
#include <memory>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWidget; class QWidget;
@@ -214,7 +215,7 @@ private:
int version() const; int version() const;
Internal::IDevicePrivate *d; const std::unique_ptr<Internal::IDevicePrivate> d;
friend class DeviceManager; friend class DeviceManager;
}; };

View File

@@ -63,7 +63,7 @@ public:
}; };
SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent) SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent)
: DeviceProcess(device, parent), d(new SshDeviceProcessPrivate(this)) : DeviceProcess(device, parent), d(std::make_unique<SshDeviceProcessPrivate>(this))
{ {
connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout); connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout);
} }
@@ -71,7 +71,6 @@ SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *par
SshDeviceProcess::~SshDeviceProcess() SshDeviceProcess::~SshDeviceProcess()
{ {
d->setState(SshDeviceProcessPrivate::Inactive); d->setState(SshDeviceProcessPrivate::Inactive);
delete d;
} }
void SshDeviceProcess::start(const Runnable &runnable) void SshDeviceProcess::start(const Runnable &runnable)

View File

@@ -27,6 +27,8 @@
#include "deviceprocess.h" #include "deviceprocess.h"
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class Runnable; class Runnable;
@@ -72,7 +74,7 @@ private:
class SshDeviceProcessPrivate; class SshDeviceProcessPrivate;
friend class SshDeviceProcessPrivate; friend class SshDeviceProcessPrivate;
SshDeviceProcessPrivate * const d; const std::unique_ptr<SshDeviceProcessPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -42,14 +42,11 @@ public:
}; };
SshDeviceProcessList::SshDeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) : SshDeviceProcessList::SshDeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) :
DeviceProcessList(device, parent), d(new SshDeviceProcessListPrivate) DeviceProcessList(device, parent), d(std::make_unique<SshDeviceProcessListPrivate>())
{ {
} }
SshDeviceProcessList::~SshDeviceProcessList() SshDeviceProcessList::~SshDeviceProcessList() = default;
{
delete d;
}
void SshDeviceProcessList::doUpdate() void SshDeviceProcessList::doUpdate()
{ {

View File

@@ -27,6 +27,8 @@
#include "deviceprocesslist.h" #include "deviceprocesslist.h"
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT SshDeviceProcessList : public DeviceProcessList class PROJECTEXPLORER_EXPORT SshDeviceProcessList : public DeviceProcessList
@@ -51,7 +53,7 @@ private:
void setFinished(); void setFinished();
class SshDeviceProcessListPrivate; class SshDeviceProcessListPrivate;
SshDeviceProcessListPrivate * const d; const std::unique_ptr<SshDeviceProcessListPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -83,7 +83,7 @@ struct EditorConfigurationPrivate
QList<BaseTextEditor *> m_editors; QList<BaseTextEditor *> m_editors;
}; };
EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate) EditorConfiguration::EditorConfiguration() : d(std::make_unique<EditorConfigurationPrivate>())
{ {
const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = TextEditorSettings::codeStyles(); const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = TextEditorSettings::codeStyles();
QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences); QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences);
@@ -119,7 +119,6 @@ EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
EditorConfiguration::~EditorConfiguration() EditorConfiguration::~EditorConfiguration()
{ {
qDeleteAll(d->m_languageCodeStylePreferences); qDeleteAll(d->m_languageCodeStylePreferences);
delete d;
} }
bool EditorConfiguration::useGlobalSettings() const bool EditorConfiguration::useGlobalSettings() const

View File

@@ -30,6 +30,8 @@
#include <QObject> #include <QObject>
#include <QVariantMap> #include <QVariantMap>
#include <memory>
namespace Core { namespace Core {
class IEditor; class IEditor;
class Id; class Id;
@@ -107,7 +109,7 @@ signals:
private: private:
void switchSettings(TextEditor::TextEditorWidget *baseTextEditor) const; void switchSettings(TextEditor::TextEditorWidget *baseTextEditor) const;
EditorConfigurationPrivate *d; const std::unique_ptr<EditorConfigurationPrivate> d;
}; };
// Return the editor settings in the case it's not null. Otherwise, try to find the project // Return the editor settings in the case it's not null. Otherwise, try to find the project

View File

@@ -132,7 +132,7 @@ public:
}; };
EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget) EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget)
: QWidget(parent), d(new EnvironmentWidgetPrivate) : QWidget(parent), d(std::make_unique<EnvironmentWidgetPrivate>())
{ {
d->m_model = new Utils::EnvironmentModel(); d->m_model = new Utils::EnvironmentModel();
connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged, connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged,
@@ -235,7 +235,6 @@ EnvironmentWidget::~EnvironmentWidget()
{ {
delete d->m_model; delete d->m_model;
d->m_model = nullptr; d->m_model = nullptr;
delete d;
} }
void EnvironmentWidget::focusIndex(const QModelIndex &index) void EnvironmentWidget::focusIndex(const QModelIndex &index)

View File

@@ -29,6 +29,8 @@
#include <QWidget> #include <QWidget>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QModelIndex) QT_FORWARD_DECLARE_CLASS(QModelIndex)
namespace Utils { namespace Utils {
@@ -71,7 +73,7 @@ private:
void updateButtons(); void updateButtons();
void linkActivated(const QString &link); void linkActivated(const QString &link);
EnvironmentWidgetPrivate *d; const std::unique_ptr<EnvironmentWidgetPrivate> d;
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -72,7 +72,7 @@ public:
ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &source, ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &source,
const Utils::FileNameList &targets, QObject *parent) : const Utils::FileNameList &targets, QObject *parent) :
QObject(parent), d(new ExtraCompilerPrivate) QObject(parent), d(std::make_unique<ExtraCompilerPrivate>())
{ {
d->project = project; d->project = project;
d->source = source; d->source = source;
@@ -129,10 +129,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &sour
} }
} }
ExtraCompiler::~ExtraCompiler() ExtraCompiler::~ExtraCompiler() = default;
{
delete d;
}
const Project *ExtraCompiler::project() const const Project *ExtraCompiler::project() const
{ {

View File

@@ -39,6 +39,7 @@
#include <QList> #include <QList>
#include <functional> #include <functional>
#include <memory>
QT_FORWARD_DECLARE_CLASS(QProcess); QT_FORWARD_DECLARE_CLASS(QProcess);
QT_FORWARD_DECLARE_CLASS(QThreadPool); QT_FORWARD_DECLARE_CLASS(QThreadPool);
@@ -89,7 +90,7 @@ private:
virtual void run(const QByteArray &sourceContent) = 0; virtual void run(const QByteArray &sourceContent) = 0;
virtual void run(const Utils::FileName &file) = 0; virtual void run(const Utils::FileName &file) = 0;
ExtraCompilerPrivate *const d; const std::unique_ptr<ExtraCompilerPrivate> d;
}; };
class PROJECTEXPLORER_EXPORT ProcessExtraCompiler : public ExtraCompiler class PROJECTEXPLORER_EXPORT ProcessExtraCompiler : public ExtraCompiler

View File

@@ -139,14 +139,13 @@ private:
// JsonFieldPage::FieldData: // JsonFieldPage::FieldData:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
JsonFieldPage::Field::Field() : d(new FieldPrivate) JsonFieldPage::Field::Field() : d(std::make_unique<FieldPrivate>())
{ } { }
JsonFieldPage::Field::~Field() JsonFieldPage::Field::~Field()
{ {
delete d->m_widget; delete d->m_widget;
delete d->m_label; delete d->m_label;
delete d;
} }
QString JsonFieldPage::Field::type() QString JsonFieldPage::Field::type()

View File

@@ -33,6 +33,8 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QVariant> #include <QVariant>
#include <memory>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QFormLayout; class QFormLayout;
class QLabel; class QLabel;
@@ -105,7 +107,7 @@ public:
friend class JsonFieldPage; friend class JsonFieldPage;
FieldPrivate *const d; const std::unique_ptr<FieldPrivate> d;
}; };
JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0); JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0);

View File

@@ -132,14 +132,14 @@ public:
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Kit::Kit(Id id) : Kit::Kit(Id id) :
d(new Internal::KitPrivate(id, this)) d(std::make_unique<Internal::KitPrivate>(id, this))
{ {
foreach (KitInformation *sti, KitManager::kitInformation()) foreach (KitInformation *sti, KitManager::kitInformation())
d->m_data.insert(sti->id(), sti->defaultValue(this)); d->m_data.insert(sti->id(), sti->defaultValue(this));
} }
Kit::Kit(const QVariantMap &data) : Kit::Kit(const QVariantMap &data) :
d(new Internal::KitPrivate(Id(), this)) d(std::make_unique<Internal::KitPrivate>(Id(), this))
{ {
d->m_id = Id::fromSetting(data.value(QLatin1String(ID_KEY))); d->m_id = Id::fromSetting(data.value(QLatin1String(ID_KEY)));
@@ -174,10 +174,7 @@ Kit::Kit(const QVariantMap &data) :
d->m_sticky.insert(Id::fromString(stickyInfo)); d->m_sticky.insert(Id::fromString(stickyInfo));
} }
Kit::~Kit() Kit::~Kit() = default;
{
delete d;
}
void Kit::blockNotification() void Kit::blockNotification()
{ {

View File

@@ -33,6 +33,8 @@
#include <QSet> #include <QSet>
#include <QVariant> #include <QVariant>
#include <memory>
namespace Utils { namespace Utils {
class Environment; class Environment;
class MacroExpander; class MacroExpander;
@@ -139,7 +141,7 @@ private:
QVariantMap toMap() const; QVariantMap toMap() const;
Internal::KitPrivate *const d; const std::unique_ptr<Internal::KitPrivate> d;
friend class KitInformation; friend class KitInformation;
friend class KitManager; friend class KitManager;

View File

@@ -526,6 +526,8 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin()
delete dd->m_toolChainManager; delete dd->m_toolChainManager;
ProjectPanelFactory::destroyFactories(); ProjectPanelFactory::destroyFactories();
delete dd; delete dd;
dd = nullptr;
m_instance = nullptr;
RunWorkerFactory::destroyRemainingRunWorkerFactories(); RunWorkerFactory::destroyRemainingRunWorkerFactories();
} }

View File

@@ -606,7 +606,7 @@ public:
// //
ProjectWindow::ProjectWindow() ProjectWindow::ProjectWindow()
: d(new ProjectWindowPrivate(this)) : d(std::make_unique<ProjectWindowPrivate>(this))
{ {
setBackgroundRole(QPalette::Base); setBackgroundRole(QPalette::Base);
@@ -615,10 +615,7 @@ ProjectWindow::ProjectWindow()
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
} }
ProjectWindow::~ProjectWindow() ProjectWindow::~ProjectWindow() = default;
{
delete d;
}
QSize SelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const QSize SelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{ {

View File

@@ -29,6 +29,8 @@
#include <utils/fancymainwindow.h> #include <utils/fancymainwindow.h>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
@@ -59,7 +61,7 @@ public:
~ProjectWindow() override; ~ProjectWindow() override;
private: private:
ProjectWindowPrivate *d; const std::unique_ptr<ProjectWindowPrivate> d;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -949,7 +949,7 @@ public:
using namespace Internal; using namespace Internal;
RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) : RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) :
d(new RunControlPrivate(this, runConfiguration, mode)) d(std::make_unique<RunControlPrivate>(this, runConfiguration, mode))
{ {
#ifdef WITH_JOURNALD #ifdef WITH_JOURNALD
JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) { JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) {
@@ -981,8 +981,6 @@ RunControl::~RunControl()
#ifdef WITH_JOURNALD #ifdef WITH_JOURNALD
JournaldWatcher::instance()->unsubscribe(this); JournaldWatcher::instance()->unsubscribe(this);
#endif #endif
delete d;
d = nullptr;
} }
void RunControl::initiateStart() void RunControl::initiateStart()
@@ -1009,7 +1007,7 @@ void RunControl::forceStop()
void RunControl::initiateFinish() void RunControl::initiateFinish()
{ {
QTimer::singleShot(0, d, &RunControlPrivate::initiateFinish); QTimer::singleShot(0, d.get(), &RunControlPrivate::initiateFinish);
} }
using WorkerCreators = QHash<Core::Id, RunControl::WorkerCreator>; using WorkerCreators = QHash<Core::Id, RunControl::WorkerCreator>;
@@ -1878,14 +1876,10 @@ void RunWorkerPrivate::timerEvent(QTimerEvent *ev)
*/ */
RunWorker::RunWorker(RunControl *runControl) RunWorker::RunWorker(RunControl *runControl)
: d(new RunWorkerPrivate(this, runControl)) : d(std::make_unique<RunWorkerPrivate>(this, runControl))
{ { }
}
RunWorker::~RunWorker() RunWorker::~RunWorker() = default;
{
delete d;
}
/*! /*!
* This function is called by the RunControl once all dependencies * This function is called by the RunControl once all dependencies

View File

@@ -417,7 +417,7 @@ protected:
private: private:
friend class Internal::RunControlPrivate; friend class Internal::RunControlPrivate;
friend class Internal::RunWorkerPrivate; friend class Internal::RunWorkerPrivate;
Internal::RunWorkerPrivate *d; const std::unique_ptr<Internal::RunWorkerPrivate> d;
}; };
class PROJECTEXPLORER_EXPORT RunWorkerFactory class PROJECTEXPLORER_EXPORT RunWorkerFactory
@@ -551,7 +551,7 @@ private:
friend class RunWorker; friend class RunWorker;
friend class Internal::RunWorkerPrivate; friend class Internal::RunWorkerPrivate;
Internal::RunControlPrivate *d; const std::unique_ptr<Internal::RunControlPrivate> d;
}; };

View File

@@ -153,6 +153,7 @@ SessionManager::~SessionManager()
emit m_instance->aboutToUnloadSession(d->m_sessionName); emit m_instance->aboutToUnloadSession(d->m_sessionName);
delete d->m_writer; delete d->m_writer;
delete d; delete d;
d = nullptr;
} }
SessionManager *SessionManager::instance() SessionManager *SessionManager::instance()

View File

@@ -110,7 +110,7 @@ TargetPrivate::TargetPrivate(Kit *k) :
Target::Target(Project *project, Kit *k, _constructor_tag) : Target::Target(Project *project, Kit *k, _constructor_tag) :
ProjectConfiguration(project, k->id()), ProjectConfiguration(project, k->id()),
d(new TargetPrivate(k)) d(std::make_unique<TargetPrivate>(k))
{ {
QTC_CHECK(d->m_kit); QTC_CHECK(d->m_kit);
connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState); connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState);
@@ -144,7 +144,6 @@ Target::~Target()
qDeleteAll(d->m_buildConfigurations); qDeleteAll(d->m_buildConfigurations);
qDeleteAll(d->m_deployConfigurations); qDeleteAll(d->m_deployConfigurations);
qDeleteAll(d->m_runConfigurations); qDeleteAll(d->m_runConfigurations);
delete d;
} }
void Target::handleKitUpdates(Kit *k) void Target::handleKitUpdates(Kit *k)

View File

@@ -30,6 +30,8 @@
#include "subscription.h" #include "subscription.h"
#include <memory>
QT_FORWARD_DECLARE_CLASS(QIcon) QT_FORWARD_DECLARE_CLASS(QIcon)
namespace Utils { class Environment; } namespace Utils { class Environment; }
@@ -180,7 +182,7 @@ private:
void setActiveBuildConfiguration(BuildConfiguration *configuration); void setActiveBuildConfiguration(BuildConfiguration *configuration);
void setActiveDeployConfiguration(DeployConfiguration *configuration); void setActiveDeployConfiguration(DeployConfiguration *configuration);
TargetPrivate *d; const std::unique_ptr<TargetPrivate> d;
friend class Project; friend class Project;
}; };

View File

@@ -690,22 +690,19 @@ public:
}; };
TargetGroupItem::TargetGroupItem(const QString &displayName, Project *project) TargetGroupItem::TargetGroupItem(const QString &displayName, Project *project)
: d(new TargetGroupItemPrivate(this, project)) : d(std::make_unique<TargetGroupItemPrivate>(this, project))
{ {
d->m_displayName = displayName; d->m_displayName = displayName;
QObject::connect(project, &Project::addedTarget, QObject::connect(project, &Project::addedTarget,
d, &TargetGroupItemPrivate::handleTargetAdded, d.get(), &TargetGroupItemPrivate::handleTargetAdded,
Qt::QueuedConnection); Qt::QueuedConnection);
QObject::connect(project, &Project::removedTarget, QObject::connect(project, &Project::removedTarget,
d, &TargetGroupItemPrivate::handleTargetRemoved); d.get(), &TargetGroupItemPrivate::handleTargetRemoved);
QObject::connect(project, &Project::activeTargetChanged, QObject::connect(project, &Project::activeTargetChanged,
d, &TargetGroupItemPrivate::handleTargetChanged, Qt::QueuedConnection); d.get(), &TargetGroupItemPrivate::handleTargetChanged, Qt::QueuedConnection);
} }
TargetGroupItem::~TargetGroupItem() TargetGroupItem::~TargetGroupItem() = default;
{
delete d;
}
TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *project) TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *project)
: q(q), m_project(project) : q(q), m_project(project)

View File

@@ -31,6 +31,8 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <memory>
namespace ProjectExplorer { namespace ProjectExplorer {
class Target; class Target;
@@ -57,7 +59,7 @@ public:
TargetItem *targetItem(Target *target) const; TargetItem *targetItem(Target *target) const;
private: private:
TargetGroupItemPrivate *d; const std::unique_ptr<TargetGroupItemPrivate> d;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -242,7 +242,7 @@ static QToolButton *createFilterButton(const QIcon &icon, const QString &toolTip
return button; return button;
} }
TaskWindow::TaskWindow() : d(new TaskWindowPrivate) TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>())
{ {
d->m_model = new Internal::TaskModel(this); d->m_model = new Internal::TaskModel(this);
d->m_filter = new Internal::TaskFilterModel(d->m_model); d->m_filter = new Internal::TaskFilterModel(d->m_model);
@@ -321,7 +321,6 @@ TaskWindow::~TaskWindow()
delete d->m_listview; delete d->m_listview;
delete d->m_filter; delete d->m_filter;
delete d->m_model; delete d->m_model;
delete d;
} }
void TaskWindow::delayedInitialization() void TaskWindow::delayedInitialization()

View File

@@ -28,6 +28,8 @@
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <coreplugin/ioutputpane.h> #include <coreplugin/ioutputpane.h>
#include <memory>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QModelIndex; class QModelIndex;
@@ -100,7 +102,7 @@ private:
int sizeHintForColumn(int column) const; int sizeHintForColumn(int column) const;
TaskWindowPrivate *d; const std::unique_ptr<TaskWindowPrivate> d;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -117,12 +117,11 @@ QString languageId(Language l)
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ToolChain::ToolChain(Core::Id typeId, Detection d) : ToolChain::ToolChain(Core::Id typeId, Detection d) :
d(new Internal::ToolChainPrivate(typeId, d)) d(std::make_unique<Internal::ToolChainPrivate>(typeId, d))
{ {
} }
ToolChain::ToolChain(const ToolChain &other) : ToolChain::ToolChain(const ToolChain &other) : ToolChain(other.d->m_typeId, ManualDetection)
d(new Internal::ToolChainPrivate(other.d->m_typeId, ManualDetection))
{ {
d->m_language = other.d->m_language; d->m_language = other.d->m_language;
@@ -140,10 +139,7 @@ void ToolChain::setLanguage(Core::Id language)
d->m_language = language; d->m_language = language;
} }
ToolChain::~ToolChain() ToolChain::~ToolChain() = default;
{
delete d;
}
QString ToolChain::displayName() const QString ToolChain::displayName() const
{ {

View File

@@ -39,6 +39,7 @@
#include <QVariantMap> #include <QVariantMap>
#include <functional> #include <functional>
#include <memory>
namespace Utils { class Environment; } namespace Utils { class Environment; }
@@ -168,7 +169,7 @@ protected:
private: private:
void setDetection(Detection d); void setDetection(Detection d);
Internal::ToolChainPrivate *const d; const std::unique_ptr<Internal::ToolChainPrivate> d;
friend class Internal::ToolChainSettingsAccessor; friend class Internal::ToolChainSettingsAccessor;
friend class ToolChainFactory; friend class ToolChainFactory;

View File

@@ -76,7 +76,7 @@ ToolChainManagerPrivate::~ToolChainManagerPrivate()
} }
static ToolChainManager *m_instance = nullptr; static ToolChainManager *m_instance = nullptr;
static ToolChainManagerPrivate *d; static ToolChainManagerPrivate *d = nullptr;
} // namespace Internal } // namespace Internal
@@ -103,8 +103,9 @@ ToolChainManager::ToolChainManager(QObject *parent) :
ToolChainManager::~ToolChainManager() ToolChainManager::~ToolChainManager()
{ {
delete d;
m_instance = nullptr; m_instance = nullptr;
delete d;
d = nullptr;
} }
ToolChainManager *ToolChainManager::instance() ToolChainManager *ToolChainManager::instance()