From 3dc25217a13d08d3ea85d2b3ede4023f48b0dd32 Mon Sep 17 00:00:00 2001 From: Lioncache Date: Sun, 30 Nov 2025 16:45:29 -0500 Subject: [PATCH] CPasteNodesCommand: Make use of unique_ptr Same behavior, but simplified allocation handling. --- src/Editor/Undo/CPasteNodesCommand.cpp | 9 ++------- src/Editor/Undo/CPasteNodesCommand.h | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index 03e4a858..de1d0076 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -10,15 +10,10 @@ CPasteNodesCommand::CPasteNodesCommand(CWorldEditor *pEditor, CScriptLayer *pLay const CNodeCopyMimeData *pkMimeData = qobject_cast(qApp->clipboard()->mimeData()); if (pkMimeData) - mpMimeData = new CNodeCopyMimeData(*pkMimeData); - else - mpMimeData = nullptr; + mpMimeData = std::make_unique(*pkMimeData); } -CPasteNodesCommand::~CPasteNodesCommand() -{ - if (mpMimeData) delete mpMimeData; -} +CPasteNodesCommand::~CPasteNodesCommand() = default; void CPasteNodesCommand::undo() { diff --git a/src/Editor/Undo/CPasteNodesCommand.h b/src/Editor/Undo/CPasteNodesCommand.h index 218e231f..74339eb5 100644 --- a/src/Editor/Undo/CPasteNodesCommand.h +++ b/src/Editor/Undo/CPasteNodesCommand.h @@ -6,13 +6,14 @@ #include "Editor/CNodeCopyMimeData.h" #include "Editor/WorldEditor/CWorldEditor.h" #include +#include class CPasteNodesCommand : public IUndoCommand { CWorldEditor *mpEditor; CScriptLayer *mpLayer; CVector3f mPastePoint; - CNodeCopyMimeData *mpMimeData; + std::unique_ptr mpMimeData; CNodePtrList mPastedNodes; CNodePtrList mOriginalSelection; CInstancePtrList mLinkedInstances;