Changeset 9627 for code/branches/core6/src
- Timestamp:
- Aug 9, 2013, 12:27:05 AM (11 years ago)
- Location:
- code/branches/core6/src/libraries/core/object
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/object/Listable.cc
r9610 r9627 80 80 void Listable::setContext(Context* context) 81 81 { 82 std::vector<ObjectListBaseElement*> copy = this->elements_; 83 this->elements_.clear(); 84 85 for (size_t i = 0; i < copy.size(); ++i) 86 { 87 copy[i]->changeContext(this->context_, context); 88 delete copy[i]; 89 } 90 82 91 this->context_ = context; 83 for (size_t i = 0; i < this->elements_.size(); ++i)84 this->elements_[i]->changeContext(context);85 92 } 86 93 -
code/branches/core6/src/libraries/core/object/ObjectListBase.h
r9608 r9627 60 60 virtual ~ObjectListBaseElement() { this->removeFromList(); } 61 61 62 virtual void changeContext(Context* context) = 0;62 virtual void changeContext(Context* oldContext, Context* newContext) = 0; 63 63 64 64 ObjectListBaseElement* next_; //!< The next element in the list … … 82 82 ObjectListElement(T* object) : ObjectListBaseElement(static_cast<Listable*>(object)), object_(object) {} 83 83 84 virtual void changeContext(Context* context)84 virtual void changeContext(Context* oldContext, Context* newContext) 85 85 { 86 // add object to new context, but only if this element belongs exactly to the old context (and not to a sub-context to avoid re-adding objects 87 // multiple times if they are in multiple contexts) 88 if (oldContext->getObjectList<T>() == this->list_) 89 newContext->addObject(this->object_); 90 91 // remove from old list 86 92 this->removeFromList(); 87 context->getObjectList<T>()->addElement(this);88 93 } 89 94
Note: See TracChangeset
for help on using the changeset viewer.