1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-05 21:52:10 +01:00

Make object IDs depend on the names of any enums so if field names change then

bad settings won't be picked up.
This commit is contained in:
James Cotton 2011-07-15 11:08:47 -05:00
parent d41260d54c
commit 2ab57910ce

View File

@ -43,7 +43,7 @@ UAVObjectParser::UAVObjectParser()
int(4) << int(1); int(4) << int(1);
accessModeStrXML << "readwrite" << "readonly"; accessModeStrXML << "readwrite" << "readonly";
} }
/** /**
@ -228,7 +228,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
node = node.nextSibling(); node = node.nextSibling();
} }
all_units.removeDuplicates(); all_units.removeDuplicates();
// Done, return null string // Done, return null string
return QString(); return QString();
} }
@ -251,6 +251,11 @@ void UAVObjectParser::calculateID(ObjectInfo* info)
hash = updateHash(info->fields[n]->name, hash); hash = updateHash(info->fields[n]->name, hash);
hash = updateHash(info->fields[n]->numElements, hash); hash = updateHash(info->fields[n]->numElements, hash);
hash = updateHash(info->fields[n]->type, hash); hash = updateHash(info->fields[n]->type, hash);
if(info->fields[n]->type == FIELDTYPE_ENUM) {
QStringList options = info->fields[n]->options;
for (int m = 0; m < options.length(); m++)
hash = updateHash(options[m], hash);
}
} }
// Done // Done
info->id = hash & 0xFFFFFFFE; info->id = hash & 0xFFFFFFFE;
@ -377,7 +382,7 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in
return QString("Object:field:units attribute is missing"); return QString("Object:field:units attribute is missing");
field->units = elemAttr.nodeValue(); field->units = elemAttr.nodeValue();
all_units << field->units; all_units << field->units;
// Get type attribute // Get type attribute
elemAttr = elemAttributes.namedItem("type"); elemAttr = elemAttributes.namedItem("type");
@ -385,14 +390,14 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in
return QString("Object:field:type attribute is missing"); return QString("Object:field:type attribute is missing");
int index = fieldTypeStrXML.indexOf(elemAttr.nodeValue()); int index = fieldTypeStrXML.indexOf(elemAttr.nodeValue());
if (index >= 0) { if (index >= 0) {
field->type = (FieldType)index; field->type = (FieldType)index;
field->numBytes = fieldTypeNumBytes[index]; field->numBytes = fieldTypeNumBytes[index];
} }
else { else {
return QString("Object:field:type attribute value is invalid"); return QString("Object:field:type attribute value is invalid");
} }
// Get numelements or elementnames attribute // Get numelements or elementnames attribute
elemAttr = elemAttributes.namedItem("elementnames"); elemAttr = elemAttributes.namedItem("elementnames");
if ( !elemAttr.isNull() ) { if ( !elemAttr.isNull() ) {