CPasteNodesCommand: Make use of unique_ptr

Same behavior, but simplified allocation handling.
This commit is contained in:
Lioncache
2025-11-30 16:45:29 -05:00
parent 43eae548ac
commit 3dc25217a1
2 changed files with 4 additions and 8 deletions

View File

@@ -10,15 +10,10 @@ CPasteNodesCommand::CPasteNodesCommand(CWorldEditor *pEditor, CScriptLayer *pLay
const CNodeCopyMimeData *pkMimeData = qobject_cast<const CNodeCopyMimeData*>(qApp->clipboard()->mimeData());
if (pkMimeData)
mpMimeData = new CNodeCopyMimeData(*pkMimeData);
else
mpMimeData = nullptr;
mpMimeData = std::make_unique<CNodeCopyMimeData>(*pkMimeData);
}
CPasteNodesCommand::~CPasteNodesCommand()
{
if (mpMimeData) delete mpMimeData;
}
CPasteNodesCommand::~CPasteNodesCommand() = default;
void CPasteNodesCommand::undo()
{

View File

@@ -6,13 +6,14 @@
#include "Editor/CNodeCopyMimeData.h"
#include "Editor/WorldEditor/CWorldEditor.h"
#include <QClipboard>
#include <memory>
class CPasteNodesCommand : public IUndoCommand
{
CWorldEditor *mpEditor;
CScriptLayer *mpLayer;
CVector3f mPastePoint;
CNodeCopyMimeData *mpMimeData;
std::unique_ptr<CNodeCopyMimeData> mpMimeData;
CNodePtrList mPastedNodes;
CNodePtrList mOriginalSelection;
CInstancePtrList mLinkedInstances;