Quote Originally Posted by wysota View Post
So implement something with the same functionality. However I don't see why you can't get the same behaviour with just QSharedPointer and QWeakPointer. I don't see a need for any other pointers here.

Isn't it enough to just keep a weak pointer to itself in the object and promote it to strong ref if needed?
oh my god facepalm.gif

Simple realization of addChild
Qt Code:
  1. TreeNode::addChild(boost::shared_ptr<TreeNode> p)
  2. {
  3. if (!p._parent.expired())
  4. throw std::runtime_error("TreeNode can't have multiple parents!");
  5. p._parent = shared_from_this(). //!!!!!!!!!
  6. _childs.push_back(p);
  7. }
To copy to clipboard, switch view to plain text mode