From 5a041dd474a8677df6a96f952c7f34f5c9edd4c2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 28 Jun 2020 05:50:57 -0400 Subject: [PATCH] CSelectInstanceDialog: Make use of in-class initializers where applicable --- src/Editor/WorldEditor/CSelectInstanceDialog.cpp | 10 ++-------- src/Editor/WorldEditor/CSelectInstanceDialog.h | 14 ++++++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Editor/WorldEditor/CSelectInstanceDialog.cpp b/src/Editor/WorldEditor/CSelectInstanceDialog.cpp index fa277879..ce8af7cd 100644 --- a/src/Editor/WorldEditor/CSelectInstanceDialog.cpp +++ b/src/Editor/WorldEditor/CSelectInstanceDialog.cpp @@ -3,13 +3,10 @@ CSelectInstanceDialog::CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pParent) : QDialog(pParent) - , ui(new Ui::CSelectInstanceDialog) , mpEditor(pEditor) , mLayersModel(pEditor, this) , mTypesModel(pEditor, this) - , mValidSelection(false) - , mpLayersInst(nullptr) - , mpTypesInst(nullptr) + , ui(std::make_unique()) { ui->setupUi(this); @@ -45,10 +42,7 @@ CSelectInstanceDialog::CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pPa connect(ui->TypesTreeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnTreeDoubleClicked(QModelIndex))); } -CSelectInstanceDialog::~CSelectInstanceDialog() -{ - delete ui; -} +CSelectInstanceDialog::~CSelectInstanceDialog() = default; CScriptObject* CSelectInstanceDialog::SelectedInstance() const { diff --git a/src/Editor/WorldEditor/CSelectInstanceDialog.h b/src/Editor/WorldEditor/CSelectInstanceDialog.h index aa20c870..7190d39c 100644 --- a/src/Editor/WorldEditor/CSelectInstanceDialog.h +++ b/src/Editor/WorldEditor/CSelectInstanceDialog.h @@ -6,6 +6,8 @@ #include #include +#include + namespace Ui { class CSelectInstanceDialog; } @@ -20,15 +22,15 @@ class CSelectInstanceDialog : public QDialog CInstancesProxyModel mLayersProxyModel; CInstancesProxyModel mTypesProxyModel; - bool mValidSelection; - CScriptObject *mpLayersInst; - CScriptObject *mpTypesInst; + bool mValidSelection = false; + CScriptObject *mpLayersInst = nullptr; + CScriptObject *mpTypesInst = nullptr; - Ui::CSelectInstanceDialog *ui; + std::unique_ptr ui; public: - explicit CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pParent = 0); - ~CSelectInstanceDialog(); + explicit CSelectInstanceDialog(CWorldEditor *pEditor, QWidget *pParent = nullptr); + ~CSelectInstanceDialog() override; CScriptObject* SelectedInstance() const;