Commit 159a6ddf authored by Jan Möbius's avatar Jan Möbius

Correctly handle append with parent



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7814 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8fcf6c34
......@@ -110,15 +110,31 @@ BaseObject::BaseObject(BaseObject* _parent) :
id_ = idGenerator;
++ idGenerator;
// If the pointer is 0 then we are creating the objectroot
if ( PluginFunctions::objectRoot() ) {
setParent(PluginFunctions::objectRoot());
PluginFunctions::objectRoot()->appendChild(this);
PluginFunctions::objectRoot()->dumpTree();
}
// If the pointer is 0 then something went wrong
if ( _parent ) {
std::cerr << "Appending child to parent" << std::endl;
_parent->appendChild(this);
} else {
std::cerr << "_parent == 0 when creating a BaseObject with name " << std::endl;
if ( PluginFunctions::objectRoot() ) {
std::cerr << "Parent is 0 , objectroot not, adding to objectRoot!" << std::endl;
setParent(PluginFunctions::objectRoot());
PluginFunctions::objectRoot()->appendChild(this);
}
}
objectManager_.objectCreated(id());
}
BaseObject::~BaseObject() {
deleteData();
......@@ -270,8 +286,8 @@ void BaseObject::visible(bool _visible) {
// Only do something if this is really a change
if ( visible_ != _visible ) {
visible_ = _visible;
emit visibilityChanged( id() );
}
emit visibilityChanged( id() );
}
// ===============================================================================
......
......@@ -88,10 +88,14 @@ class DLLEXPORTONLY BaseObject : public QObject {
public :
/** Creates a copy of this Object. Currently it will not have any per Object data attached.
* Its also not attached to the object tree. This has to be done by using setParent.
* Its automatically attached to the objectRoot.
*/
BaseObject(const BaseObject& _object);
/** Creates a new object. If the parent is 0 and the objectroot does not exist, it will have no parent.
* If the objectroot exists and parent is 0, it will be appended to the objectroot.
* If a parent is given, it is appended to this object.
*/
BaseObject( BaseObject *_parent = 0);
virtual ~BaseObject();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment