From 2ab57910cef6ea1360b690444bc7eaa33a6895c3 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Fri, 15 Jul 2011 11:08:47 -0500 Subject: [PATCH] Make object IDs depend on the names of any enums so if field names change then bad settings won't be picked up. --- ground/uavobjgenerator/uavobjectparser.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ground/uavobjgenerator/uavobjectparser.cpp b/ground/uavobjgenerator/uavobjectparser.cpp index 2ab246ae8..cba02f8ee 100644 --- a/ground/uavobjgenerator/uavobjectparser.cpp +++ b/ground/uavobjgenerator/uavobjectparser.cpp @@ -43,7 +43,7 @@ UAVObjectParser::UAVObjectParser() int(4) << int(1); accessModeStrXML << "readwrite" << "readonly"; - + } /** @@ -228,7 +228,7 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename) node = node.nextSibling(); } - all_units.removeDuplicates(); + all_units.removeDuplicates(); // Done, return null string return QString(); } @@ -251,6 +251,11 @@ void UAVObjectParser::calculateID(ObjectInfo* info) hash = updateHash(info->fields[n]->name, hash); hash = updateHash(info->fields[n]->numElements, 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 info->id = hash & 0xFFFFFFFE; @@ -377,7 +382,7 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in return QString("Object:field:units attribute is missing"); field->units = elemAttr.nodeValue(); - all_units << field->units; + all_units << field->units; // Get type attribute elemAttr = elemAttributes.namedItem("type"); @@ -385,14 +390,14 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in return QString("Object:field:type attribute is missing"); int index = fieldTypeStrXML.indexOf(elemAttr.nodeValue()); - if (index >= 0) { + if (index >= 0) { field->type = (FieldType)index; field->numBytes = fieldTypeNumBytes[index]; - } - else { + } + else { return QString("Object:field:type attribute value is invalid"); - } - + } + // Get numelements or elementnames attribute elemAttr = elemAttributes.namedItem("elementnames"); if ( !elemAttr.isNull() ) {