Merge pull request #11773 from vladest/fix_avatar_new_attachment

Remove checking of empty model url and add sanity for checking modelU…
This commit is contained in:
Seth Alves 2017-11-08 14:15:17 -08:00 committed by GitHub
commit 34500fdf18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -2223,11 +2223,13 @@ glm::vec3 variantToVec3(const QVariant& var) {
return result;
}
void AttachmentData::fromVariant(const QVariant& variant) {
bool AttachmentData::fromVariant(const QVariant& variant) {
bool isValid = false;
auto map = variant.toMap();
if (map.contains("modelUrl")) {
auto urlString = map["modelUrl"].toString();
modelURL = urlString;
isValid = true;
}
if (map.contains("jointName")) {
jointName = map["jointName"].toString();
@ -2244,6 +2246,7 @@ void AttachmentData::fromVariant(const QVariant& variant) {
if (map.contains("soft")) {
isSoft = map["soft"].toBool();
}
return isValid;
}
QVariantList AvatarData::getAttachmentsVariant() const {
@ -2259,8 +2262,7 @@ void AvatarData::setAttachmentsVariant(const QVariantList& variant) {
newAttachments.reserve(variant.size());
for (const auto& attachmentVar : variant) {
AttachmentData attachment;
attachment.fromVariant(attachmentVar);
if (!attachment.modelURL.isEmpty()) {
if (attachment.fromVariant(attachmentVar)) {
newAttachments.append(attachment);
}
}

View file

@ -903,7 +903,7 @@ public:
void fromJson(const QJsonObject& json);
QVariant toVariant() const;
void fromVariant(const QVariant& variant);
bool fromVariant(const QVariant& variant);
};
QDataStream& operator<<(QDataStream& out, const AttachmentData& attachment);