1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-28 19:21:04 +00:00

Use std::unique_ptr in EnchantingDialog

This commit is contained in:
Evil Eye 2022-08-31 18:02:12 +02:00
parent 58d08d402a
commit b21c77a026
2 changed files with 6 additions and 12 deletions

View File

@ -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<ItemSelectionDialog>("#{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<ItemSelectionDialog>("#{sSoulGemsWithSouls}");
mItemSelectionDialog->eventItemSelected += MyGUI::newDelegate(this, &EnchantingDialog::onSoulSelected);
mItemSelectionDialog->eventDialogCanceled += MyGUI::newDelegate(this, &EnchantingDialog::onSoulCancel);
mItemSelectionDialog->setVisible(true);

View File

@ -1,6 +1,8 @@
#ifndef MWGUI_ENCHANTINGDIALOG_H
#define MWGUI_ENCHANTINGDIALOG_H
#include <memory>
#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<ItemSelectionDialog> mItemSelectionDialog;
MyGUI::Widget* mChanceLayout;