diff --git a/src/app/file/ase_format.cpp b/src/app/file/ase_format.cpp index c582a6304..13f46cda3 100644 --- a/src/app/file/ase_format.cpp +++ b/src/app/file/ase_format.cpp @@ -1570,10 +1570,14 @@ static void ase_file_write_property_value(FILE* f, case USER_DATA_PROPERTY_TYPE_VECTOR: { auto& v = *std::get_if(&value); fputl(v.size(), f); - const uint16_t type = (v.empty() ? 0 : v.front().type()); + const uint16_t type = doc::all_elements_of_same_type(v); fputw(type, f); for (const auto& elem : v) { - ASSERT(type == elem.type()); // Check that all elements have the same type + // Check that all elements have the same type when mode == 0. Or just that mode == 1 + ASSERT(type != 0 && type == elem.type() || type == 0); + if (type == 0) { + fputw(elem.type(), f); + } ase_file_write_property_value(f, elem); } break; diff --git a/src/app/script/values.cpp b/src/app/script/values.cpp index ec1e670b9..a87bbbfcc 100644 --- a/src/app/script/values.cpp +++ b/src/app/script/values.cpp @@ -413,8 +413,6 @@ doc::UserData::Variant get_value_from_lua(lua_State* L, int index) lua_pushnil(L); while (lua_next(L, index) != 0) { if (lua_isinteger(L, -2)) { - // TODO we should check that all values are of the same type - // to create the vector if (++i != lua_tointeger(L, -2)) { isArray = false; lua_pop(L, 2); // Pop value and key @@ -509,7 +507,6 @@ doc::UserData::Vector get_value_from_lua(lua_State* L, int index) --index; lua_pushnil(L); while (lua_next(L, index) != 0) { - // TODO we should check that all variants are of the same type v.push_back(get_value_from_lua(L, -1)); lua_pop(L, 1); } diff --git a/src/dio/aseprite_decoder.cpp b/src/dio/aseprite_decoder.cpp index 62ce57805..8d0026a36 100644 --- a/src/dio/aseprite_decoder.cpp +++ b/src/dio/aseprite_decoder.cpp @@ -1375,9 +1375,13 @@ const doc::UserData::Variant AsepriteDecoder::readPropertyValue(uint16_t type) case USER_DATA_PROPERTY_TYPE_VECTOR: { auto numElems = read32(); auto elemsType = read16(); + auto elemType = elemsType; std::vector value; for (int k=0; k& vector = get_value>(variant); write32(os, vector.size()); - const uint16_t type = vector.size() == 0 ? 0 : vector.front().type(); - write16(os, type); for (auto elem : vector) { + write16(os, elem.type()); write_property_value(os, elem); } break; @@ -237,10 +247,10 @@ UserData::Variant read_property_value(std::istream& is, uint16_t type) } case USER_DATA_PROPERTY_TYPE_VECTOR: { auto numElems = read32(is); - auto elemsType = read16(is); std::vector value; for (int k=0; k