Browse Source

sigh_storage_mixin:
* always check the owner in debug
* fixed a test that doesn't invoke bind

Michele Caini 4 years ago
parent
commit
699a0eb934
2 changed files with 6 additions and 0 deletions
  1. 3 0
      src/entt/entity/storage.hpp
  2. 3 0
      test/entt/entity/view.cpp

+ 3 - 0
src/entt/entity/storage.hpp

@@ -995,6 +995,7 @@ public:
      */
     template<typename... Args>
     decltype(auto) emplace(const entity_type entt, Args &&...args) {
+        ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
         Type::emplace(entt, std::forward<Args>(args)...);
         construction.publish(*owner, entt);
         return this->get(entt);
@@ -1009,6 +1010,7 @@ public:
      */
     template<typename... Func>
     decltype(auto) patch(const entity_type entt, Func &&...func) {
+        ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
         Type::patch(entt, std::forward<Func>(func)...);
         update.publish(*owner, entt);
         return this->get(entt);
@@ -1026,6 +1028,7 @@ public:
      */
     template<typename It, typename... Args>
     void insert(It first, It last, Args &&...args) {
+        ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
         Type::insert(first, last, std::forward<Args>(args)...);
 
         for(auto it = construction.empty() ? last : first; it != last; ++it) {

+ 3 - 0
test/entt/entity/view.cpp

@@ -1153,6 +1153,9 @@ TEST(MultiComponentView, SameComponentTypes) {
     typename entt::storage_traits<entt::entity, int>::storage_type other;
     entt::basic_view view{storage, other};
 
+    storage.bind(entt::forward_as_any(registry));
+    other.bind(entt::forward_as_any(registry));
+
     const entt::entity e0{42u};
     const entt::entity e1{3u};