diff --git a/ground/uavobjgenerator/uavobjectparser.cpp b/ground/uavobjgenerator/uavobjectparser.cpp index cba02f8ee..8a69bd9a1 100644 --- a/ground/uavobjgenerator/uavobjectparser.cpp +++ b/ground/uavobjgenerator/uavobjectparser.cpp @@ -111,6 +111,11 @@ int UAVObjectParser::getNumBytes(int objIndex) } } +bool fieldTypeLessThan(const FieldInfo* f1, const FieldInfo* f2) +{ + return f1->numBytes > f2->numBytes; +} + /** * Parse supplied XML file * @param xml The xml text @@ -201,6 +206,9 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename) childNode = childNode.nextSibling(); } + // Sort all fields according to size + qStableSort(info->fields.begin(), info->fields.end(), fieldTypeLessThan); + // Make sure that required elements were found if ( !accessFound ) return QString("Object::access element is missing");