sigh_storage_mixin: always trigger an emplace request notification (in sync with unbalanced destroy)

This commit is contained in:
Michele Caini
2022-01-10 00:23:18 +01:00
parent 9ad807bd58
commit 72440ab937
2 changed files with 9 additions and 8 deletions

View File

@@ -929,10 +929,7 @@ class sigh_storage_mixin final: public Type {
void try_emplace(const typename Type::entity_type entt, const void *value) final {
ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
Type::try_emplace(entt, value);
if(Type::contains(entt)) {
construction.publish(*owner, entt);
}
construction.publish(*owner, entt);
}
public:

View File

@@ -183,7 +183,8 @@ TEST(SighStorageMixin, NonDefaultConstructibleType) {
pool.emplace(entities[1u], 3);
ASSERT_EQ(on_construct.value, 1);
ASSERT_EQ(pool.size(), 1u);
ASSERT_EQ(on_construct.value, 2);
ASSERT_EQ(on_destroy.value, 0);
ASSERT_FALSE(pool.empty());
@@ -192,7 +193,8 @@ TEST(SighStorageMixin, NonDefaultConstructibleType) {
base.erase(entities[1u]);
ASSERT_EQ(on_construct.value, 1);
ASSERT_EQ(pool.size(), 0u);
ASSERT_EQ(on_construct.value, 2);
ASSERT_EQ(on_destroy.value, 1);
ASSERT_TRUE(pool.empty());
@@ -204,7 +206,8 @@ TEST(SighStorageMixin, NonDefaultConstructibleType) {
pool.insert(std::begin(entities), std::end(entities), 3);
ASSERT_EQ(on_construct.value, 3);
ASSERT_EQ(pool.size(), 2u);
ASSERT_EQ(on_construct.value, 6);
ASSERT_EQ(on_destroy.value, 1);
ASSERT_FALSE(pool.empty());
@@ -213,7 +216,8 @@ TEST(SighStorageMixin, NonDefaultConstructibleType) {
pool.erase(std::begin(entities), std::end(entities));
ASSERT_EQ(on_construct.value, 3);
ASSERT_EQ(pool.size(), 0u);
ASSERT_EQ(on_construct.value, 6);
ASSERT_EQ(on_destroy.value, 3);
ASSERT_TRUE(pool.empty());
}