diff --git a/src/common/scripting/core/maps.cpp b/src/common/scripting/core/maps.cpp index e4ef24a5d..07522e2e1 100644 --- a/src/common/scripting/core/maps.cpp +++ b/src/common/scripting/core/maps.cpp @@ -118,8 +118,16 @@ template unsigned int MapCountUsed(M * self) template expand_types_vm MapGet(M * self,expand_types_vm key) { typename M::ValueType * v = self->CheckKey(key); - if (v) { - return *v; + if (v) + { + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -148,7 +156,14 @@ template expand_types_vm MapGetIfExists(M * s { typename M::ValueType * v = self->CheckKey(key); if (v) { - return *v; + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -177,7 +192,14 @@ template expand_types_vm MapCheckValue(M * se { typename M::ValueType * v = self->CheckKey(key); if ((*exists = !!v)) { - return *v; + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(*v); + } + else + { + return *v; + } } else { @@ -288,7 +310,14 @@ template void MapIteratorGetKeyString(I * self, FString &out) template expand_types_vm MapIteratorGetValue(I * self) { - return self->GetValue(); + if constexpr(std::is_same_v) + { + return GC::ReadBarrier(self->GetValue()); + } + else + { + return self->GetValue(); + } } template void MapIteratorGetValueString(I * self, FString &out)