Commit 1add5a33 authored by jouke's avatar jouke
Browse files

Fix for running object generator in templates.

We want to run the copyDefault for the hypocotyl template, but not the
tillers inside. This fixes runBarley and runRice complains about
plantType not being defined in the Origin
parent 7a7985c1
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -397,11 +397,17 @@ void Database::updateRecursively(const Time &t){
	//check time
	if(attributeOf->evaluateTime(t)){
		//update the attribute list
		if (generator) generator->generateObjects(t);
		if (generator) {
			if(attributeOf->getPath().find( "Template" , 0 ) != std::string::npos){
				//todo could also be based on dynamic type casting.
				if(generator->name=="copyDefaults") generator->generateObjects(t);//do not run the other object generators in the templates.
			}else{
				generator->generateObjects(t);
			}
		}
		//call children to update
		for (Database::Table::const_iterator it(data.begin()) ; it!=data.end() ; ++it){
			SimulaBase* probe(it->second);
			//if (probe->getName().find( "Template" , 0 ) != std::string::npos) continue;
			if(probe->hasChildren()){
				probe->getChildren()->updateRecursively(t);
			}
+1 −0
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ class AutoRegisterCopyDefaultsInstantiationFunctions {
public:
   AutoRegisterCopyDefaultsInstantiationFunctions() {
      // register the maker with the factory
	  // note this name is known in XML but also in the Database::UpdateRecursively code as we make an exception there for this class.
	  BaseClassesMap::getObjectGeneratorClasses()["copyDefaults"] = newInstantiationCopyDefaults;
   }
};