Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group#replace and updateZ order issue #1410

Closed
hightopo opened this issue Dec 4, 2014 · 1 comment
Closed

Group#replace and updateZ order issue #1410

hightopo opened this issue Dec 4, 2014 · 1 comment

Comments

@hightopo
Copy link
Contributor

hightopo commented Dec 4, 2014

https://github.com/photonstorm/phaser/blob/dev/src/core/Group.js#L689
In Group's replace method, when removeChild is invoked, newChild.parent will become undefined, so i think we should save parent to variable before remvoeChild, then parent.updateZ()

    if (newChild.parent !== undefined)
    {
        newChild.events.onRemovedFromGroup$dispatch(newChild, this);
        newChild.parent.removeChild(newChild);

        if (newChild.parent instanceof Phaser.Group)
        {
            newChild.parent.updateZ();
        }
    }
@pnstickne
Copy link
Contributor

Remember, you can create a PR too!

pnstickne added a commit to pnstickne/phaser that referenced this issue Dec 6, 2014
As pointed out, `newChild.parent` could be accessed after it was set to
undefined. This fix unifies the code from the various `destroy` methods so
the previou issue does not occur.
photonstorm added a commit that referenced this issue Dec 11, 2014
Fixes #1410 where newChild.parent could be set to undefined before use
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants