diff --git a/LEGO1/lego/legoomni/include/legoroimaplist.h b/LEGO1/lego/legoomni/include/legoroimaplist.h index 05a03b44..697c2dd8 100644 --- a/LEGO1/lego/legoomni/include/legoroimaplist.h +++ b/LEGO1/lego/legoomni/include/legoroimaplist.h @@ -15,23 +15,6 @@ class LegoROI; // VTABLE: LEGO1 0x100d9248 // class MxPtrList -// Specialize MxPtrList for LegoROI* in order to fix Destroy. -// TODO: Change to using constexpr in MxPtrList::Destroy once C++17 standard works. -template <> -class MxPtrList : public MxList { -public: - MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); } - - static void Destroy(LegoROI** p_obj) { delete[] p_obj; } - - void SetOwnership(MxBool p_ownership) - { - MxCollection::SetDestroy( - p_ownership ? MxPtrList::Destroy : MxCollection::Destroy - ); - } -}; - // VTABLE: LEGO1 0x100d9260 // SIZE 0x18 class LegoROIMapList : public MxPtrList { diff --git a/LEGO1/omni/include/mxlist.h b/LEGO1/omni/include/mxlist.h index f6954168..6d46cb2a 100644 --- a/LEGO1/omni/include/mxlist.h +++ b/LEGO1/omni/include/mxlist.h @@ -5,6 +5,8 @@ #include "mxcore.h" #include "mxtypes.h" +#include + template class MxList; template @@ -71,7 +73,15 @@ class MxPtrList : public MxList { public: MxPtrList(MxBool p_ownership) { SetOwnership(p_ownership); } - static void Destroy(T* p_obj) { delete p_obj; } + static void Destroy(T* p_obj) + { + if constexpr (std::is_pointer::value) { + delete[] p_obj; + } + else { + delete p_obj; + } + } void SetOwnership(MxBool p_ownership) {