Начало фикса json
This commit is contained in:
@@ -17,7 +17,7 @@ pub const OpenDocument = struct {
|
||||
|
||||
pub fn init(allocator: std.mem.Allocator, self: *OpenDocument) void {
|
||||
const default_size = basic_models.Size_f{ .w = 800, .h = 600 };
|
||||
self.document = Document.init(allocator, default_size);
|
||||
self.document = Document.init(default_size);
|
||||
self.cpu_render = CpuRenderEngine.init(allocator, .Squares);
|
||||
self.canvas = Canvas.init(
|
||||
allocator,
|
||||
@@ -38,8 +38,8 @@ pub const OpenDocument = struct {
|
||||
self.selected_object_id = null;
|
||||
}
|
||||
|
||||
pub fn deinit(self: *OpenDocument) void {
|
||||
self.document.deinit();
|
||||
pub fn deinit(self: *OpenDocument, allocator: std.mem.Allocator) void {
|
||||
self.document.deinit(allocator);
|
||||
self.canvas.deinit();
|
||||
}
|
||||
};
|
||||
@@ -60,7 +60,7 @@ pub fn init(allocator: std.mem.Allocator) !WindowContext {
|
||||
|
||||
pub fn deinit(self: *WindowContext) void {
|
||||
for (self.documents.items) |ptr| {
|
||||
ptr.deinit();
|
||||
ptr.deinit(self.allocator);
|
||||
self.allocator.destroy(ptr);
|
||||
}
|
||||
self.documents.deinit(self.allocator);
|
||||
@@ -85,7 +85,7 @@ pub fn addDocument(self: *WindowContext, doc: Document) !void {
|
||||
const ptr = try self.allocator.create(OpenDocument);
|
||||
errdefer self.allocator.destroy(ptr);
|
||||
var doc_mut = doc;
|
||||
errdefer doc_mut.deinit();
|
||||
errdefer doc_mut.deinit(self.allocator);
|
||||
OpenDocument.initWithDocument(self.allocator, ptr, doc_mut);
|
||||
try self.documents.append(self.allocator, ptr);
|
||||
self.active_document_index = self.documents.items.len - 1;
|
||||
@@ -100,7 +100,7 @@ pub fn setActiveDocument(self: *WindowContext, index: usize) void {
|
||||
pub fn closeDocument(self: *WindowContext, index: usize) void {
|
||||
if (index >= self.documents.items.len) return;
|
||||
const open_doc = self.documents.items[index];
|
||||
open_doc.deinit();
|
||||
open_doc.deinit(self.allocator);
|
||||
self.allocator.destroy(open_doc);
|
||||
_ = self.documents.orderedRemove(index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user