Prefer unique_ptr to a raw pointer for CommandAdjustNodeGroup's members
Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// include the required headers
|
||||
#include "NodeGroupCommands.h"
|
||||
#include "CommandManager.h"
|
||||
#include <EMotionFX/Source/NodeGroup.h>
|
||||
#include <EMotionFX/Source/Allocators.h>
|
||||
#include <EMotionFX/Source/ActorManager.h>
|
||||
#include <MCore/Source/LogManager.h>
|
||||
#include <MCore/Source/StringConversions.h>
|
||||
@@ -28,13 +28,6 @@ namespace CommandSystem
|
||||
}
|
||||
|
||||
|
||||
// destructor
|
||||
CommandAdjustNodeGroup::~CommandAdjustNodeGroup()
|
||||
{
|
||||
delete mOldNodeGroup;
|
||||
}
|
||||
|
||||
|
||||
// execute
|
||||
bool CommandAdjustNodeGroup::Execute(const MCore::CommandLine& parameters, AZStd::string& outResult)
|
||||
{
|
||||
@@ -60,10 +53,7 @@ namespace CommandSystem
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy the old node group for undo
|
||||
delete mOldNodeGroup;
|
||||
|
||||
mOldNodeGroup = aznew EMotionFX::NodeGroup(*nodeGroup);
|
||||
mOldNodeGroup = AZStd::make_unique<EMotionFX::NodeGroup>(*nodeGroup);
|
||||
|
||||
// check if newName is set and apply new name
|
||||
if (parameters.CheckIfHasParameter("newName"))
|
||||
@@ -228,8 +218,6 @@ namespace CommandSystem
|
||||
}
|
||||
}
|
||||
|
||||
delete mOldNodeGroup;
|
||||
|
||||
mOldNodeGroup = nullptr;
|
||||
|
||||
// set the dirty flag back to the old value
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
#pragma once
|
||||
|
||||
// include the required headers
|
||||
#include <AzCore/std/smart_ptr/unique_ptr.h>
|
||||
#include "CommandSystemConfig.h"
|
||||
#include <MCore/Source/Command.h>
|
||||
#include <MCore/Source/CommandGroup.h>
|
||||
#include <EMotionFX/Source/EMotionFXConfig.h>
|
||||
#include <EMotionFX/Source/NodeGroup.h>
|
||||
#include <EMotionFX/CommandSystem/Source/ParameterMixins.h>
|
||||
|
||||
EMFX_FORWARD_DECLARE(Actor);
|
||||
EMFX_FORWARD_DECLARE(NodeGroup);
|
||||
@@ -20,20 +23,41 @@ EMFX_FORWARD_DECLARE(NodeGroup);
|
||||
namespace CommandSystem
|
||||
{
|
||||
// adjust a node group
|
||||
MCORE_DEFINECOMMAND_START(CommandAdjustNodeGroup, "Adjust node group", true)
|
||||
bool mOldDirtyFlag;
|
||||
EMotionFX::NodeGroup* mOldNodeGroup = nullptr;
|
||||
MCORE_DEFINECOMMAND_END
|
||||
class CommandAdjustNodeGroup
|
||||
: public MCore::Command
|
||||
{
|
||||
public:
|
||||
CommandAdjustNodeGroup(MCore::Command* orgCommand = nullptr);
|
||||
bool Execute(const MCore::CommandLine& parameters, AZStd::string& outResult) override;
|
||||
bool Undo(const MCore::CommandLine& parameters, AZStd::string& outResult) override;
|
||||
void InitSyntax() override;
|
||||
bool GetIsUndoable() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const char* GetHistoryName() const override
|
||||
{
|
||||
return "Adjust node group";
|
||||
}
|
||||
const char* GetDescription() const override;
|
||||
MCore::Command* Create() override
|
||||
{
|
||||
return new CommandAdjustNodeGroup(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool mOldDirtyFlag = false;
|
||||
AZStd::unique_ptr<EMotionFX::NodeGroup> mOldNodeGroup = nullptr;
|
||||
};
|
||||
|
||||
// add node group
|
||||
MCORE_DEFINECOMMAND_START(CommandAddNodeGroup, "Add node group", true)
|
||||
MCORE_DEFINECOMMAND_START(CommandAddNodeGroup, "Add node group", true)
|
||||
bool mOldDirtyFlag;
|
||||
MCORE_DEFINECOMMAND_END
|
||||
|
||||
|
||||
// remove a node group
|
||||
MCORE_DEFINECOMMAND_START(CommandRemoveNodeGroup, "Remove node group", true)
|
||||
MCORE_DEFINECOMMAND_START(CommandRemoveNodeGroup, "Remove node group", true)
|
||||
EMotionFX::NodeGroup * mOldNodeGroup;
|
||||
bool mOldDirtyFlag;
|
||||
MCORE_DEFINECOMMAND_END
|
||||
|
||||
Reference in New Issue
Block a user