Entt: registry::clone doesn't copy the remove delegate

Created on 4 Jul 2019  路  2Comments  路  Source: skypjack/entt

Within registry::clone, the remove delegate isn't neither copied nor initialized. Some functionalities are therefore unavailable or risky for the newly returned registry.

bug

Most helpful comment

Yep, this is the whole point of the issue.
I've already added a dedicated test locally for this yesterday but I've not the time to fix it right now.
I'll push the changes upstream soon and probably cut a v3.1.0 because of some other features already released. :+1:

All 2 comments

Just encountered the issue. It's impossible to use registry.destroy on a copied registry.

Can be reproduced with:

#include <iostream>
#include <entt/entt.hpp>

struct component {};

int main() {
  entt::registry reg;

  auto entity = reg.create();
  reg.assign<component>(entity);

  auto new_reg = reg.clone();
  auto view = new_reg.view<component>();

  for (auto e : view) {
    new_reg.destroy(e); // segfault here
  }
}

gdb backtrace:

(gdb) backtrace
#0  0x0000000000000000 in ?? ()
#1  0x0000555555557c39 in entt::basic_registry<unsigned int>::destroy (entity=0, this=0x7fffffffdee0) at /usr/local/include/entt/entity/registry.hpp:664
#2  main () at test.cpp:16

Tested on EnTT v3.0.0

Yep, this is the whole point of the issue.
I've already added a dedicated test locally for this yesterday but I've not the time to fix it right now.
I'll push the changes upstream soon and probably cut a v3.1.0 because of some other features already released. :+1:

Was this page helpful?
0 / 5 - 0 ratings