Fix recently introduced bug in json-to-prop conversion
This commit is contained in:
parent
fced50f480
commit
f32f1fba59
1 changed files with 10 additions and 12 deletions
|
@ -118,21 +118,19 @@ void JSON::toProp(cJSON * json, SGPropertyNode_ptr base)
|
||||||
// else update base
|
// else update base
|
||||||
cJSON * cj = cJSON_GetObjectItem(json, "name");
|
cJSON * cj = cJSON_GetObjectItem(json, "name");
|
||||||
if ( cj ) {
|
if ( cj ) {
|
||||||
char * name = cj->valuestring;
|
const char * name = cj->valuestring;
|
||||||
if (NULL == name) return; // no name?
|
if (NULL == name) name = "";
|
||||||
|
|
||||||
string namestr = simgear::strutils::strip(string(name));
|
|
||||||
if( namestr.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
//TODO: better check for valid name
|
//TODO: better check for valid name
|
||||||
|
string namestr = simgear::strutils::strip(string(name));
|
||||||
|
if( false == namestr.empty() ) {
|
||||||
|
int index = 0;
|
||||||
|
cj = cJSON_GetObjectItem(json, "index");
|
||||||
|
if (NULL != cj) index = cj->valueint;
|
||||||
|
if (index < 0) return;
|
||||||
|
|
||||||
int index = 0;
|
n = base->getNode(namestr, index, true);
|
||||||
cj = cJSON_GetObjectItem(json, "index");
|
}
|
||||||
if (NULL != cj) index = cj->valueint;
|
|
||||||
if (index < 0) return;
|
|
||||||
|
|
||||||
n = base->getNode(namestr, index, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON * children = cJSON_GetObjectItem(json, "children");
|
cJSON * children = cJSON_GetObjectItem(json, "children");
|
||||||
|
|
Loading…
Add table
Reference in a new issue