martyj Posted November 21, 2016 Share Posted November 21, 2016 In the non-beta branch. When removing a hook on an entity in the Hook's callback, an access violation occurs. When removing a hook on an entity NOT in the hook, everything works as expected. Code: void tempHook(Entity* entity) { if (Window::GetCurrent()->KeyHit(Key::J)) { entity->RemoveHook(Entity::UpdateWorldHook, tempHook); } } bool App::Start() { temp = Model::Box(3, 3, 3); temp->AddHook(Entity::UpdateWorldHook, tempHook); return true; } Quote Link to comment Share on other sites More sharing options...
Josh Posted November 21, 2016 Share Posted November 21, 2016 Don't do this! It is iterating through the list as it is doing this, and you are messing up the iterator. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted November 21, 2016 Author Share Posted November 21, 2016 I see. Does having an update hook effect performance much? I have an object that I add an update hook on when it gets interacted with, then I hide the object. After x number of seconds, I show the object, and would like to remove the hook as it's no longer needed to check to see if it should show. What would be the best way to do this? Quote Link to comment Share on other sites More sharing options...
Josh Posted November 21, 2016 Share Posted November 21, 2016 Ah I see. If you aren't doing this with tons of objects it should be fine. The actor class I talk about here could probably handle this. You could just remove the actor from the entity in the function and it should be okay: http://www.leadwerks.com/werkspace/topic/15235-actor-class-for-c-entity-management/ It's not ready to use yet, but it might be a good option in the future. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.