Fix: BLI: Assert in generic array move constructor

When assigning a default constructed virtual array,
an assert checking for a non-null type was triggered.
This commit is contained in:
Hans Goudey
2023-07-10 16:22:55 -04:00
parent 04235d0e55
commit 5ca29d293b
2 changed files with 10 additions and 1 deletions

View File

@@ -99,7 +99,8 @@ class GArray {
/**
* Create an array by taking ownership of another array's data, clearing the data in the other.
*/
GArray(GArray &&other) : GArray(other.type(), other.data(), other.size(), other.allocator())
GArray(GArray &&other)
: type_(other.type_), data_(other.data_), size_(other.size_), allocator_(other.allocator_)
{
other.data_ = nullptr;
other.size_ = 0;

View File

@@ -125,4 +125,12 @@ TEST(generic_array, ReinitEmpty)
EXPECT_EQ(array.as_span().typed<int>()[9], 7);
}
TEST(generic_array, AssignDefault)
{
GArray<> array(CPPType::get<int32_t>(), int64_t(5));
array = {};
EXPECT_EQ(array.size(), 0);
EXPECT_EQ(array.data(), nullptr);
}
} // namespace blender::tests