#[BUG] 1.4.0-pre.2 TryGetRefRW is busted

1 messages · Page 1 of 1 (latest)

half solar
#

Looks like someone may have just copy/pasted the RO version

        public bool TryGetRefRO(Entity entity, out RefRO<T> outRef)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckReadAndThrow(m_Safety);
#endif
            var ecs = m_Access->EntityComponentStore;
            if (Hint.Unlikely(!ecs->Exists(entity)))
            {
                outRef = default;
                return false;
            }
            void *ptr = ecs->GetOptionalComponentDataWithTypeRO(entity, m_TypeIndex, ref m_Cache);
            if (ptr == null)
            {
                outRef = default;
                return false;
            }

            outRef = Hint.Unlikely(m_IsZeroSized != 0) ? default
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                : new RefRO<T>(ptr, m_Safety);
#else
                : new RefRO<T>(ptr);
#endif
            return true;
        }


        public bool TryGetRefRW(Entity entity, out RefRW<T> outRef)
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckReadAndThrow(m_Safety);
#endif
            var ecs = m_Access->EntityComponentStore;
            if (Hint.Unlikely(!ecs->Exists(entity)))
            {
                outRef = default;
                return false;
            }
            void *ptr = ecs->GetOptionalComponentDataWithTypeRO(entity, m_TypeIndex, ref m_Cache);
            if (ptr == null)
            {
                outRef = default;
                return false;
            }

#if ENABLE_UNITY_COLLECTIONS_CHECKS
                : new RefRW<T>(ptr, m_Safety);
#else
                : new RefRW<T>(ptr);
#endif
            return true;
        }```

So doesn't read by RW (and bump change filters)
half solar
#

Which unfortunately also breaks the old now obsolete GetRefRWOptional as you got rid of its original code and made it point to TryGetRefRW instead

#

should be this for anyone who has the problem as well
void *ptr = ecs->GetOptionalComponentDataWithTypeRW(entity, m_TypeIndex, m_GlobalSystemVersion, ref m_Cache);