Review Request: GluonObject: Fix usage of addChildAt in combination with GameObject

Felix Rohrbach fxrh at gmx.de
Sun Nov 6 14:14:39 UTC 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/103054/
-----------------------------------------------------------

Review request for Gluon.


Description
-------

This happened when calling addChildAt on a GameObject:
- GameObject adds the child to an internal list, d->children.
- GameObject calls GluonObject::addChildAt
- GluonObject calls addChild. As addChild is virtual,
  GameObject::addChild is called.
- GameObject checks whether the child is in d->children. As it is in it,
   it does nothing. GluonObject::addChild is not called

There are two options to solve this problem. The first one is to call GluonObject::addChild in GluonObject::addChildAt explicitly. The second is to call GluonObject::addChild in GameObject::addChild every time. I chose the first, as you can't know that GluonObject::addChildAt will call GluonChild::addChild. Additionally, the GluonObject removes children before calling addChild and adds them afterwards, so GluonObject is in an unstable state when calling addChild, which could cause even more confusion for API users. The downside of this option is that the api user has to implement both, addChild and addChildAt.


Diffs
-----

  core/gluonobject.cpp 7248dc1 

Diff: http://git.reviewboard.kde.org/r/103054/diff/diff


Testing
-------

All tests are succesfull, GluonCreator still starts and a problem I had with prefabs is gone.


Thanks,

Felix Rohrbach

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/gluon/attachments/20111106/092357b3/attachment.html>


More information about the Gluon mailing list