Jump to content

[Unigine 2] Error in upgrade script.


photo

Recommended Posts

Hi

I'm updating our projects using upgrade script. But conversion fails when it has to upgrade a "LightProb" object.

//...

if(type == "LightProb") {
	if(xml.isChild("node")) {		
		// ...		
	} else {
		delete xml.getParent().removeChild(xml); // OH SHI--
		return;
	}
}

//...

The problem is this method is invoked recursively for node children.

// process child nodes
forloop(int i = 0; xml.getNumChilds()) {
	Xml x = xml.getChild(i);
	string name = x.getName();
	if(name == "node") process_node(x,version);
	if(name == "body") process_body(x,version);	
} 

Deleting any XML child makes forloop completely useless. In my opinion process_node() must return a value to indicate the invoker to remove the Xml child and modify the loop in the way it's more convenient for the process.

Link to comment

Hello, you are absolutely right.
Inner loop has no check for whether node was removed.

We are planning hot-fix release for SDK Browser this week.
It will contain improved migration scripts.

For now you can replace forloop with this code:

for(int i = 0; i < xml.getNumChildren(); i++) {
	
	Xml x = xml.getChild(i);
	string name = x.getName();
	
	if(name == "node") {
		process_node(x,version);
		if(x == NULL) i--;
	} else if(name == "body") {
		process_body(x,version);
	}
}

Thanks!

Link to comment
×
×
  • Create New...