diff --git a/src/animations/DurFile.zig b/src/animations/DurFile.zig index 5c595ff..b180880 100644 --- a/src/animations/DurFile.zig +++ b/src/animations/DurFile.zig @@ -103,7 +103,6 @@ const DurFormatRaw = struct { // transfer ownership const frames = self.frames; - self.frames = .{}; return .{ .allocator = self.allocator, @@ -167,8 +166,8 @@ const DurFormatRaw = struct { } } - pub fn create_from_file(self: *DurFormatRaw, allocator: Allocator, file_path: []const u8) !void { - const file_decompressed = try read_decompress_file(allocator, file_path); + pub fn create_from_file(self: *DurFormatRaw, allocator: Allocator, io: std.Io, file_path: []const u8) !void { + const file_decompressed = try read_decompress_file(allocator, io, file_path); defer allocator.free(file_decompressed); const parsed = try Json.parseFromSlice(Json.Value, allocator, file_decompressed, .{}); @@ -184,11 +183,6 @@ const DurFormatRaw = struct { pub fn deinit(self: *DurFormatRaw) void { if (self.colorFormat) |str| self.allocator.free(str); if (self.encoding) |str| self.allocator.free(str); - - for (self.frames.items) |frame| { - frame.deinit(self.allocator); - } - self.frames.deinit(self.allocator); } }; @@ -421,7 +415,7 @@ pub fn init( ) !DurFile { var dur_movie_raw: DurFormatRaw = .init(allocator); - dur_movie_raw.create_from_file(allocator, file_path) catch |err| switch (err) { + dur_movie_raw.create_from_file(allocator, io, file_path) catch |err| switch (err) { error.FileNotFound => { try log_file.err(io, "tui", "dur_file was not found at: {s}", .{file_path}); return err; @@ -435,7 +429,7 @@ pub fn init( var dur_movie = dur_movie_raw.validate() catch |err| switch (err) { error.NotValidFile => { - try log_file.err("tui", "dur_file loaded was invalid or not a dur file!", .{}); + try log_file.err(io, "tui", "dur_file loaded was invalid or not a dur file!", .{}); return err; }, }; @@ -443,7 +437,7 @@ pub fn init( // 4 bit mode with 256 color is unsupported if (!full_color and dur_movie.colorFormat == .two_fifty_six) { - try log_file.err("tui", "dur_file can not be 256 color encoded when not using full_color option!", .{}); + try log_file.err(io, "tui", "dur_file can not be 256 color encoded when not using full_color option!", .{}); dur_movie.deinit(); return error.NotFullColor; }