← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2515: 1. Fix laoding of unitialized LawTester

 

------------------------------------------------------------
revno: 2515
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-10-26 17:39:49 +0200
message:
  1. Fix laoding of unitialized LawTester
modified:
  pkg/dem/DomainLimiter.cpp


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'pkg/dem/DomainLimiter.cpp'
--- pkg/dem/DomainLimiter.cpp	2010-10-17 19:43:48 +0000
+++ pkg/dem/DomainLimiter.cpp	2010-10-26 15:39:49 +0000
@@ -30,6 +30,7 @@
 CREATE_LOGGER(LawTester);
 
 void LawTester::postLoad(LawTester&){
+	if(ids.size()==0) return; // uninitialized object, don't do nothing at all
 	if(ids.size()!=2) throw std::invalid_argument("LawTester.ids: exactly two values must be given.");
 	if(path.empty() && rotPath.empty()) throw invalid_argument("LawTester.{path,rotPath}: at least one point must be given.");
 	if(pathSteps.empty()) throw invalid_argument("LawTester.pathSteps: at least one value must be given.");
@@ -49,6 +50,7 @@
 }
 
 void LawTester::action(){
+	if(ids.size()!=2) throw std::invalid_argument("LawTester.ids: exactly two values must be given.");
 	LOG_DEBUG("=================== LawTester step "<<step<<" ========================");
 	const shared_ptr<Interaction> Inew=scene->interactions->find(ids[0],ids[1]);
 	string strIds("##"+lexical_cast<string>(ids[0])+"+"+lexical_cast<string>(ids[1]));