60 lines
1.8 KiB
Diff
60 lines
1.8 KiB
Diff
|
From 7f0b52de6fcddf98dc07ca3aa1c34e8b03e0416c Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= <ricolvs123@gmail.com>
|
||
|
Date: Wed, 18 Jan 2023 21:05:47 -0300
|
||
|
Subject: [PATCH 26/51] Add Missing Read Barriers to Map Get Functions
|
||
|
|
||
|
---
|
||
|
src/common/scripting/core/maps.cpp | 22 ++++++++++++++++++----
|
||
|
1 file changed, 18 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/src/common/scripting/core/maps.cpp b/src/common/scripting/core/maps.cpp
|
||
|
index bfc2b676d..b6ae925c6 100644
|
||
|
--- a/src/common/scripting/core/maps.cpp
|
||
|
+++ b/src/common/scripting/core/maps.cpp
|
||
|
@@ -118,8 +118,16 @@ template<typename M> unsigned int MapCountUsed(M * self)
|
||
|
template<typename M> expand_types_vm<typename M::ValueType> MapGet(M * self,expand_types_vm<typename M::KeyType> key)
|
||
|
{
|
||
|
typename M::ValueType * v = self->CheckKey(key);
|
||
|
- if (v) {
|
||
|
- return *v;
|
||
|
+ if (v)
|
||
|
+ {
|
||
|
+ if constexpr(std::is_same_v<typename M::ValueType, DObject*>)
|
||
|
+ {
|
||
|
+ return GC::ReadBarrier(*v);
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ return *v;
|
||
|
+ }
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
@@ -149,7 +157,6 @@ template<typename M> int MapCheckKey(M * self, expand_types_vm<typename M::KeyTy
|
||
|
return self->CheckKey(key) != nullptr;
|
||
|
}
|
||
|
|
||
|
-
|
||
|
//==========================================================================
|
||
|
//
|
||
|
// MapInsert
|
||
|
@@ -240,7 +247,14 @@ template<typename I> void MapIteratorGetKeyString(I * self, FString &out)
|
||
|
|
||
|
template<typename I> expand_types_vm<typename I::ValueType> MapIteratorGetValue(I * self)
|
||
|
{
|
||
|
- return self->GetValue();
|
||
|
+ if constexpr(std::is_same_v<typename I::ValueType, DObject*>)
|
||
|
+ {
|
||
|
+ return GC::ReadBarrier(self->GetValue());
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ return self->GetValue();
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
template<typename I> void MapIteratorGetValueString(I * self, FString &out)
|
||
|
--
|
||
|
2.39.3
|
||
|
|