diff options
50 files changed, 130 insertions, 144 deletions
diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index 162427342f..d4a3070d69 100644 --- a/src/plugins/projectexplorer/abiwidget.cpp +++ b/src/plugins/projectexplorer/abiwidget.cpp @@ -75,7 +75,7 @@ public: // -------------------------------------------------------------------------- AbiWidget::AbiWidget(QWidget *parent) : QWidget(parent), - d(new Internal::AbiWidgetPrivate) + d(std::make_unique<Internal::AbiWidgetPrivate>()) { auto *layout = new QHBoxLayout(this); layout->setMargin(0); @@ -152,10 +152,7 @@ AbiWidget::AbiWidget(QWidget *parent) : QWidget(parent), setAbis(QList<Abi>(), Abi::hostAbi()); } -AbiWidget::~AbiWidget() -{ - delete d; -} +AbiWidget::~AbiWidget() = default; static Abi selectAbi(const Abi ¤t, const QList<Abi> &abiList) { diff --git a/src/plugins/projectexplorer/abiwidget.h b/src/plugins/projectexplorer/abiwidget.h index 569840bc1f..b8a64dd05c 100644 --- a/src/plugins/projectexplorer/abiwidget.h +++ b/src/plugins/projectexplorer/abiwidget.h @@ -29,6 +29,8 @@ #include <QWidget> +#include <memory> + namespace ProjectExplorer { class Abi; @@ -64,7 +66,7 @@ private: void emitAbiChanged(const Abi ¤t); - Internal::AbiWidgetPrivate *const d; + const std::unique_ptr<Internal::AbiWidgetPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 70b55b7aae..8cb71a9bec 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -165,14 +165,10 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare } ApplicationLauncher::ApplicationLauncher(QObject *parent) : QObject(parent), - d(new ApplicationLauncherPrivate(this)) -{ -} + d(std::make_unique<ApplicationLauncherPrivate>(this)) +{ } -ApplicationLauncher::~ApplicationLauncher() -{ - delete d; -} +ApplicationLauncher::~ApplicationLauncher() = default; void ApplicationLauncher::setProcessChannelMode(QProcess::ProcessChannelMode mode) { diff --git a/src/plugins/projectexplorer/applicationlauncher.h b/src/plugins/projectexplorer/applicationlauncher.h index 29e8ef3961..68376fece0 100644 --- a/src/plugins/projectexplorer/applicationlauncher.h +++ b/src/plugins/projectexplorer/applicationlauncher.h @@ -34,6 +34,8 @@ #include <QProcess> +#include <memory> + namespace Utils { class ProcessHandle; } namespace ProjectExplorer { @@ -79,7 +81,7 @@ signals: void finished(bool success); private: - Internal::ApplicationLauncherPrivate *d; + std::unique_ptr<Internal::ApplicationLauncherPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp index 61a66a1206..cb0734f226 100644 --- a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp +++ b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp @@ -64,7 +64,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto QWidget *parent, const Core::WizardDialogParameters ¶meters) : Core::BaseFileWizard(factory, parameters.extraValues(), parent), - d(new BaseProjectWizardDialogPrivate(new Utils::ProjectIntroPage)) + d(std::make_unique<BaseProjectWizardDialogPrivate>(new Utils::ProjectIntroPage)) { setPath(parameters.defaultPath()); setSelectedPlatform(parameters.selectedPlatform()); @@ -77,7 +77,7 @@ BaseProjectWizardDialog::BaseProjectWizardDialog(const Core::BaseFileWizardFacto QWidget *parent, const Core::WizardDialogParameters ¶meters) : Core::BaseFileWizard(factory, parameters.extraValues(), parent), - d(new BaseProjectWizardDialogPrivate(introPage, introId)) + d(std::make_unique<BaseProjectWizardDialogPrivate>(introPage, introId)) { setPath(parameters.defaultPath()); setSelectedPlatform(parameters.selectedPlatform()); @@ -96,10 +96,7 @@ void BaseProjectWizardDialog::init() connect(this, &QDialog::accepted, this, &BaseProjectWizardDialog::slotAccepted); } -BaseProjectWizardDialog::~BaseProjectWizardDialog() -{ - delete d; -} +BaseProjectWizardDialog::~BaseProjectWizardDialog() = default; QString BaseProjectWizardDialog::projectName() const { diff --git a/src/plugins/projectexplorer/baseprojectwizarddialog.h b/src/plugins/projectexplorer/baseprojectwizarddialog.h index 3cd414e338..98db214c96 100644 --- a/src/plugins/projectexplorer/baseprojectwizarddialog.h +++ b/src/plugins/projectexplorer/baseprojectwizarddialog.h @@ -30,6 +30,8 @@ #include <coreplugin/basefilewizard.h> #include <coreplugin/basefilewizardfactory.h> +#include <memory> + namespace Utils { class ProjectIntroPage; } namespace ProjectExplorer { @@ -82,7 +84,7 @@ private: void slotAccepted(); bool validateCurrentPage() override; - BaseProjectWizardDialogPrivate *d; + std::unique_ptr<BaseProjectWizardDialogPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index db53631f66..10c60357fe 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -103,6 +103,7 @@ static BuildManager *m_instance = nullptr; BuildManager::BuildManager(QObject *parent, QAction *cancelBuildAction) : QObject(parent) { + QTC_CHECK(!m_instance); m_instance = this; d = new BuildManagerPrivate; @@ -166,6 +167,7 @@ BuildManager::~BuildManager() delete d->m_outputWindow; delete d; + d = nullptr; } void BuildManager::aboutToRemoveProject(Project *p) diff --git a/src/plugins/projectexplorer/deploymentdataview.cpp b/src/plugins/projectexplorer/deploymentdataview.cpp index 40f4ad3fb4..bce3bff0b4 100644 --- a/src/plugins/projectexplorer/deploymentdataview.cpp +++ b/src/plugins/projectexplorer/deploymentdataview.cpp @@ -45,7 +45,7 @@ public: using namespace Internal; DeploymentDataView::DeploymentDataView(Target *target, QWidget *parent) : NamedWidget(parent), - d(new DeploymentDataViewPrivate) + d(std::make_unique<DeploymentDataViewPrivate>()) { d->ui.setupUi(this); d->ui.deploymentDataView->setTextElideMode(Qt::ElideMiddle); @@ -60,10 +60,7 @@ DeploymentDataView::DeploymentDataView(Target *target, QWidget *parent) : NamedW updateDeploymentDataModel(); } -DeploymentDataView::~DeploymentDataView() -{ - delete d; -} +DeploymentDataView::~DeploymentDataView() = default; void DeploymentDataView::updateDeploymentDataModel() { diff --git a/src/plugins/projectexplorer/deploymentdataview.h b/src/plugins/projectexplorer/deploymentdataview.h index f8d3b11698..9cc49eaa8f 100644 --- a/src/plugins/projectexplorer/deploymentdataview.h +++ b/src/plugins/projectexplorer/deploymentdataview.h @@ -28,6 +28,8 @@ #include "namedwidget.h" #include "projectexplorer_export.h" +#include <memory> + namespace ProjectExplorer { class Target; @@ -44,7 +46,7 @@ public: private: void updateDeploymentDataModel(); - Internal::DeploymentDataViewPrivate * const d; + const std::unique_ptr<Internal::DeploymentDataViewPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index 9a0e1b0e11..e6d78e4651 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -46,6 +46,7 @@ #include <QVariantList> #include <limits> +#include <memory> namespace ProjectExplorer { namespace Internal { @@ -348,7 +349,7 @@ const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map) return factory; } -DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate) +DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManagerPrivate>()) { if (isInstance) { QTC_ASSERT(!m_instance, return); @@ -370,7 +371,6 @@ DeviceManager::~DeviceManager() delete d->writer; if (m_instance == this) m_instance = nullptr; - delete d; } IDevice::ConstPtr DeviceManager::deviceAt(int idx) const diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.h b/src/plugins/projectexplorer/devicesupport/devicemanager.h index 964e10ff81..2b086f0683 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.h +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.h @@ -31,6 +31,8 @@ #include <QObject> +#include <memory> + namespace QSsh { class SshHostKeyDatabase; } namespace Utils { class FileName; } @@ -101,7 +103,7 @@ private: static Utils::FileName systemSettingsFilePath(const QString &deviceFileRelativePath); 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; diff --git a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp index e1cfb0dfc5..0aa0ac12d6 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.cpp @@ -44,7 +44,7 @@ public: } // namespace Internal DeviceManagerModel::DeviceManagerModel(const DeviceManager *deviceManager, QObject *parent) : - QAbstractListModel(parent), d(new Internal::DeviceManagerModelPrivate) + QAbstractListModel(parent), d(std::make_unique<Internal::DeviceManagerModelPrivate>()) { d->deviceManager = deviceManager; handleDeviceListChanged(); @@ -58,10 +58,7 @@ DeviceManagerModel::DeviceManagerModel(const DeviceManager *deviceManager, QObje this, &DeviceManagerModel::handleDeviceListChanged); } -DeviceManagerModel::~DeviceManagerModel() -{ - delete d; -} +DeviceManagerModel::~DeviceManagerModel() = default; void DeviceManagerModel::setFilter(const QList<Core::Id> &filter) { diff --git a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.h b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.h index 5851699478..da2fee8e46 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanagermodel.h +++ b/src/plugins/projectexplorer/devicesupport/devicemanagermodel.h @@ -30,6 +30,8 @@ #include <QAbstractListModel> +#include <memory> + namespace ProjectExplorer { namespace Internal { class DeviceManagerModelPrivate; } class IDevice; @@ -62,7 +64,7 @@ private: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; bool matchesTypeFilter(const IDevice::ConstPtr &dev) const; - Internal::DeviceManagerModelPrivate * const d; + const std::unique_ptr<Internal::DeviceManagerModelPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp index a51da5de5e..dd6a851929 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.cpp @@ -316,19 +316,14 @@ DeviceProcessItem DeviceProcessesDialogPrivate::selectedProcess() const */ 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) - : QDialog(parent), d(new Internal::DeviceProcessesDialogPrivate(chooser, this)) -{ -} + : QDialog(parent), d(std::make_unique<Internal::DeviceProcessesDialogPrivate>(chooser, this)) +{ } -DeviceProcessesDialog::~DeviceProcessesDialog() -{ - delete d; -} +DeviceProcessesDialog::~DeviceProcessesDialog() = default; void DeviceProcessesDialog::addAcceptButton(const QString &label) { diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.h b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.h index 0f5fcace6b..7876bf6edd 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.h +++ b/src/plugins/projectexplorer/devicesupport/deviceprocessesdialog.h @@ -31,6 +31,8 @@ #include <QDialog> +#include <memory> + namespace ProjectExplorer { class DeviceProcessItem; @@ -58,7 +60,7 @@ public: private: void setKitVisible(bool); - Internal::DeviceProcessesDialogPrivate * const d; + const std::unique_ptr<Internal::DeviceProcessesDialogPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp index 9cdd2d4cb1..e6075da516 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp +++ b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.cpp @@ -51,14 +51,10 @@ public: using namespace Internal; DeviceProcessList::DeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) - : QAbstractItemModel(parent), d(new DeviceProcessListPrivate(device)) -{ -} + : QAbstractItemModel(parent), d(std::make_unique<DeviceProcessListPrivate>(device)) +{ } -DeviceProcessList::~DeviceProcessList() -{ - delete d; -} +DeviceProcessList::~DeviceProcessList() = default; QModelIndex DeviceProcessList::parent(const QModelIndex &) const { diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h index 77f71351ff..6e965b0450 100644 --- a/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h +++ b/src/plugins/projectexplorer/devicesupport/deviceprocesslist.h @@ -30,6 +30,8 @@ #include <QAbstractItemModel> #include <QList> +#include <memory> + namespace ProjectExplorer { namespace Internal { class DeviceProcessListPrivate; } @@ -86,7 +88,7 @@ private: void setFinished(); - Internal::DeviceProcessListPrivate * const d; + const std::unique_ptr<Internal::DeviceProcessListPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/devicetestdialog.cpp b/src/plugins/projectexplorer/devicesupport/devicetestdialog.cpp index 8557292aed..e308b76f46 100644 --- a/src/plugins/projectexplorer/devicesupport/devicetestdialog.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicetestdialog.cpp @@ -50,7 +50,8 @@ public: DeviceTestDialog::DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, QWidget *parent) - : QDialog(parent), d(new DeviceTestDialogPrivate(deviceConfiguration->createDeviceTester())) + : QDialog(parent) + , d(std::make_unique<DeviceTestDialogPrivate>(deviceConfiguration->createDeviceTester())) { d->ui.setupUi(this); @@ -64,10 +65,7 @@ DeviceTestDialog::DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, d->deviceTester->testDevice(deviceConfiguration); } -DeviceTestDialog::~DeviceTestDialog() -{ - delete d; -} +DeviceTestDialog::~DeviceTestDialog() = default; void DeviceTestDialog::reject() { diff --git a/src/plugins/projectexplorer/devicesupport/devicetestdialog.h b/src/plugins/projectexplorer/devicesupport/devicetestdialog.h index 69e7c3c9b5..7263234fbe 100644 --- a/src/plugins/projectexplorer/devicesupport/devicetestdialog.h +++ b/src/plugins/projectexplorer/devicesupport/devicetestdialog.h @@ -29,6 +29,8 @@ #include <QDialog> +#include <memory> + namespace ProjectExplorer { namespace Internal { @@ -37,7 +39,7 @@ class DeviceTestDialog : public QDialog Q_OBJECT public: - DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, QWidget *parent = 0); + DeviceTestDialog(const IDevice::ConstPtr &deviceConfiguration, QWidget *parent = nullptr); ~DeviceTestDialog() override; void reject() override; @@ -50,7 +52,7 @@ private: void addText(const QString &text, const QString &color, bool bold); class DeviceTestDialogPrivate; - DeviceTestDialogPrivate * const d; + const std::unique_ptr<DeviceTestDialogPrivate> d; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 6dd073962c..2ff4090ffd 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -165,7 +165,7 @@ IDevice::IDevice() : d(new Internal::IDevicePrivate) } 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->origin = origin; @@ -177,15 +177,12 @@ IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id IDevice::IDevice(const IDevice &other) : QEnableSharedFromThis<IDevice>(other) - , d(new Internal::IDevicePrivate) + , d(std::make_unique<Internal::IDevicePrivate>()) { *d = *other.d; } -IDevice::~IDevice() -{ - delete d; -} +IDevice::~IDevice() = default; /*! Specifies a free-text name for the device to be displayed in GUI elements. diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index c040fab334..493b7b306e 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -38,6 +38,7 @@ #include <QVariantMap> #include <functional> +#include <memory> QT_BEGIN_NAMESPACE class QWidget; @@ -214,7 +215,7 @@ private: int version() const; - Internal::IDevicePrivate *d; + const std::unique_ptr<Internal::IDevicePrivate> d; friend class DeviceManager; }; diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index a3177944cb..0a4ac513bc 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -63,7 +63,7 @@ public: }; 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); } @@ -71,7 +71,6 @@ SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *par SshDeviceProcess::~SshDeviceProcess() { d->setState(SshDeviceProcessPrivate::Inactive); - delete d; } void SshDeviceProcess::start(const Runnable &runnable) diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index a6de321f3b..19acc31769 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -27,6 +27,8 @@ #include "deviceprocess.h" +#include <memory> + namespace ProjectExplorer { class Runnable; @@ -72,7 +74,7 @@ private: class SshDeviceProcessPrivate; friend class SshDeviceProcessPrivate; - SshDeviceProcessPrivate * const d; + const std::unique_ptr<SshDeviceProcessPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp index a25d56c380..589b3d1721 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp @@ -42,14 +42,11 @@ public: }; SshDeviceProcessList::SshDeviceProcessList(const IDevice::ConstPtr &device, QObject *parent) : - DeviceProcessList(device, parent), d(new SshDeviceProcessListPrivate) + DeviceProcessList(device, parent), d(std::make_unique<SshDeviceProcessListPrivate>()) { } -SshDeviceProcessList::~SshDeviceProcessList() -{ - delete d; -} +SshDeviceProcessList::~SshDeviceProcessList() = default; void SshDeviceProcessList::doUpdate() { diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.h index 9c97ce04ff..8ecefce9b9 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.h @@ -27,6 +27,8 @@ #include "deviceprocesslist.h" +#include <memory> + namespace ProjectExplorer { class PROJECTEXPLORER_EXPORT SshDeviceProcessList : public DeviceProcessList @@ -51,7 +53,7 @@ private: void setFinished(); class SshDeviceProcessListPrivate; - SshDeviceProcessListPrivate * const d; + const std::unique_ptr<SshDeviceProcessListPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp index d6c447ad7f..43f7b79c69 100644 --- a/src/plugins/projectexplorer/editorconfiguration.cpp +++ b/src/plugins/projectexplorer/editorconfiguration.cpp @@ -83,7 +83,7 @@ struct EditorConfigurationPrivate QList<BaseTextEditor *> m_editors; }; -EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate) +EditorConfiguration::EditorConfiguration() : d(std::make_unique<EditorConfigurationPrivate>()) { const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = TextEditorSettings::codeStyles(); QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences); @@ -119,7 +119,6 @@ EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate) EditorConfiguration::~EditorConfiguration() { qDeleteAll(d->m_languageCodeStylePreferences); - delete d; } bool EditorConfiguration::useGlobalSettings() const diff --git a/src/plugins/projectexplorer/editorconfiguration.h b/src/plugins/projectexplorer/editorconfiguration.h index 9f410d6a1e..e9c6138648 100644 --- a/src/plugins/projectexplorer/editorconfiguration.h +++ b/src/plugins/projectexplorer/editorconfiguration.h @@ -30,6 +30,8 @@ #include <QObject> #include <QVariantMap> +#include <memory> + namespace Core { class IEditor; class Id; @@ -107,7 +109,7 @@ signals: private: 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 diff --git a/src/plugins/projectexplorer/environmentwidget.cpp b/src/plugins/projectexplorer/environmentwidget.cpp index fb67c4a4f3..e39f21532b 100644 --- a/src/plugins/projectexplorer/environmentwidget.cpp +++ b/src/plugins/projectexplorer/environmentwidget.cpp @@ -132,7 +132,7 @@ public: }; EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetailsWidget) - : QWidget(parent), d(new EnvironmentWidgetPrivate) + : QWidget(parent), d(std::make_unique<EnvironmentWidgetPrivate>()) { d->m_model = new Utils::EnvironmentModel(); connect(d->m_model, &Utils::EnvironmentModel::userChangesChanged, @@ -235,7 +235,6 @@ EnvironmentWidget::~EnvironmentWidget() { delete d->m_model; d->m_model = nullptr; - delete d; } void EnvironmentWidget::focusIndex(const QModelIndex &index) diff --git a/src/plugins/projectexplorer/environmentwidget.h b/src/plugins/projectexplorer/environmentwidget.h index 380a68917e..004f1cb1e6 100644 --- a/src/plugins/projectexplorer/environmentwidget.h +++ b/src/plugins/projectexplorer/environmentwidget.h @@ -29,6 +29,8 @@ #include <QWidget> +#include <memory> + QT_FORWARD_DECLARE_CLASS(QModelIndex) namespace Utils { @@ -71,7 +73,7 @@ private: void updateButtons(); void linkActivated(const QString &link); - EnvironmentWidgetPrivate *d; + const std::unique_ptr<EnvironmentWidgetPrivate> d; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index 1d5e97add9..e73b44cb90 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -72,7 +72,7 @@ public: ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &source, const Utils::FileNameList &targets, QObject *parent) : - QObject(parent), d(new ExtraCompilerPrivate) + QObject(parent), d(std::make_unique<ExtraCompilerPrivate>()) { d->project = project; d->source = source; @@ -129,10 +129,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &sour } } -ExtraCompiler::~ExtraCompiler() -{ - delete d; -} +ExtraCompiler::~ExtraCompiler() = default; const Project *ExtraCompiler::project() const { diff --git a/src/plugins/projectexplorer/extracompiler.h b/src/plugins/projectexplorer/extracompiler.h index d4ef5326ac..c93830b10c 100644 --- a/src/plugins/projectexplorer/extracompiler.h +++ b/src/plugins/projectexplorer/extracompiler.h @@ -39,6 +39,7 @@ #include <QList> #include <functional> +#include <memory> QT_FORWARD_DECLARE_CLASS(QProcess); QT_FORWARD_DECLARE_CLASS(QThreadPool); @@ -89,7 +90,7 @@ private: virtual void run(const QByteArray &sourceContent) = 0; virtual void run(const Utils::FileName &file) = 0; - ExtraCompilerPrivate *const d; + const std::unique_ptr<ExtraCompilerPrivate> d; }; class PROJECTEXPLORER_EXPORT ProcessExtraCompiler : public ExtraCompiler diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index a2e2cc0722..c4e3477596 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -139,14 +139,13 @@ private: // JsonFieldPage::FieldData: // -------------------------------------------------------------------- -JsonFieldPage::Field::Field() : d(new FieldPrivate) +JsonFieldPage::Field::Field() : d(std::make_unique<FieldPrivate>()) { } JsonFieldPage::Field::~Field() { delete d->m_widget; delete d->m_label; - delete d; } QString JsonFieldPage::Field::type() diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h index 7cdb50c544..e1ddc7b559 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h @@ -33,6 +33,8 @@ #include <QRegularExpression> #include <QVariant> +#include <memory> + QT_BEGIN_NAMESPACE class QFormLayout; class QLabel; @@ -105,7 +107,7 @@ public: friend class JsonFieldPage; - FieldPrivate *const d; + const std::unique_ptr<FieldPrivate> d; }; JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0); diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 02c9ceca05..37d71a2aff 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -132,14 +132,14 @@ public: // ------------------------------------------------------------------------- Kit::Kit(Id id) : - d(new Internal::KitPrivate(id, this)) + d(std::make_unique<Internal::KitPrivate>(id, this)) { foreach (KitInformation *sti, KitManager::kitInformation()) d->m_data.insert(sti->id(), sti->defaultValue(this)); } 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))); @@ -174,10 +174,7 @@ Kit::Kit(const QVariantMap &data) : d->m_sticky.insert(Id::fromString(stickyInfo)); } -Kit::~Kit() -{ - delete d; -} +Kit::~Kit() = default; void Kit::blockNotification() { diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h index 9c5551d8c6..fc57688060 100644 --- a/src/plugins/projectexplorer/kit.h +++ b/src/plugins/projectexplorer/kit.h @@ -33,6 +33,8 @@ #include <QSet> #include <QVariant> +#include <memory> + namespace Utils { class Environment; class MacroExpander; @@ -139,7 +141,7 @@ private: QVariantMap toMap() const; - Internal::KitPrivate *const d; + const std::unique_ptr<Internal::KitPrivate> d; friend class KitInformation; friend class KitManager; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 164f299b3b..01e758cef8 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -526,6 +526,8 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin() delete dd->m_toolChainManager; ProjectPanelFactory::destroyFactories(); delete dd; + dd = nullptr; + m_instance = nullptr; RunWorkerFactory::destroyRemainingRunWorkerFactories(); } diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 028c8e9ccf..85917bcdda 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -606,7 +606,7 @@ public: // ProjectWindow::ProjectWindow() - : d(new ProjectWindowPrivate(this)) + : d(std::make_unique<ProjectWindowPrivate>(this)) { setBackgroundRole(QPalette::Base); @@ -615,10 +615,7 @@ ProjectWindow::ProjectWindow() setContextMenuPolicy(Qt::CustomContextMenu); } -ProjectWindow::~ProjectWindow() -{ - delete d; -} +ProjectWindow::~ProjectWindow() = default; QSize SelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index c50e018620..1aeeb882f9 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -29,6 +29,8 @@ #include <utils/fancymainwindow.h> +#include <memory> + namespace ProjectExplorer { namespace Internal { @@ -59,7 +61,7 @@ public: ~ProjectWindow() override; private: - ProjectWindowPrivate *d; + const std::unique_ptr<ProjectWindowPrivate> d; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 12ded83d40..52cd91751e 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -949,7 +949,7 @@ public: using namespace Internal; RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) : - d(new RunControlPrivate(this, runConfiguration, mode)) + d(std::make_unique<RunControlPrivate>(this, runConfiguration, mode)) { #ifdef WITH_JOURNALD JournaldWatcher::instance()->subscribe(this, [this](const JournaldWatcher::LogEntry &entry) { @@ -981,8 +981,6 @@ RunControl::~RunControl() #ifdef WITH_JOURNALD JournaldWatcher::instance()->unsubscribe(this); #endif - delete d; - d = nullptr; } void RunControl::initiateStart() @@ -1009,7 +1007,7 @@ void RunControl::forceStop() void RunControl::initiateFinish() { - QTimer::singleShot(0, d, &RunControlPrivate::initiateFinish); + QTimer::singleShot(0, d.get(), &RunControlPrivate::initiateFinish); } using WorkerCreators = QHash<Core::Id, RunControl::WorkerCreator>; @@ -1878,14 +1876,10 @@ void RunWorkerPrivate::timerEvent(QTimerEvent *ev) */ RunWorker::RunWorker(RunControl *runControl) - : d(new RunWorkerPrivate(this, runControl)) -{ -} + : d(std::make_unique<RunWorkerPrivate>(this, runControl)) +{ } -RunWorker::~RunWorker() -{ - delete d; -} +RunWorker::~RunWorker() = default; /*! * This function is called by the RunControl once all dependencies diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 506197603f..08797804c0 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -417,7 +417,7 @@ protected: private: friend class Internal::RunControlPrivate; friend class Internal::RunWorkerPrivate; - Internal::RunWorkerPrivate *d; + const std::unique_ptr<Internal::RunWorkerPrivate> d; }; class PROJECTEXPLORER_EXPORT RunWorkerFactory @@ -551,7 +551,7 @@ private: friend class RunWorker; friend class Internal::RunWorkerPrivate; - Internal::RunControlPrivate *d; + const std::unique_ptr<Internal::RunControlPrivate> d; }; diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 06a33c93e2..29d5e2f945 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -153,6 +153,7 @@ SessionManager::~SessionManager() emit m_instance->aboutToUnloadSession(d->m_sessionName); delete d->m_writer; delete d; + d = nullptr; } SessionManager *SessionManager::instance() diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index 1d37a01101..452fcce1b4 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -110,7 +110,7 @@ TargetPrivate::TargetPrivate(Kit *k) : Target::Target(Project *project, Kit *k, _constructor_tag) : ProjectConfiguration(project, k->id()), - d(new TargetPrivate(k)) + d(std::make_unique<TargetPrivate>(k)) { QTC_CHECK(d->m_kit); connect(DeviceManager::instance(), &DeviceManager::updated, this, &Target::updateDeviceState); @@ -144,7 +144,6 @@ Target::~Target() qDeleteAll(d->m_buildConfigurations); qDeleteAll(d->m_deployConfigurations); qDeleteAll(d->m_runConfigurations); - delete d; } void Target::handleKitUpdates(Kit *k) diff --git a/src/plugins/projectexplorer/target.h b/src/plugins/projectexplorer/target.h index 43d7c39796..233fc40b54 100644 --- a/src/plugins/projectexplorer/target.h +++ b/src/plugins/projectexplorer/target.h @@ -30,6 +30,8 @@ #include "subscription.h" +#include <memory> + QT_FORWARD_DECLARE_CLASS(QIcon) namespace Utils { class Environment; } @@ -180,7 +182,7 @@ private: void setActiveBuildConfiguration(BuildConfiguration *configuration); void setActiveDeployConfiguration(DeployConfiguration *configuration); - TargetPrivate *d; + const std::unique_ptr<TargetPrivate> d; friend class Project; }; diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 71d52af9e3..78d7daabc8 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -690,22 +690,19 @@ public: }; TargetGroupItem::TargetGroupItem(const QString &displayName, Project *project) - : d(new TargetGroupItemPrivate(this, project)) + : d(std::make_unique<TargetGroupItemPrivate>(this, project)) { d->m_displayName = displayName; QObject::connect(project, &Project::addedTarget, - d, &TargetGroupItemPrivate::handleTargetAdded, + d.get(), &TargetGroupItemPrivate::handleTargetAdded, Qt::QueuedConnection); QObject::connect(project, &Project::removedTarget, - d, &TargetGroupItemPrivate::handleTargetRemoved); + d.get(), &TargetGroupItemPrivate::handleTargetRemoved); QObject::connect(project, &Project::activeTargetChanged, - d, &TargetGroupItemPrivate::handleTargetChanged, Qt::QueuedConnection); + d.get(), &TargetGroupItemPrivate::handleTargetChanged, Qt::QueuedConnection); } -TargetGroupItem::~TargetGroupItem() -{ - delete d; -} +TargetGroupItem::~TargetGroupItem() = default; TargetGroupItemPrivate::TargetGroupItemPrivate(TargetGroupItem *q, Project *project) : q(q), m_project(project) diff --git a/src/plugins/projectexplorer/targetsettingspanel.h b/src/plugins/projectexplorer/targetsettingspanel.h index 120f112a09..2a6cb04461 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.h +++ b/src/plugins/projectexplorer/targetsettingspanel.h @@ -31,6 +31,8 @@ #include <QCoreApplication> +#include <memory> + namespace ProjectExplorer { class Target; @@ -57,7 +59,7 @@ public: TargetItem *targetItem(Target *target) const; private: - TargetGroupItemPrivate *d; + const std::unique_ptr<TargetGroupItemPrivate> d; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 418d590fee..9c9ca6e832 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -242,7 +242,7 @@ static QToolButton *createFilterButton(const QIcon &icon, const QString &toolTip return button; } -TaskWindow::TaskWindow() : d(new TaskWindowPrivate) +TaskWindow::TaskWindow() : d(std::make_unique<TaskWindowPrivate>()) { d->m_model = new Internal::TaskModel(this); d->m_filter = new Internal::TaskFilterModel(d->m_model); @@ -321,7 +321,6 @@ TaskWindow::~TaskWindow() delete d->m_listview; delete d->m_filter; delete d->m_model; - delete d; } void TaskWindow::delayedInitialization() diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 267402ad1b..290927b47b 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -28,6 +28,8 @@ #include <coreplugin/id.h> #include <coreplugin/ioutputpane.h> +#include <memory> + QT_BEGIN_NAMESPACE class QAction; class QModelIndex; @@ -100,7 +102,7 @@ private: int sizeHintForColumn(int column) const; - TaskWindowPrivate *d; + const std::unique_ptr<TaskWindowPrivate> d; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/toolchain.cpp b/src/plugins/projectexplorer/toolchain.cpp index a28a035d3d..e0c1b113a8 100644 --- a/src/plugins/projectexplorer/toolchain.cpp +++ b/src/plugins/projectexplorer/toolchain.cpp @@ -117,12 +117,11 @@ QString languageId(Language l) // -------------------------------------------------------------------------- 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) : - d(new Internal::ToolChainPrivate(other.d->m_typeId, ManualDetection)) +ToolChain::ToolChain(const ToolChain &other) : ToolChain(other.d->m_typeId, ManualDetection) { d->m_language = other.d->m_language; @@ -140,10 +139,7 @@ void ToolChain::setLanguage(Core::Id language) d->m_language = language; } -ToolChain::~ToolChain() -{ - delete d; -} +ToolChain::~ToolChain() = default; QString ToolChain::displayName() const { diff --git a/src/plugins/projectexplorer/toolchain.h b/src/plugins/projectexplorer/toolchain.h index 59f3b7a402..0f463bf801 100644 --- a/src/plugins/projectexplorer/toolchain.h +++ b/src/plugins/projectexplorer/toolchain.h @@ -39,6 +39,7 @@ #include <QVariantMap> #include <functional> +#include <memory> namespace Utils { class Environment; } @@ -168,7 +169,7 @@ protected: private: void setDetection(Detection d); - Internal::ToolChainPrivate *const d; + const std::unique_ptr<Internal::ToolChainPrivate> d; friend class Internal::ToolChainSettingsAccessor; friend class ToolChainFactory; diff --git a/src/plugins/projectexplorer/toolchainmanager.cpp b/src/plugins/projectexplorer/toolchainmanager.cpp index acaeb8b7d7..2a5c899570 100644 --- a/src/plugins/projectexplorer/toolchainmanager.cpp +++ b/src/plugins/projectexplorer/toolchainmanager.cpp @@ -76,7 +76,7 @@ ToolChainManagerPrivate::~ToolChainManagerPrivate() } static ToolChainManager *m_instance = nullptr; -static ToolChainManagerPrivate *d; +static ToolChainManagerPrivate *d = nullptr; } // namespace Internal @@ -103,8 +103,9 @@ ToolChainManager::ToolChainManager(QObject *parent) : ToolChainManager::~ToolChainManager() { - delete d; m_instance = nullptr; + delete d; + d = nullptr; } ToolChainManager *ToolChainManager::instance() |