yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #11175
[Branch ~yade-pkg/yade/git-trunk] Rev 4139: Fix crash after clumps removing. Closes LP:1354433
------------------------------------------------------------
revno: 4139
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Mon 2014-08-11 20:27:43 +0200
message:
Fix crash after clumps removing. Closes LP:1354433
After Clump::del(clumpBody, b), b->clumpId is aways "-1",
so it is wrong to use it later in this->erase(b->clumpId,false).
modified:
core/BodyContainer.cpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'core/BodyContainer.cpp'
--- core/BodyContainer.cpp 2014-07-17 08:05:16 +0000
+++ core/BodyContainer.cpp 2014-08-11 18:27:43 +0000
@@ -29,15 +29,12 @@
bool BodyContainer::erase(Body::id_t id, bool eraseClumpMembers){//default is false (as before)
if(!body[id]) return false;
-
const shared_ptr<Body>& b=Body::byId(id);
-
if ((b) and (b->isClumpMember())) {
- const shared_ptr<Body>& clumpBody=Body::byId(b->clumpId);
+ const shared_ptr<Body> clumpBody=Body::byId(b->clumpId);
const shared_ptr<Clump> clump=YADE_PTR_CAST<Clump>(clumpBody->shape);
Clump::del(clumpBody, b);
-
- if (clump->members.size()==0) this->erase(b->clumpId,false); //Clump has no members any more. Remove it
+ if (clump->members.size()==0) this->erase(clumpBody->id,false); //Clump has no members any more. Remove it
}
if ((b) and (b->isClump())){
@@ -46,17 +43,18 @@
std::map<Body::id_t,Se3r>& members = clump->members;
FOREACH(MemberMap::value_type& mm, members){
const Body::id_t& memberId=mm.first;
- if (eraseClumpMembers) this->erase(memberId,false); // erase members
- //when the last members is erased, the clump will be erased automatically, see above
- else Body::byId(memberId)->clumpId=Body::id_t(-1); // make members standalones
+ if (eraseClumpMembers) {
+ this->erase(memberId,false); // erase members
+ } else {
+ //when the last members is erased, the clump will be erased automatically, see above
+ Body::byId(memberId)->clumpId=Body::ID_NONE; // make members standalones
+ }
}
}
const shared_ptr<Scene>& scene=Omega::instance().getScene();
for(Body::MapId2IntrT::iterator it=b->intrs.begin(),end=b->intrs.end(); it!=end; ++it) { //Iterate over all body's interactions
scene->interactions->requestErase((*it).second);
}
-
body[id].reset();
-
return true;
}