sigh_storage_mixin: always trigger an emplace request notification (in sync with unbalanced destroy)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user