From b21c77a0267e499e78d18391af0017d87e9c3bde Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Wed, 31 Aug 2022 18:02:12 +0200 Subject: [PATCH] Use std::unique_ptr in EnchantingDialog --- apps/openmw/mwgui/enchantingdialog.cpp | 12 ++---------- apps/openmw/mwgui/enchantingdialog.hpp | 6 ++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index cb4203eb1c..582aeded24 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -34,7 +34,6 @@ namespace MWGui EnchantingDialog::EnchantingDialog() : WindowBase("openmw_enchanting_dialog.layout") , EffectEditorBase(EffectEditorBase::Enchanting) - , mItemSelectionDialog(nullptr) { getWidget(mName, "NameEdit"); getWidget(mCancelButton, "CancelButton"); @@ -62,11 +61,6 @@ namespace MWGui mName->eventEditSelectAccept += MyGUI::newDelegate(this, &EnchantingDialog::onAccept); } - EnchantingDialog::~EnchantingDialog() - { - delete mItemSelectionDialog; - } - void EnchantingDialog::onOpen() { center(); @@ -195,8 +189,7 @@ namespace MWGui { if (mEnchanting.getOldItem().isEmpty()) { - delete mItemSelectionDialog; - mItemSelectionDialog = new ItemSelectionDialog("#{sEnchantItems}"); + mItemSelectionDialog = std::make_unique("#{sEnchantItems}"); mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onItemSelected); mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onItemCancel); mItemSelectionDialog->setVisible(true); @@ -250,8 +243,7 @@ namespace MWGui { if (mEnchanting.getGem().isEmpty()) { - delete mItemSelectionDialog; - mItemSelectionDialog = new ItemSelectionDialog("#{sSoulGemsWithSouls}"); + mItemSelectionDialog = std::make_unique("#{sSoulGemsWithSouls}"); mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected); mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel); mItemSelectionDialog->setVisible(true); diff --git a/apps/openmw/mwgui/enchantingdialog.hpp b/apps/openmw/mwgui/enchantingdialog.hpp index 52f3aa34b8..779dce972b 100644 --- a/apps/openmw/mwgui/enchantingdialog.hpp +++ b/apps/openmw/mwgui/enchantingdialog.hpp @@ -1,6 +1,8 @@ #ifndef MWGUI_ENCHANTINGDIALOG_H #define MWGUI_ENCHANTINGDIALOG_H +#include + #include "spellcreationdialog.hpp" #include "../mwmechanics/enchanting.hpp" @@ -15,7 +17,7 @@ namespace MWGui { public: EnchantingDialog(); - virtual ~EnchantingDialog(); + virtual ~EnchantingDialog() = default; void onOpen() override; @@ -48,7 +50,7 @@ namespace MWGui void onTypeButtonClicked(MyGUI::Widget* sender); void onAccept(MyGUI::EditBox* sender); - ItemSelectionDialog* mItemSelectionDialog; + std::unique_ptr mItemSelectionDialog; MyGUI::Widget* mChanceLayout;