From d21afe5b33b4cb3f5cf1917f4d15f402de41a032 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 16 Oct 2024 17:05:46 +0200 Subject: Make format --- src/crepe/api/BehaviorScript.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/crepe/api/BehaviorScript.cpp') diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp index 2dd933e..84bfd4c 100644 --- a/src/crepe/api/BehaviorScript.cpp +++ b/src/crepe/api/BehaviorScript.cpp @@ -4,7 +4,4 @@ using namespace crepe::api; -BehaviorScript::BehaviorScript() { - dbg_trace(); -} - +BehaviorScript::BehaviorScript() { dbg_trace(); } -- cgit v1.2.3 From 81a9b43e12a32340262fa0e74005c7e6bd25eba7 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 16 Oct 2024 17:28:15 +0200 Subject: properly clean up Script instance --- src/crepe/api/BehaviorScript.cpp | 8 ++++++++ src/crepe/api/BehaviorScript.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/crepe/api/BehaviorScript.cpp') diff --git a/src/crepe/api/BehaviorScript.cpp b/src/crepe/api/BehaviorScript.cpp index 2dd933e..e8a85dd 100644 --- a/src/crepe/api/BehaviorScript.cpp +++ b/src/crepe/api/BehaviorScript.cpp @@ -1,5 +1,6 @@ #include "../util/log.h" +#include "Script.h" #include "BehaviorScript.h" using namespace crepe::api; @@ -8,3 +9,10 @@ BehaviorScript::BehaviorScript() { dbg_trace(); } +BehaviorScript::~BehaviorScript() { + if (this->script != nullptr) { + delete this->script; + this->script = nullptr; + } +} + diff --git a/src/crepe/api/BehaviorScript.h b/src/crepe/api/BehaviorScript.h index 052d764..e197991 100644 --- a/src/crepe/api/BehaviorScript.h +++ b/src/crepe/api/BehaviorScript.h @@ -16,7 +16,7 @@ protected: friend class crepe::ComponentManager; BehaviorScript(); public: - virtual ~BehaviorScript() = default; + virtual ~BehaviorScript(); public: template -- cgit v1.2.3 From 9fd3bdca9de2d37b63e1646b22d32b0b182f01ee Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 16 Oct 2024 18:24:16 +0200 Subject: use unique_ptr instead of manual memory management in behaviorscript --- src/crepe/ScriptSystem.cpp | 2 +- src/crepe/api/BehaviorScript.cpp | 7 ------- src/crepe/api/BehaviorScript.h | 6 ++++-- src/crepe/api/BehaviorScript.hpp | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-) (limited to 'src/crepe/api/BehaviorScript.cpp') diff --git a/src/crepe/ScriptSystem.cpp b/src/crepe/ScriptSystem.cpp index 0537c16..1a7bff4 100644 --- a/src/crepe/ScriptSystem.cpp +++ b/src/crepe/ScriptSystem.cpp @@ -40,7 +40,7 @@ forward_list