Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/LuaEngine/ALETemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern "C"
#include "ALECompat.h"
#include "ALEUtility.h"
#include "SharedDefines.h"
#include <type_traits>

class ALEGlobal
{
Expand Down Expand Up @@ -347,8 +348,13 @@ class ALETemplate
{
// Get object pointer (and check type, no error)
ALEObject* obj = ALE::CHECKOBJ<ALEObject>(L, 1, false);
if (obj && manageMemory)
delete static_cast<T*>(obj->GetObj());
// Types whose destructor is not accessible, singletons for example, can never be
// memory managed by ALE, so the delete must not even be compiled for them.
if constexpr (std::is_destructible_v<T>)
{
if (obj && manageMemory)
delete static_cast<T*>(obj->GetObj());
}
delete obj;
return 0;
}
Expand Down
334 changes: 334 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp

Large diffs are not rendered by default.

Loading
Loading