Merge branch 'development' into cmake/SPEC-7484
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> # Conflicts: # Code/Editor/CryEditDoc.cpp # Code/Editor/CryEditDoc.h # Code/Legacy/CryCommon/CryArray.h # Code/Legacy/CryCommon/CryString.h # Code/Legacy/CryCommon/UnicodeBinding.h # Code/Legacy/CrySystem/LocalizedStringManager.cpp # Gems/LyShine/Code/Source/StringUtfUtils.h # Gems/PhysXDebug/Code/Source/SystemComponent.cpp
This commit is contained in:
@@ -47,7 +47,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
auto stackEntry = AZStd::make_shared<BlockCache>(
|
||||
cacheSize, blockSize, aznumeric_caster(hardware.m_maxPhysicalSectorSize), false);
|
||||
cacheSize, aznumeric_cast<AZ::u32>(blockSize), aznumeric_cast<AZ::u32>(hardware.m_maxPhysicalSectorSize), false);
|
||||
stackEntry->SetNext(AZStd::move(parent));
|
||||
return stackEntry;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace AZ
|
||||
}
|
||||
|
||||
auto stackEntry = AZStd::make_shared<DedicatedCache>(
|
||||
cacheSize, blockSize, aznumeric_caster(hardware.m_maxPhysicalSectorSize), m_writeOnlyEpilog);
|
||||
cacheSize, aznumeric_cast<AZ::u32>(blockSize), aznumeric_cast<AZ::u32>(hardware.m_maxPhysicalSectorSize), m_writeOnlyEpilog);
|
||||
stackEntry->SetNext(AZStd::move(parent));
|
||||
return stackEntry;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace AZ
|
||||
static Aabb CreateCenterRadius(const Vector3& center, float radius);
|
||||
|
||||
//! Creates an AABB which contains the specified points.
|
||||
static Aabb CreatePoints(const Vector3* pts, int numPts);
|
||||
static Aabb CreatePoints(const Vector3* pts, size_t numPts);
|
||||
|
||||
//! Creates an AABB which contains the specified OBB.
|
||||
static Aabb CreateFromObb(const Obb& obb);
|
||||
|
||||
@@ -60,10 +60,10 @@ namespace AZ
|
||||
}
|
||||
|
||||
|
||||
AZ_MATH_INLINE Aabb Aabb::CreatePoints(const Vector3* pts, int numPts)
|
||||
AZ_MATH_INLINE Aabb Aabb::CreatePoints(const Vector3* pts, size_t numPts)
|
||||
{
|
||||
Aabb aabb = Aabb::CreateFromPoint(pts[0]);
|
||||
for (int i = 1; i < numPts; ++i)
|
||||
for (size_t i = 1; i < numPts; ++i)
|
||||
{
|
||||
aabb.AddPoint(pts[i]);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <AzCore/Memory/OSAllocator.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
#include <AzCore/Math/Crc.h>
|
||||
#include <AzCore/std/parallel/scoped_lock.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -75,6 +76,42 @@ namespace AZ
|
||||
bool operator==(const OSStdAllocator& a, const OSStdAllocator& b) { (void)a; (void)b; return true; }
|
||||
bool operator!=(const OSStdAllocator& a, const OSStdAllocator& b) { (void)a; (void)b; return false; }
|
||||
|
||||
void EnvironmentVariableHolderBase::UnregisterAndDestroy(DestructFunc destruct, bool moduleRelease)
|
||||
{
|
||||
const bool releaseByUseCount = (--m_useCount == 0);
|
||||
// We take over the lock, and release it before potentially destroying/freeing ourselves
|
||||
{
|
||||
AZStd::scoped_lock envLockHolder(AZStd::adopt_lock, m_mutex);
|
||||
const bool releaseByModule = (moduleRelease && !m_canTransferOwnership && m_moduleOwner == AZ::Environment::GetModuleId());
|
||||
|
||||
if (!releaseByModule && !releaseByUseCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// if the environment that created us is gone the owner can be null
|
||||
// which means (assuming intermodule allocator) that the variable is still alive
|
||||
// but can't be found as it's not part of any environment.
|
||||
if (m_environmentOwner)
|
||||
{
|
||||
m_environmentOwner->RemoveVariable(m_guid);
|
||||
m_environmentOwner = nullptr;
|
||||
}
|
||||
if (m_isConstructed)
|
||||
{
|
||||
destruct(this, DestroyTarget::Member); // destruct the value
|
||||
}
|
||||
}
|
||||
// m_mutex is no longer held here, envLockHolder has released it above.
|
||||
if (releaseByUseCount)
|
||||
{
|
||||
// m_mutex is unlocked before this is deleted
|
||||
Environment::AllocatorInterface* allocator = m_allocator;
|
||||
// Call child class dtor and clear the memory
|
||||
destruct(this, DestroyTarget::Self);
|
||||
allocator->DeAllocate(this);
|
||||
}
|
||||
}
|
||||
|
||||
// instance of the environment
|
||||
EnvironmentInterface* EnvironmentInterface::s_environment = nullptr;
|
||||
|
||||
@@ -110,7 +147,7 @@ namespace AZ
|
||||
#ifdef AZ_ENVIRONMENT_VALIDATE_ON_EXIT
|
||||
AZ_Assert(m_numAttached == 0, "We should not delete an environment while there are %d modules attached! Unload all DLLs first!", m_numAttached);
|
||||
#endif
|
||||
|
||||
|
||||
for (auto variableIt : m_variableMap)
|
||||
{
|
||||
EnvironmentVariableHolderBase* holder = reinterpret_cast<EnvironmentVariableHolderBase*>(variableIt.second);
|
||||
|
||||
@@ -200,6 +200,11 @@ namespace AZ
|
||||
class EnvironmentVariableHolderBase
|
||||
{
|
||||
friend class EnvironmentImpl;
|
||||
protected:
|
||||
enum class DestroyTarget {
|
||||
Member,
|
||||
Self
|
||||
};
|
||||
public:
|
||||
EnvironmentVariableHolderBase(u32 guid, AZ::Internal::EnvironmentInterface* environmentOwner, bool canOwnershipTransfer, Environment::AllocatorInterface* allocator)
|
||||
: m_environmentOwner(environmentOwner)
|
||||
@@ -217,12 +222,21 @@ namespace AZ
|
||||
return m_isConstructed;
|
||||
}
|
||||
|
||||
bool IsOwner() const
|
||||
{
|
||||
return m_moduleOwner == Environment::GetModuleId();
|
||||
}
|
||||
|
||||
u32 GetId() const
|
||||
{
|
||||
return m_guid;
|
||||
}
|
||||
|
||||
protected:
|
||||
using DestructFunc = void (*)(EnvironmentVariableHolderBase *, DestroyTarget);
|
||||
// Assumes the m_mutex is already locked.
|
||||
// On return m_mutex is in an unlocked state.
|
||||
void UnregisterAndDestroy(DestructFunc destruct, bool moduleRelease);
|
||||
|
||||
AZ::Internal::EnvironmentInterface* m_environmentOwner; ///< Used to know which environment we should use to free the variable if we can't transfer ownership
|
||||
void* m_moduleOwner; ///< Used when the variable can't transfered across module and we need to destruct the variable when the module is going away
|
||||
bool m_canTransferOwnership; ///< True if variable can be allocated in one module and freed in other. Usually true for POD types when they share allocator.
|
||||
@@ -242,41 +256,29 @@ namespace AZ
|
||||
memset(&m_value, 0, sizeof(T));
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
template<class... Args>
|
||||
void ConstructImpl(const AZStd::false_type& /* AZStd::has_trivial_constructor<T> */, Args&&... args)
|
||||
{
|
||||
// Construction of non-trivial types is left up to the type's constructor.
|
||||
new(&m_value) T(AZStd::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void DestructImpl(const AZStd::true_type& /* AZStd::is_trivially_destructible<T> */)
|
||||
static void DestructDispatchNoLock(EnvironmentVariableHolderBase *base, DestroyTarget selfDestruct)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
void DestructImpl(const AZStd::false_type& /* AZStd::is_trivially_destructible<T> */)
|
||||
{
|
||||
reinterpret_cast<T*>(&m_value)->~T();
|
||||
}
|
||||
|
||||
// Assumes the lock is already held
|
||||
void UnregisterAndDestruct()
|
||||
{
|
||||
// if the environment that created us is gone the owner can be null
|
||||
// which means (assuming intermodule allocator) that the variable is still alive
|
||||
// but can't be found as it's not part of any environment.
|
||||
if (m_environmentOwner)
|
||||
auto *self = reinterpret_cast<EnvironmentVariableHolder *>(base);
|
||||
if (selfDestruct == DestroyTarget::Self)
|
||||
{
|
||||
m_environmentOwner->RemoveVariable(m_guid);
|
||||
m_environmentOwner = nullptr;
|
||||
self->~EnvironmentVariableHolder();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isConstructed)
|
||||
AZ_Assert(self->m_isConstructed, "Variable is not constructed. Please check your logic and guard if needed!");
|
||||
self->m_isConstructed = false;
|
||||
self->m_moduleOwner = nullptr;
|
||||
if constexpr(!AZStd::is_trivially_destructible_v<T>)
|
||||
{
|
||||
DestructNoLock();
|
||||
reinterpret_cast<T*>(&self->m_value)->~T();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
EnvironmentVariableHolder(u32 guid, bool isOwnershipTransfer, Environment::AllocatorInterface* allocator)
|
||||
: EnvironmentVariableHolderBase(guid, Environment::GetInstance(), isOwnershipTransfer, allocator)
|
||||
@@ -287,12 +289,6 @@ namespace AZ
|
||||
{
|
||||
AZ_Assert(!m_isConstructed, "To get the destructor we should have already destructed the variable!");
|
||||
}
|
||||
|
||||
bool IsOwner() const
|
||||
{
|
||||
return m_moduleOwner == Environment::GetModuleId();
|
||||
}
|
||||
|
||||
void AddRef()
|
||||
{
|
||||
AZStd::lock_guard<AZStd::spin_mutex> lock(m_mutex);
|
||||
@@ -303,30 +299,8 @@ namespace AZ
|
||||
void Release()
|
||||
{
|
||||
m_mutex.lock();
|
||||
|
||||
if (--s_moduleUseCount == 0)
|
||||
{
|
||||
if (!m_canTransferOwnership && m_moduleOwner == AZ::Environment::GetModuleId())
|
||||
{
|
||||
UnregisterAndDestruct();
|
||||
}
|
||||
}
|
||||
|
||||
if (--m_useCount == 0)
|
||||
{
|
||||
UnregisterAndDestruct();
|
||||
|
||||
// unlock before this is deleted
|
||||
m_mutex.unlock();
|
||||
|
||||
Environment::AllocatorInterface* allocator = m_allocator;
|
||||
// Call dtor and clear the memory
|
||||
this->~EnvironmentVariableHolder();
|
||||
allocator->DeAllocate(this);
|
||||
return;
|
||||
}
|
||||
|
||||
m_mutex.unlock();
|
||||
const bool moduleRelease = (--s_moduleUseCount == 0);
|
||||
UnregisterAndDestroy(DestructDispatchNoLock, moduleRelease);
|
||||
}
|
||||
|
||||
void Construct()
|
||||
@@ -352,18 +326,10 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void DestructNoLock()
|
||||
{
|
||||
AZ_Assert(m_isConstructed, "Variable is not constructed. Please check your logic and guard if needed!");
|
||||
m_isConstructed = false;
|
||||
m_moduleOwner = nullptr;
|
||||
DestructImpl(typename AZStd::is_trivially_destructible<T>::type());
|
||||
}
|
||||
|
||||
void Destruct()
|
||||
{
|
||||
AZStd::lock_guard<AZStd::spin_mutex> lock(m_mutex);
|
||||
DestructNoLock();
|
||||
DestructDispatchNoLock(this, DestroyTarget::Member);
|
||||
}
|
||||
|
||||
// variable storage
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace AZ
|
||||
if (context.ShouldKeepDefaults() || !defaultValue || (valAsByteStream != *static_cast<const JsonByteStream*>(defaultValue)))
|
||||
{
|
||||
const auto base64ByteStream = AZ::StringFunc::Base64::Encode(valAsByteStream.data(), valAsByteStream.size());
|
||||
outputValue.SetString(base64ByteStream.c_str(), base64ByteStream.size(), context.GetJsonAllocator());
|
||||
outputValue.SetString(base64ByteStream.c_str(), static_cast<rapidjson::SizeType>(base64ByteStream.size()), context.GetJsonAllocator());
|
||||
return context.Report(Tasks::WriteValue, Outcomes::Success, "ByteStream successfully stored.");
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace AZStd
|
||||
// 20.9.3.2, observer:
|
||||
constexpr rep count() const { return m_rep; }
|
||||
// 20.9.3.3, arithmetic:
|
||||
constexpr duration operator+() const { *this; }
|
||||
constexpr duration operator+() const { return *this; }
|
||||
constexpr duration operator-() const { return duration(-m_rep); }
|
||||
constexpr duration& operator++() { ++m_rep; return *this; }
|
||||
constexpr duration operator++(int) { return duration(m_rep++); }
|
||||
|
||||
@@ -1056,7 +1056,7 @@ namespace AZStd
|
||||
inline void insert(const iterator& pos, ForwardIterator first, ForwardIterator last, const AZStd::forward_iterator_tag&)
|
||||
{
|
||||
size_type size = AZStd::distance(first, last);
|
||||
AZSTD_CONTAINER_ASSERT(size >= 0, "AZStd::ring_buffer::insert - there are no elements to insert!");
|
||||
AZSTD_CONTAINER_ASSERT(first > last, "AZStd::ring_buffer::insert - there are no elements to insert!");
|
||||
if (size == 0)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace AZStd
|
||||
1610612741ul, 3221225473ul, 4294967291ul
|
||||
};
|
||||
|
||||
// Bucket size suitable to hold n elements.
|
||||
AZStd::size_t hash_next_bucket_size(AZStd::size_t n)
|
||||
{
|
||||
const AZStd::size_t* first = prime_list;
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace AZStd
|
||||
void rehash(HashTable* table, size_type numBucketsMin)
|
||||
{
|
||||
size_type num_buckets = 0;
|
||||
|
||||
numBucketsMin = (AZStd::max)(numBucketsMin, (size_type)ceilf((float)m_list.size() / m_max_load_factor));
|
||||
|
||||
if (numBucketsMin != 0)
|
||||
@@ -143,7 +144,7 @@ namespace AZStd
|
||||
|
||||
if (num_buckets == m_numBuckets)
|
||||
{
|
||||
return; // no point
|
||||
return; // no need yet to rehash
|
||||
}
|
||||
m_numBuckets = num_buckets;
|
||||
|
||||
@@ -165,32 +166,43 @@ namespace AZStd
|
||||
while (!m_list.empty())
|
||||
{
|
||||
cur = m_list.begin();
|
||||
typename list_type::iterator insertIter, curEnd(cur);
|
||||
const typename HashTable::key_type& valueKey = Traits::key_from_value(*cur);
|
||||
|
||||
typename list_type::iterator newIter, iter(cur);
|
||||
size_type numValues = 1;
|
||||
for (++iter; iter != last && table->m_keyEqual(Traits::key_from_value(*cur), Traits::key_from_value(*iter)); ++iter, ++numValues)
|
||||
// Get the number of same consecutive elements in the table with same key,
|
||||
// this allows range insertion of elements at once
|
||||
for (++curEnd; curEnd != last && table->m_keyEqual(valueKey, Traits::key_from_value(*curEnd)); ++curEnd, ++numValues)
|
||||
{
|
||||
}
|
||||
;
|
||||
|
||||
const typename HashTable::key_type& valueKey = Traits::key_from_value(*cur);
|
||||
size_type newBucketIndex = table->bucket_from_hash(table->m_hasher(valueKey));
|
||||
|
||||
// newBucket.first holds the total number of elements in the bucket
|
||||
// newBucket.second contains the pointer to the first element in the bucket
|
||||
vector_value_type& newBucket = newBuckets[newBucketIndex];
|
||||
size_type numElements = newBucket.first;
|
||||
newIter = newBucket.second;
|
||||
insertIter = newBucket.second;
|
||||
|
||||
// If we don't have elements in the bucket yet, transfer the elements directly
|
||||
if (numElements == 0)
|
||||
{
|
||||
newList.splice(newList.begin(), m_list, cur, iter);
|
||||
newList.splice(newList.begin(), m_list, cur, curEnd);
|
||||
newBucket.second = newList.begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!table->find_insert_position(valueKey, table->m_keyEqual, newIter, numElements, integral_constant<bool, Traits::has_multi_elements>()))
|
||||
// Since there are elements already in the bucket, update `insertIter` to where the elements will need to be inserted.
|
||||
if (!table->find_insert_position(valueKey, table->m_keyEqual, insertIter, numElements, integral_constant<bool, Traits::has_multi_elements>()))
|
||||
{
|
||||
continue;
|
||||
// An element was found but we don't allow for duplicate elements in this table.
|
||||
// This happens when there was an insertion of two elements that are equal but have different hashes,
|
||||
// which is undefined behavior for a hash table: ISO C++ N4713, section 23.14.15 - 5.3
|
||||
AZ_Assert(false, "Found a duplicate element when rehashing. "
|
||||
"Review the hashing function for this type and make sure two equal elements always have the same hash");
|
||||
}
|
||||
|
||||
newList.splice(newIter, m_list, cur, iter);
|
||||
newList.splice(insertIter, m_list, cur, curEnd);
|
||||
}
|
||||
|
||||
newBucket.first += numValues;
|
||||
@@ -251,15 +263,15 @@ namespace AZStd
|
||||
m_vector.set_allocator(typename vector_type::allocator_type(&m_allocator));
|
||||
}
|
||||
|
||||
allocator_type m_allocator; ///< The single instance of the allocator shared between list and vector containers.
|
||||
list_type m_list; ///< List with elements.
|
||||
vector_type m_vector; ///< Buckets with list iterators.
|
||||
allocator_type m_allocator; //!< The single instance of the allocator shared between list and vector containers.
|
||||
list_type m_list; //!< List with elements.
|
||||
vector_type m_vector; //!< Buckets with list iterators.
|
||||
|
||||
private:
|
||||
vector_value_type* m_buckets; ///< Current buckets array. (can point to the m_vector or m_startBucket).
|
||||
size_type m_numBuckets; ///< Current number of buckets.
|
||||
float m_max_load_factor;
|
||||
vector_value_type m_startBucket; ///< Start bucket used for before we start dynamically allocate memory from m_vector.
|
||||
vector_value_type* m_buckets; //!< Current buckets array. (can point to the m_vector or m_startBucket).
|
||||
size_type m_numBuckets; //!< Current number of buckets.
|
||||
float m_max_load_factor; //!< Maximum load (elements/buckets) before rehashing.
|
||||
vector_value_type m_startBucket; //!< Start bucket used for before we start dynamically allocate memory from m_vector.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -321,8 +333,8 @@ namespace AZStd
|
||||
template<class HashTable>
|
||||
AZ_FORCE_INLINE void rehash(HashTable*, size_type) {}
|
||||
|
||||
vector_type m_vector; ///< Buckets with list iterators.
|
||||
list_type m_list; ///< List with elements.
|
||||
vector_type m_vector; //!< Buckets with list iterators.
|
||||
list_type m_list; //!< List with elements.
|
||||
};
|
||||
}
|
||||
|
||||
@@ -972,28 +984,32 @@ namespace AZStd
|
||||
rhs.clear();
|
||||
}
|
||||
|
||||
// find_insert_position sets insertIter to where the element should be inserted
|
||||
// and returns true if the element should be inserted, otherwise false
|
||||
template<class ComparableToKey, class KeyEq>
|
||||
bool find_insert_position(const ComparableToKey& keyCmp, const KeyEq& keyEq, iterator& iter, size_type numElements, const true_type& /* is multi elements */)
|
||||
bool find_insert_position(const ComparableToKey& keyCmp, const KeyEq& keyEq, iterator& insertIter, size_type numElements, const true_type& /* is multi elements */)
|
||||
{
|
||||
for (size_type i = 0; i < numElements; ++i, ++iter)
|
||||
for (size_type i = 0; i < numElements; ++i, ++insertIter)
|
||||
{
|
||||
if (keyEq(keyCmp, Traits::key_from_value(*iter)))
|
||||
if (keyEq(keyCmp, Traits::key_from_value(*insertIter)))
|
||||
{
|
||||
++iter;
|
||||
++insertIter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// always return true since multi elements (like multiset) allow repeated elements
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class ComparableToKey, class KeyEq>
|
||||
bool find_insert_position(const ComparableToKey& keyCmp, const KeyEq& keyEq, iterator& iter, size_type numElements, const false_type& /* !is multi elements */)
|
||||
bool find_insert_position(const ComparableToKey& keyCmp, const KeyEq& keyEq, iterator& insertIter, size_type numElements, const false_type& /* !is multi elements */)
|
||||
{
|
||||
for (size_type i = 0; i < numElements; ++i, ++iter)
|
||||
for (size_type i = 0; i < numElements; ++i, ++insertIter)
|
||||
{
|
||||
if (keyEq(keyCmp, Traits::key_from_value(*iter)))
|
||||
if (keyEq(keyCmp, Traits::key_from_value(*insertIter)))
|
||||
{
|
||||
// Element already exists, it shouldn't be inserted as we don't allow more than one repeated element for this specialization
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace AZStd
|
||||
T& m_v;
|
||||
constexpr addr_impl_ref(T& v)
|
||||
: m_v(v) {}
|
||||
constexpr addr_impl_ref& operator=(const addr_impl_ref& v) { m_v = v; }
|
||||
constexpr addr_impl_ref& operator=(const addr_impl_ref& v) { m_v = v; return *this; }
|
||||
constexpr operator T& () const { return m_v; }
|
||||
};
|
||||
|
||||
|
||||
@@ -287,6 +287,55 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(HashedContainers, HashTable_InsertionDuplicateOnRehash)
|
||||
{
|
||||
struct TwoPtrs
|
||||
{
|
||||
void* m_ptr1;
|
||||
void* m_ptr2;
|
||||
|
||||
bool operator==(const TwoPtrs& other) const
|
||||
{
|
||||
if (m_ptr1 == other.m_ptr1)
|
||||
{
|
||||
return m_ptr2 == other.m_ptr2;
|
||||
}
|
||||
else if (m_ptr1 == other.m_ptr2)
|
||||
{
|
||||
return m_ptr2 == other.m_ptr1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// This hashing function produces different hashes for two equal values,
|
||||
// which violates the requirement for hashing functions.
|
||||
// The test makes sure that this does not reproduce an issue that caused the insert() function to loop infinitely.
|
||||
struct TwoPtrsHasher
|
||||
{
|
||||
size_t operator()(const TwoPtrs& p) const
|
||||
{
|
||||
size_t hash{ 0 };
|
||||
AZStd::hash_combine(hash, p.m_ptr1, p.m_ptr2);
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
using PairSet = AZStd::unordered_set<TwoPtrs, TwoPtrsHasher>;
|
||||
PairSet set;
|
||||
set.insert({ (void*)1, (void*)2 });
|
||||
set.insert({ (void*)3, (void*)4 });
|
||||
set.insert({ (void*)5, (void*)6 });
|
||||
set.insert({ (void*)7, (void*)8 });
|
||||
// Elements with different hashes, but equal
|
||||
set.insert({ (void*)0x000001ceddd9ca20, (void*)0x000001ceddd9cba0 }); // hash(148335135725641)
|
||||
set.insert({ (void*)0x000001ceddd9cba0, (void*)0x000001ceddd9ca20 }); // hash(148335135764189)
|
||||
AZ_TEST_START_TRACE_SUPPRESSION;
|
||||
// This will trigger the assertion of duplicated elements found
|
||||
// A bucket size of 23 since is where the collision between different hashes happens
|
||||
set.rehash(23);
|
||||
AZ_TEST_STOP_TRACE_SUPPRESSION(1); // 1 assertion
|
||||
}
|
||||
|
||||
TEST_F(HashedContainers, HashTable_Fixed)
|
||||
{
|
||||
array<int, 5> elements = {
|
||||
|
||||
@@ -1150,7 +1150,7 @@ namespace UnitTest
|
||||
#if AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
|
||||
TEST_F(AssetJobsFloodTest, DISABLED_ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
|
||||
#else
|
||||
TEST_F(AssetJobsFloodTest, ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
|
||||
TEST_F(AssetJobsFloodTest, DISABLED_ContainerFilterTest_ContainersWithAndWithoutFiltering_Success)
|
||||
#endif // !AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
|
||||
{
|
||||
m_assetHandlerAndCatalog->AssetCatalogRequestBus::Handler::BusConnect();
|
||||
|
||||
@@ -163,7 +163,11 @@ namespace AzFramework
|
||||
AZ_TracePrintfOnce("AssetSystemComponent", "Failed to find asset platform, setting 'pc'\n");
|
||||
outputConnectionSettings.m_assetPlatform = "pc";
|
||||
}
|
||||
outputConnectionSettings.m_assetPlatform = assetsPlatform;
|
||||
else
|
||||
{
|
||||
outputConnectionSettings.m_assetPlatform = assetsPlatform;
|
||||
}
|
||||
|
||||
if (outputConnectionSettings.m_assetPlatform.empty())
|
||||
{
|
||||
assetsPlatform = AzFramework::OSPlatformToDefaultAssetPlatform(AZ_TRAIT_OS_PLATFORM_CODENAME);
|
||||
|
||||
@@ -227,8 +227,10 @@ namespace AzFramework
|
||||
|
||||
EntitySpawnTicket::EntitySpawnTicket(EntitySpawnTicket&& rhs)
|
||||
: m_payload(rhs.m_payload)
|
||||
, m_id(rhs.m_id)
|
||||
{
|
||||
rhs.m_payload = nullptr;
|
||||
rhs.m_id = 0;
|
||||
}
|
||||
|
||||
EntitySpawnTicket::EntitySpawnTicket(AZ::Data::Asset<Spawnable> spawnable)
|
||||
|
||||
+1
-1
@@ -269,7 +269,7 @@ namespace AzFramework
|
||||
int numEnvironmentVars = 0;
|
||||
if (processLaunchInfo.m_environmentVariables)
|
||||
{
|
||||
const int numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
|
||||
numEnvironmentVars = processLaunchInfo.m_environmentVariables->size();
|
||||
// Adding one more as exec expects the array to have a nullptr as the last element
|
||||
environmentVariables = new char*[numEnvironmentVars + 1];
|
||||
for (int i = 0; i < numEnvironmentVars; i++)
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace UnitTest
|
||||
// If an entry is removed from the octree as an unintended side effect of updating an existing entry,
|
||||
// GetEntryCount can't be relied upon to report the actual entry count.
|
||||
// So manually count the entries when using the entry count for validation.
|
||||
uint32_t manualEntryCount = 0;
|
||||
size_t manualEntryCount = 0;
|
||||
visScene->EnumerateNoCull([&manualEntryCount](const AzFramework::IVisibilityScene::NodeData& nodeData) { manualEntryCount += nodeData.m_entries.size(); });
|
||||
|
||||
EXPECT_EQ(manualEntryCount, expectedEntryCount);
|
||||
@@ -409,7 +409,7 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
// Expect all the entries to be in the scene
|
||||
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
|
||||
ValidateEntryCountEqualsExpectedCount(m_octreeScene, static_cast<uint32_t>(visEntries.size()));
|
||||
|
||||
// Update them, without making any actual changes
|
||||
for (AzFramework::VisibilityEntry& entry : visEntries)
|
||||
@@ -418,6 +418,6 @@ namespace UnitTest
|
||||
}
|
||||
|
||||
// Expect all the entries to be in the scene
|
||||
ValidateEntryCountEqualsExpectedCount(m_octreeScene, visEntries.size());
|
||||
ValidateEntryCountEqualsExpectedCount(m_octreeScene, static_cast<uint32_t>(visEntries.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +366,24 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, EntitySpawnTicket_Move_Works)
|
||||
{
|
||||
AzFramework::EntitySpawnTicket ticket1(*m_spawnableAsset);
|
||||
AzFramework::EntitySpawnTicket ticket2(*m_spawnableAsset);
|
||||
|
||||
const AzFramework::EntitySpawnTicket::Id ticket1Id = ticket1.GetId();
|
||||
const AzFramework::EntitySpawnTicket::Id ticket2Id = ticket2.GetId();
|
||||
|
||||
AzFramework::EntitySpawnTicket ticketMoveConstructor(AZStd::move(ticket1));
|
||||
EXPECT_TRUE(ticketMoveConstructor.IsValid());
|
||||
EXPECT_EQ(ticketMoveConstructor.GetId(), ticket1Id);
|
||||
|
||||
AzFramework::EntitySpawnTicket ticketMoveOperator;
|
||||
ticketMoveOperator = AZStd::move(ticket2);
|
||||
EXPECT_TRUE(ticketMoveOperator.IsValid());
|
||||
EXPECT_EQ(ticketMoveOperator.GetId(), ticket2Id);
|
||||
}
|
||||
|
||||
TEST_F(SpawnableEntitiesManagerTest, SpawnAllEntities_DeleteTicketBeforeCall_NoCrash)
|
||||
{
|
||||
{
|
||||
|
||||
@@ -103,6 +103,14 @@ namespace AzNetworking
|
||||
//! @return boolean true on success
|
||||
virtual bool Disconnect(ConnectionId connectionId, DisconnectReason reason) = 0;
|
||||
|
||||
//! Sets whether this connection interface can disconnect by virtue of a timeout
|
||||
//! @param timeoutEnabled If this connection interface will automatically disconnect due to a timeout
|
||||
virtual void SetTimeoutEnabled(bool timeoutEnabled) = 0;
|
||||
|
||||
//! Whether this connection interface will disconnect by virtue of a time out (does not account for cvars affecting all connections)
|
||||
//! @return boolean true if this connection will not disconnect on timeout (does not account for cvars affecting all connections)
|
||||
virtual bool IsTimeoutEnabled() const = 0;
|
||||
|
||||
//! Const access to the metrics tracked by this network interface.
|
||||
//! @return const reference to the metrics tracked by this network interface
|
||||
const NetworkInterfaceMetrics& GetMetrics() const;
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace AzNetworking
|
||||
}
|
||||
timeoutItem->UpdateTimeoutTime(startTimeMs);
|
||||
|
||||
NetworkOutputSerializer serializer(buffer.GetBuffer(), buffer.GetSize());
|
||||
NetworkOutputSerializer serializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetSize()));
|
||||
if (m_state == ConnectionState::Connecting)
|
||||
{
|
||||
const ConnectResult connectResult = m_networkInterface.GetConnectionListener().ValidateConnect(GetRemoteAddress(), header, serializer);
|
||||
@@ -198,7 +198,7 @@ namespace AzNetworking
|
||||
{
|
||||
TcpPacketEncodingBuffer buffer;
|
||||
{
|
||||
NetworkInputSerializer serializer(buffer.GetBuffer(), buffer.GetCapacity());
|
||||
NetworkInputSerializer serializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetCapacity()));
|
||||
if (!const_cast<IPacket&>(packet).Serialize(serializer))
|
||||
{
|
||||
AZ_Assert(false, "SendReliablePacket: Unable to serialize packet [Type: %d]", packet.GetPacketType());
|
||||
@@ -272,7 +272,7 @@ namespace AzNetworking
|
||||
{
|
||||
TcpPacketHeader header(packetType, aznumeric_cast<uint16_t>(payloadBuffer.GetSize()));
|
||||
header.SetPacketFlag(PacketFlag::Compressed, shouldCompress);
|
||||
NetworkInputSerializer serializer(headerBuffer.GetBuffer(), headerBuffer.GetCapacity());
|
||||
NetworkInputSerializer serializer(headerBuffer.GetBuffer(), static_cast<uint32_t>(headerBuffer.GetCapacity()));
|
||||
if (!header.Serialize(serializer))
|
||||
{
|
||||
return false;
|
||||
@@ -313,7 +313,7 @@ namespace AzNetworking
|
||||
m_networkInterface.GetMetrics().m_sendBytesCompressedDelta += (payloadSize - compressionMemBytesUsed);
|
||||
|
||||
writeBuffer.Resize(aznumeric_cast<int32_t>(compressionMemBytesUsed));
|
||||
payloadSize = writeBuffer.GetSize();
|
||||
payloadSize = static_cast<uint32_t>(writeBuffer.GetSize());
|
||||
srcData = writeBuffer.GetBuffer();
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,16 @@ namespace AzNetworking
|
||||
return connection->Disconnect(reason, TerminationEndpoint::Local);
|
||||
}
|
||||
|
||||
void TcpNetworkInterface::SetTimeoutEnabled(bool timeoutEnabled)
|
||||
{
|
||||
m_timeoutEnabled = timeoutEnabled;
|
||||
}
|
||||
|
||||
bool TcpNetworkInterface::IsTimeoutEnabled() const
|
||||
{
|
||||
return m_timeoutEnabled;
|
||||
}
|
||||
|
||||
void TcpNetworkInterface::QueueNewConnection(const PendingConnection& pendingConnection)
|
||||
{
|
||||
m_pendingConnections.PushBackItem(pendingConnection);
|
||||
@@ -306,7 +316,7 @@ namespace AzNetworking
|
||||
{
|
||||
tcpConnection->SendReliablePacket(CorePackets::HeartbeatPacket());
|
||||
}
|
||||
else if (net_TcpTimeoutConnections)
|
||||
else if (net_TcpTimeoutConnections && m_networkInterface.IsTimeoutEnabled())
|
||||
{
|
||||
tcpConnection->Disconnect(DisconnectReason::Timeout, TerminationEndpoint::Local);
|
||||
return TimeoutResult::Delete;
|
||||
|
||||
@@ -99,6 +99,8 @@ namespace AzNetworking
|
||||
bool WasPacketAcked(ConnectionId connectionId, PacketId packetId) override;
|
||||
bool StopListening() override;
|
||||
bool Disconnect(ConnectionId connectionId, DisconnectReason reason) override;
|
||||
void SetTimeoutEnabled(bool timeoutEnabled) override;
|
||||
bool IsTimeoutEnabled() const override;
|
||||
//! @}
|
||||
|
||||
//! Queues a new incoming connection for this network interface.
|
||||
@@ -154,6 +156,7 @@ namespace AzNetworking
|
||||
AZ::Name m_name;
|
||||
TrustZone m_trustZone;
|
||||
uint16_t m_port = 0;
|
||||
bool m_timeoutEnabled = true;
|
||||
IConnectionListener& m_connectionListener;
|
||||
TcpConnectionSet m_connectionSet;
|
||||
TcpSocketManager m_tcpSocketManager;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AzNetworking
|
||||
{
|
||||
template <uint32_t SIZE>
|
||||
inline TcpRingBuffer<SIZE>::TcpRingBuffer()
|
||||
: m_impl(m_buffer.data(), m_buffer.size())
|
||||
: m_impl(m_buffer.data(), static_cast<uint32_t>(m_buffer.size()))
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace AzNetworking
|
||||
if (dtlsData.GetSize() > 0)
|
||||
{
|
||||
const uint8_t* encryptedData = dtlsData.GetBuffer();
|
||||
const uint32_t encryptedSize = dtlsData.GetSize();
|
||||
const uint32_t encryptedSize = static_cast<uint32_t>(dtlsData.GetSize());
|
||||
BIO_write(m_readBio, encryptedData, encryptedSize);
|
||||
}
|
||||
DtlsEndpoint::HandshakeState prevState = m_state;
|
||||
@@ -196,7 +196,7 @@ namespace AzNetworking
|
||||
// Need to do this... connection negotiation may have left data in the write bio that we need to send out
|
||||
if (BIO_ctrl_pending(m_writeBio) > 0)
|
||||
{
|
||||
const uint32_t maxBufferSize = outHandshakeData.GetCapacity();
|
||||
const uint32_t maxBufferSize = static_cast<uint32_t>(outHandshakeData.GetCapacity());
|
||||
outHandshakeData.Resize(maxBufferSize);
|
||||
const int32_t dataSize = BIO_read(m_writeBio, outHandshakeData.GetBuffer(), maxBufferSize);
|
||||
outHandshakeData.Resize(dataSize);
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace AzNetworking
|
||||
return true;
|
||||
}
|
||||
|
||||
totalPacketSize += packetFragments[index]->GetChunkBuffer().GetSize();
|
||||
totalPacketSize += static_cast<uint32_t>(packetFragments[index]->GetChunkBuffer().GetSize());
|
||||
}
|
||||
|
||||
// We now mark this sequence as delivered, so if by some chance all the individual chunks get redelivered again we don't double deliver the reconstructed packet
|
||||
@@ -125,7 +125,7 @@ namespace AzNetworking
|
||||
uint8_t* bufferPointer = buffer.GetBuffer();
|
||||
for (uint32_t index = 0; index < packetFragments.size(); ++index)
|
||||
{
|
||||
const uint32_t chunkSize = packetFragments[index]->GetChunkBuffer().GetSize();
|
||||
const uint32_t chunkSize = static_cast<uint32_t>(packetFragments[index]->GetChunkBuffer().GetSize());
|
||||
memcpy(bufferPointer, packetFragments[index]->GetChunkBuffer().GetBuffer(), chunkSize);
|
||||
bufferPointer += chunkSize;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace AzNetworking
|
||||
// We can erase all the chunks now, packet is completed
|
||||
m_packetFragments.erase(fragmentSequence);
|
||||
|
||||
NetworkOutputSerializer networkSerializer(buffer.GetBuffer(), buffer.GetSize());
|
||||
NetworkOutputSerializer networkSerializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetSize()));
|
||||
{
|
||||
ISerializer& networkISerializer = networkSerializer; // To get the default typeinfo parameters in ISerializer
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace AzNetworking
|
||||
continue;
|
||||
}
|
||||
decodedPacketData = m_decompressBuffer.GetBuffer();
|
||||
decodedPacketSize = m_decompressBuffer.GetSize();
|
||||
decodedPacketSize = static_cast<int32_t>(m_decompressBuffer.GetSize());
|
||||
}
|
||||
GetMetrics().m_recvBytesUncompressed += decodedPacketSize;
|
||||
|
||||
@@ -397,6 +397,16 @@ namespace AzNetworking
|
||||
return connection->Disconnect(reason, TerminationEndpoint::Local);
|
||||
}
|
||||
|
||||
void UdpNetworkInterface::SetTimeoutEnabled(bool timeoutEnabled)
|
||||
{
|
||||
m_timeoutEnabled = timeoutEnabled;
|
||||
}
|
||||
|
||||
bool UdpNetworkInterface::IsTimeoutEnabled() const
|
||||
{
|
||||
return m_timeoutEnabled;
|
||||
}
|
||||
|
||||
bool UdpNetworkInterface::IsEncrypted() const
|
||||
{
|
||||
return m_socket->IsEncrypted();
|
||||
@@ -494,7 +504,7 @@ namespace AzNetworking
|
||||
{
|
||||
buffer.Resize(buffer.GetCapacity());
|
||||
|
||||
NetworkInputSerializer networkSerializer(buffer.GetBuffer(), buffer.GetCapacity());
|
||||
NetworkInputSerializer networkSerializer(buffer.GetBuffer(), static_cast<uint32_t>(buffer.GetCapacity()));
|
||||
ISerializer& serializer = networkSerializer; // To get the default typeinfo parameters in ISerializer
|
||||
|
||||
if (!header.SerializePacketFlags(serializer))
|
||||
@@ -517,7 +527,7 @@ namespace AzNetworking
|
||||
|
||||
buffer.Resize(serializer.GetSize());
|
||||
}
|
||||
uint32_t packetSize = buffer.GetSize();
|
||||
uint32_t packetSize = static_cast<uint32_t>(buffer.GetSize());
|
||||
uint8_t* packetData = buffer.GetBuffer();
|
||||
|
||||
// If the packet doesn't fit within our MTU (minus potential SSL encryption overhead), break it up
|
||||
@@ -549,7 +559,7 @@ namespace AzNetworking
|
||||
UdpPacketEncodingBuffer writeBuffer;
|
||||
if (m_compressor && shouldCompress)
|
||||
{
|
||||
NetworkInputSerializer flagSerializer(writeBuffer.GetBuffer(), writeBuffer.GetCapacity());
|
||||
NetworkInputSerializer flagSerializer(writeBuffer.GetBuffer(), static_cast<uint32_t>(writeBuffer.GetCapacity()));
|
||||
ISerializer& serializer = flagSerializer; // To get the default typeinfo parameters in ISerializer
|
||||
|
||||
header.SetPacketFlag(PacketFlag::Compressed, true);
|
||||
@@ -562,7 +572,7 @@ namespace AzNetworking
|
||||
AZ_Assert(flagSize == 1, "Flag bitfield should serialize to one byte");
|
||||
|
||||
// Compress the packet, make sure to offset by the size of the flag which is now serialized
|
||||
const uint32_t payloadSize = buffer.GetSize() - flagSize;
|
||||
const uint32_t payloadSize = static_cast<uint32_t>(buffer.GetSize() - flagSize);
|
||||
uint8_t* payload = buffer.GetBuffer() + flagSize;
|
||||
const AZStd::size_t maxSizeNeeded = m_compressor->GetMaxCompressedBufferSize(payloadSize);
|
||||
AZStd::size_t compressionMemBytesUsed = 0;
|
||||
@@ -578,7 +588,7 @@ namespace AzNetworking
|
||||
if (compressionMemBytesUsed < payloadSize)
|
||||
{
|
||||
writeBuffer.Resize(aznumeric_cast<int32_t>(flagSize + compressionMemBytesUsed));
|
||||
packetSize = writeBuffer.GetSize();
|
||||
packetSize = static_cast<uint32_t>(writeBuffer.GetSize());
|
||||
packetData = writeBuffer.GetBuffer();
|
||||
// Track byte delta caused by compression
|
||||
GetMetrics().m_sendBytesCompressedDelta += (packetSize - compressionMemBytesUsed);
|
||||
@@ -729,7 +739,7 @@ namespace AzNetworking
|
||||
{
|
||||
udpConnection->SendUnreliablePacket(CorePackets::HeartbeatPacket());
|
||||
}
|
||||
else if (net_UdpTimeoutConnections)
|
||||
else if (net_UdpTimeoutConnections && m_networkInterface.IsTimeoutEnabled())
|
||||
{
|
||||
udpConnection->Disconnect(DisconnectReason::Timeout, TerminationEndpoint::Local);
|
||||
return TimeoutResult::Delete;
|
||||
|
||||
@@ -104,6 +104,8 @@ namespace AzNetworking
|
||||
bool WasPacketAcked(ConnectionId connectionId, PacketId packetId) override;
|
||||
bool StopListening() override;
|
||||
bool Disconnect(ConnectionId connectionId, DisconnectReason reason) override;
|
||||
void SetTimeoutEnabled(bool timeoutEnabled) override;
|
||||
bool IsTimeoutEnabled() const override;
|
||||
//! @}
|
||||
|
||||
//! Returns true if this is an encrypted socket, false if not.
|
||||
@@ -179,6 +181,7 @@ namespace AzNetworking
|
||||
TrustZone m_trustZone;
|
||||
uint16_t m_port = 0;
|
||||
bool m_allowIncomingConnections = false;
|
||||
bool m_timeoutEnabled = true;
|
||||
IConnectionListener& m_connectionListener;
|
||||
UdpConnectionSet m_connectionSet;
|
||||
TimeoutQueue m_connectionTimeoutQueue;
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace AzNetworking
|
||||
}
|
||||
|
||||
IpAddress address;
|
||||
const uint32_t bufferHead = receiveBuffer.GetSize();
|
||||
const uint32_t bufferHead = static_cast<uint32_t>(receiveBuffer.GetSize());
|
||||
if (bufferHead + MaxUdpTransmissionUnit >= receiveBuffer.GetCapacity())
|
||||
{
|
||||
AZLOG_INFO("Receive buffer full, leaving data on the socket. Size exceeded by %d",
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace AzNetworking
|
||||
#ifdef ENABLE_LATENCY_DEBUG
|
||||
int32_t UdpSocket::SendInternalDeferred(const DeferredData& data) const
|
||||
{
|
||||
return SendInternal(data.m_address, data.m_dataBuffer.GetBuffer(), data.m_dataBuffer.GetSize(), data.m_encrypt, *data.m_dtlsEndpoint);
|
||||
return SendInternal(data.m_address, data.m_dataBuffer.GetBuffer(), static_cast<uint32_t>(data.m_dataBuffer.GetSize()), data.m_encrypt, *data.m_dtlsEndpoint);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace AzToolsFramework
|
||||
SourceControlFileInfo GetSceneSourceControlInfo() override;
|
||||
|
||||
bool AreAnyEntitiesSelected() override { return !m_selectedEntities.empty(); }
|
||||
int GetSelectedEntitiesCount() override { return m_selectedEntities.size(); }
|
||||
int GetSelectedEntitiesCount() override { return static_cast<int>(m_selectedEntities.size()); }
|
||||
const EntityIdList& GetSelectedEntities() override { return m_selectedEntities; }
|
||||
const EntityIdList& GetHighlightedEntities() override { return m_highlightedEntities; }
|
||||
void SetSelectedEntities(const EntityIdList& selectedEntities) override;
|
||||
|
||||
@@ -34,8 +34,6 @@ namespace AzToolsFramework::AssetUtils::Internal
|
||||
return {};
|
||||
}
|
||||
|
||||
const int pathLen = sourceFolder.length() + 1;
|
||||
|
||||
AZ::IO::Path sourceWildcard{ sourceFolder };
|
||||
|
||||
|
||||
|
||||
+2
-9
@@ -72,15 +72,8 @@ namespace AzToolsFramework
|
||||
|
||||
if (m_rootInstance != nullptr)
|
||||
{
|
||||
// Need to save off the template id to remove the template after the instance is deleted.
|
||||
Prefab::TemplateId templateId = m_rootInstance->GetTemplateId();
|
||||
m_rootInstance.reset();
|
||||
if (templateId != Prefab::InvalidTemplateId)
|
||||
{
|
||||
// Remove the template here so that if we're in a Deactivate/Activate cycle, it can recreate the template/rootInstance
|
||||
// correctly
|
||||
m_prefabSystemComponent->RemoveTemplate(templateId);
|
||||
}
|
||||
m_prefabSystemComponent->RemoveAllTemplates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +88,7 @@ namespace AzToolsFramework
|
||||
if (templateId != Prefab::InvalidTemplateId)
|
||||
{
|
||||
m_rootInstance->SetTemplateId(Prefab::InvalidTemplateId);
|
||||
m_prefabSystemComponent->RemoveTemplate(templateId);
|
||||
m_prefabSystemComponent->RemoveAllTemplates();
|
||||
}
|
||||
m_rootInstance->SetContainerEntityName("Level");
|
||||
}
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ namespace AzToolsFramework
|
||||
|
||||
AZStd::string path = prefix + pathIter->value.GetString();
|
||||
|
||||
pathIter->value.SetString(path.c_str(), path.length(), providedPatch.GetAllocator());
|
||||
pathIter->value.SetString(path.c_str(), static_cast<rapidjson::SizeType>(path.length()), providedPatch.GetAllocator());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ namespace AzToolsFramework
|
||||
m_updatingTemplateInstancesInQueue = true;
|
||||
|
||||
const int instanceCountToUpdateInBatch =
|
||||
m_instanceCountToUpdateInBatch == 0 ? m_instancesUpdateQueue.size() : m_instanceCountToUpdateInBatch;
|
||||
m_instanceCountToUpdateInBatch == 0 ? static_cast<int>(m_instancesUpdateQueue.size()) : m_instanceCountToUpdateInBatch;
|
||||
TemplateId currentTemplateId = InvalidTemplateId;
|
||||
TemplateReference currentTemplateReference = AZStd::nullopt;
|
||||
|
||||
|
||||
@@ -1458,7 +1458,7 @@ namespace AzToolsFramework
|
||||
if (&owningInstance->get() == &commonRootEntityOwningInstance)
|
||||
{
|
||||
// If it's the same instance, we can add this entity to the new instance entities.
|
||||
int priorEntitiesSize = entities.size();
|
||||
size_t priorEntitiesSize = entities.size();
|
||||
|
||||
entities.insert(entity);
|
||||
|
||||
@@ -1645,7 +1645,7 @@ namespace AzToolsFramework
|
||||
entityDomAfter.Parse(newEntityDomString.toUtf8().constData());
|
||||
|
||||
// Add the new Entity DOM to the Entities member of the instance
|
||||
rapidjson::Value aliasName(newEntityAlias.c_str(), newEntityAlias.length(), domToAddDuplicatedEntitiesUnder.GetAllocator());
|
||||
rapidjson::Value aliasName(newEntityAlias.c_str(), static_cast<rapidjson::SizeType>(newEntityAlias.length()), domToAddDuplicatedEntitiesUnder.GetAllocator());
|
||||
entitiesIter->value.AddMember(AZStd::move(aliasName), entityDomAfter, domToAddDuplicatedEntitiesUnder.GetAllocator());
|
||||
}
|
||||
|
||||
@@ -1717,7 +1717,7 @@ namespace AzToolsFramework
|
||||
nestedInstanceDomAfter.Parse(newInstanceDomString.toUtf8().constData());
|
||||
|
||||
// Add the new Instance DOM to the Instances member of the instance
|
||||
rapidjson::Value aliasName(newInstanceAlias.c_str(), newInstanceAlias.length(), domToAddDuplicatedInstancesUnder.GetAllocator());
|
||||
rapidjson::Value aliasName(newInstanceAlias.c_str(), static_cast<rapidjson::SizeType>(newInstanceAlias.length()), domToAddDuplicatedInstancesUnder.GetAllocator());
|
||||
instancesIter->value.AddMember(AZStd::move(aliasName), nestedInstanceDomAfter, domToAddDuplicatedInstancesUnder.GetAllocator());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
EditorPythonConsoleInterface::GlobalFunctionCollection globalFunctionCollection;
|
||||
editorPythonConsoleInterface->GetGlobalFunctionList(globalFunctionCollection);
|
||||
m_items.reserve(globalFunctionCollection.size());
|
||||
m_items.reserve(static_cast<int>(globalFunctionCollection.size()));
|
||||
for (const EditorPythonConsoleInterface::GlobalFunction& globalFunction : globalFunctionCollection)
|
||||
{
|
||||
Item item;
|
||||
|
||||
+1
-1
@@ -247,7 +247,7 @@ namespace AzToolsFramework
|
||||
if (highlightTextIndex >= 0)
|
||||
{
|
||||
const QString BACKGROUND_COLOR{ "#707070" };
|
||||
label.insert(highlightTextIndex + m_filterString.length(), "</span>");
|
||||
label.insert(highlightTextIndex + static_cast<int>(m_filterString.length()), "</span>");
|
||||
label.insert(highlightTextIndex, "<span style=\"background-color: " + BACKGROUND_COLOR + "\">");
|
||||
}
|
||||
} while(highlightTextIndex > 0);
|
||||
|
||||
+6
-6
@@ -2643,22 +2643,22 @@ namespace AzToolsFramework
|
||||
m_gui->m_statusComboBox->setItalic(false);
|
||||
if (allActive)
|
||||
{
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusStartActive)]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusStartActive));
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusStartActive))]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusStartActive)));
|
||||
m_comboItems[StatusTypeToIndex(StatusType::StatusStartActive)]->setCheckState(Qt::Checked);
|
||||
}
|
||||
else
|
||||
if (allInactive)
|
||||
{
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusStartInactive)]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusStartInactive));
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusStartInactive))]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusStartInactive)));
|
||||
m_comboItems[StatusTypeToIndex(StatusType::StatusStartInactive)]->setCheckState(Qt::Checked);
|
||||
}
|
||||
else
|
||||
if (allEditorOnly)
|
||||
{
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[StatusTypeToIndex(StatusType::StatusEditorOnly)]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(StatusTypeToIndex(StatusType::StatusEditorOnly));
|
||||
m_gui->m_statusComboBox->setHeaderOverride(m_itemNames[static_cast<int>(StatusTypeToIndex(StatusType::StatusEditorOnly))]);
|
||||
m_gui->m_statusComboBox->setCurrentIndex(static_cast<int>(StatusTypeToIndex(StatusType::StatusEditorOnly)));
|
||||
m_comboItems[StatusTypeToIndex(StatusType::StatusEditorOnly)]->setCheckState(Qt::Checked);
|
||||
}
|
||||
else // Some marked active, some not
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace Benchmark
|
||||
|
||||
void BM_Prefab::SetUpMockValidatorForReadPrefab()
|
||||
{
|
||||
int pathCount = m_paths.size();
|
||||
for (int number = 0; number < pathCount; ++number)
|
||||
const size_t pathCount = m_paths.size();
|
||||
for (size_t number = 0; number < pathCount; ++number)
|
||||
{
|
||||
m_mockIOActionValidator->ReadPrefabDom(
|
||||
m_paths[number], UnitTest::PrefabTestDomUtils::CreatePrefabDom());
|
||||
|
||||
+3
-1
@@ -245,7 +245,9 @@ namespace UnitTest
|
||||
m_instanceToTemplateInterface->GenerateDomForInstance(instanceDomBeforeUpdate, *firstInstance);
|
||||
|
||||
//remove instance from instance
|
||||
firstInstance->DetachNestedInstance(addedAlias);
|
||||
AZStd::unique_ptr<Instance> detachedInstance = firstInstance->DetachNestedInstance(addedAlias);
|
||||
ASSERT_TRUE(detachedInstance != nullptr);
|
||||
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
|
||||
|
||||
//create document with after change snapshot
|
||||
PrefabDom instanceDomAfterUpdate;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace UnitTest
|
||||
const EntityAlias& entityAlias)
|
||||
{
|
||||
return GetPrefabDomEntitiesPath()
|
||||
.Append(entityAlias.c_str(), entityAlias.length());
|
||||
.Append(entityAlias.c_str(), static_cast<rapidjson::SizeType>(entityAlias.length()));
|
||||
};
|
||||
|
||||
inline PrefabDomPath GetPrefabDomEntityNamePath(
|
||||
@@ -62,7 +62,7 @@ namespace UnitTest
|
||||
inline PrefabDomPath GetPrefabDomInstancePath(
|
||||
const InstanceAlias& instanceAlias)
|
||||
{
|
||||
return GetPrefabDomInstancesPath().Append(instanceAlias.c_str(), instanceAlias.length());
|
||||
return GetPrefabDomInstancesPath().Append(instanceAlias.c_str(), static_cast<rapidjson::SizeType>(instanceAlias.length()));
|
||||
};
|
||||
|
||||
inline PrefabDomPath GetPrefabDomInstancePath(
|
||||
|
||||
@@ -309,6 +309,7 @@ namespace UnitTest
|
||||
// and use the updated enclosing Instance to update the PrefabDom of Template.
|
||||
AZStd::unique_ptr<Instance> detachedInstance = newEnclosingInstance->DetachNestedInstance(nestedInstanceAliases.front());
|
||||
ASSERT_TRUE(detachedInstance);
|
||||
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
|
||||
|
||||
PrefabDom updatedTemplateDom;
|
||||
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*newEnclosingInstance, updatedTemplateDom));
|
||||
|
||||
@@ -274,6 +274,7 @@ namespace UnitTest
|
||||
InstanceAlias aliasOfWheelInstanceToRetain = wheelInstanceAliasesUnderAxle.front();
|
||||
AZStd::unique_ptr<Instance> detachedInstance = axleInstance->DetachNestedInstance(wheelInstanceAliasesUnderAxle.back());
|
||||
ASSERT_TRUE(detachedInstance);
|
||||
m_prefabSystemComponent->RemoveLink(detachedInstance->GetLinkId());
|
||||
PrefabDom updatedAxleInstanceDom;
|
||||
ASSERT_TRUE(PrefabDomUtils::StoreInstanceInPrefabDom(*axleInstance, updatedAxleInstanceDom));
|
||||
m_prefabSystemComponent->UpdatePrefabTemplate(axleTemplateId, updatedAxleInstanceDom);
|
||||
|
||||
Reference in New Issue
Block a user