# HG changeset patch # User Sleek@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1216469691 0 # Node ID e7b55b2b398f03a857bcea470a70f5dc45f6fccf # Parent 9855464762c1d9d3992880299d9f48a7f4fdfe6b Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig diff -r 9855464762c1 -r e7b55b2b398f engine/core/model/structures/layer.cpp --- a/engine/core/model/structures/layer.cpp Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.cpp Sat Jul 19 12:14:51 2008 +0000 @@ -63,7 +63,7 @@ return createInstance(object, emc, id); } - Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { + bool Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { Location l; l.setLayer(this); l.setExactLayerCoordinates(p); @@ -90,8 +90,11 @@ } bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){ - if( !instance ) + if( !instance ){ FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid"); + return false; + } + Location l; l.setLayer(this); l.setExactLayerCoordinates(p); @@ -114,7 +117,7 @@ ++i; } m_changed = true; - return instance; + return true; } void Layer::deleteInstance(Instance* instance) { diff -r 9855464762c1 -r e7b55b2b398f engine/core/model/structures/layer.h --- a/engine/core/model/structures/layer.h Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.h Sat Jul 19 12:14:51 2008 +0000 @@ -135,7 +135,7 @@ /** Add a valid instance at a specific position. This is temporary. It will be moved to a higher level later so that we can ensure that each Instance only lives in one layer. */ - Instance* Layer::addInstance(Instance* instance, const ExactModelCoordinate& p); + bool addInstance(Instance* instance, const ExactModelCoordinate& p); /** Remove an instance from the layer */ diff -r 9855464762c1 -r e7b55b2b398f engine/core/model/structures/layer.i --- a/engine/core/model/structures/layer.i Sat Jul 19 12:06:14 2008 +0000 +++ b/engine/core/model/structures/layer.i Sat Jul 19 12:14:51 2008 +0000 @@ -68,6 +68,7 @@ bool hasInstances() const; Instance* createInstance(Object* object, const ModelCoordinate& p, const std::string& id=""); Instance* createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id=""); + bool addInstance(Instance* instance, const ExactModelCoordinate& p); void deleteInstance(Instance* object); const std::vector& getInstances() const;