diff --git a/libraries/entities/src/EntityItemPropertiesMacros.h b/libraries/entities/src/EntityItemPropertiesMacros.h index 4a0b5c210d..be6a221af4 100644 --- a/libraries/entities/src/EntityItemPropertiesMacros.h +++ b/libraries/entities/src/EntityItemPropertiesMacros.h @@ -88,20 +88,24 @@ } \ } -// TODO: this doesn't need a length. See OctreePacketData::appendValue(const QUuid& uuid) -#define READ_ENTITY_PROPERTY_UUID(P,O) \ - if (propertyFlags.getHasProperty(P)) { \ - uint16_t length; \ - memcpy(&length, dataAt, sizeof(length)); \ - dataAt += sizeof(length); \ - bytesRead += sizeof(length); \ - QByteArray ba((const char*)dataAt, length); \ - QUuid value = QUuid::fromRfc4122(ba); \ - dataAt += length; \ - bytesRead += length; \ - if (overwriteLocalData) { \ - O(value); \ - } \ +#define READ_ENTITY_PROPERTY_UUID(P,O) \ + if (propertyFlags.getHasProperty(P)) { \ + uint16_t length; \ + memcpy(&length, dataAt, sizeof(length)); \ + dataAt += sizeof(length); \ + bytesRead += sizeof(length); \ + QUuid value; \ + if (length == 0) { \ + value = QUuid(); \ + } else { \ + QByteArray ba((const char*)dataAt, length); \ + value = QUuid::fromRfc4122(ba); \ + dataAt += length; \ + bytesRead += length; \ + } \ + if (overwriteLocalData) { \ + O(value); \ + } \ } #define READ_ENTITY_PROPERTY_COLOR(P,M) \ @@ -144,18 +148,22 @@ } -// TODO: this doesn't need a length. See OctreePacketData::appendValue(const QUuid& uuid) -#define READ_ENTITY_PROPERTY_UUID_TO_PROPERTIES(P,O) \ - if (propertyFlags.getHasProperty(P)) { \ - uint16_t length; \ - memcpy(&length, dataAt, sizeof(length)); \ - dataAt += sizeof(length); \ - processedBytes += sizeof(length); \ - QByteArray ba((const char*)dataAt, length); \ - QUuid value = QUuid::fromRfc4122(ba); \ - dataAt += length; \ - processedBytes += length; \ - properties.O(value); \ +#define READ_ENTITY_PROPERTY_UUID_TO_PROPERTIES(P,O) \ + if (propertyFlags.getHasProperty(P)) { \ + uint16_t length; \ + memcpy(&length, dataAt, sizeof(length)); \ + dataAt += sizeof(length); \ + processedBytes += sizeof(length); \ + QUuid value; \ + if (length == 0) { \ + value = QUuid(); \ + } else { \ + QByteArray ba((const char*)dataAt, length); \ + value = QUuid::fromRfc4122(ba); \ + dataAt += length; \ + processedBytes += length; \ + } \ + properties.O(value); \ } #define READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(P,O) \ diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 346d2f1a79..64947010a0 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -412,14 +412,17 @@ bool OctreePacketData::appendValue(const QString& string) { } bool OctreePacketData::appendValue(const QUuid& uuid) { - // TODO: this doesn't need a length QByteArray bytes = uuid.toRfc4122(); - uint16_t length = bytes.size(); - bool success = appendValue(length); - if (success) { - success = appendRawData((const unsigned char*)bytes.constData(), bytes.size()); + if (uuid.isNull()) { + return appendValue((uint16_t)0); // zero length for null uuid + } else { + uint16_t length = bytes.size(); + bool success = appendValue(length); + if (success) { + success = appendRawData((const unsigned char*)bytes.constData(), bytes.size()); + } + return success; } - return success; } bool OctreePacketData::appendValue(const QByteArray& bytes) {