Skip to content

Mutate world from callbacks of third-party libraries #1050

Answered by SanderMertens
mathisloge asked this question in Q&A
Discussion options

You must be logged in to vote

Ah, that's a bit less straightforward.

What you can do is capture flecs::world_t* by value:

flecs::world_t *ecs_ptr = ecs;

ecs.get<Window>()->gui->get<tgui::Button>("PlayButton")->onClick.connect([=](const auto &) {
  flecs::world ecs(ecs_ptr);
  // ...
});

I'll keep this use case in mind, I don't like how convoluted it is. Ideally the world object would be copyable, but that's a thorny problem to address (something to do with RAII and how copy constructors (don't) work).

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mathisloge
Comment options

@SanderMertens
Comment options

Answer selected by mathisloge
@mathisloge
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants