make qvariantmap deinit work properly.

This commit is contained in:
Kitteh 2021-06-02 20:35:37 +01:00
parent 09066b3033
commit 83ee7b5c5f
2 changed files with 4 additions and 0 deletions

View file

@ -128,6 +128,9 @@ pub fn freeQVariant(variant: QVariant, allocator: *std.mem.Allocator) void {
allocator.free(v.key); allocator.free(v.key);
freeQVariant(v.value, allocator); freeQVariant(v.value, allocator);
} }
// Compiler bug maybe? doesnt want me to drop const so have to store it in a variable
var qi = q;
qi.deinit();
}, },
.QVariantList => |l| { .QVariantList => |l| {

View file

@ -136,6 +136,7 @@ test "QVariant QVariantMap serialization/deserialization" {
defer qvar.freeQVariant(varient, global_allocator); defer qvar.freeQVariant(varient, global_allocator);
var qVariantMap = varient.QVariantMap; var qVariantMap = varient.QVariantMap;
var testKey = qVariantMap.get("testkey"); var testKey = qVariantMap.get("testkey");
if (testKey) |key| { if (testKey) |key| {
try expect(key.UInt == 1337); try expect(key.UInt == 1337);