feat(windows): fix windows bugs
This commit is contained in:
@@ -17,7 +17,7 @@ pub const Tab = struct {
|
||||
_private: Private,
|
||||
|
||||
const Private = struct {
|
||||
currentItemsAllocator: ?std.heap.ArenaAllocator,
|
||||
currentItemsAllocator: std.heap.ArenaAllocator,
|
||||
};
|
||||
|
||||
pub fn init(
|
||||
@@ -31,7 +31,7 @@ pub const Tab = struct {
|
||||
.currentLocation = null,
|
||||
.threadPool = threadPool,
|
||||
._private = .{
|
||||
.currentItemsAllocator = null,
|
||||
.currentItemsAllocator = std.heap.ArenaAllocator.init(allocator),
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -51,9 +51,7 @@ pub const Tab = struct {
|
||||
loadItems(self, location) catch return;
|
||||
}
|
||||
fn loadItems(self: *Tab, location: *Container) !void {
|
||||
if (self._private.currentItemsAllocator) |arena| {
|
||||
arena.deinit();
|
||||
}
|
||||
_ = self._private.currentItemsAllocator.reset(.retain_capacity);
|
||||
|
||||
{
|
||||
self.currentItems.mutex.lock();
|
||||
@@ -63,16 +61,14 @@ pub const Tab = struct {
|
||||
}
|
||||
}
|
||||
|
||||
self._private.currentItemsAllocator = std.heap.ArenaAllocator.init(self.allocator);
|
||||
const arenaAllocator = &self._private.currentItemsAllocator.?;
|
||||
const arenaAllocator = &self._private.currentItemsAllocator;
|
||||
const arena = arenaAllocator.allocator();
|
||||
|
||||
var threadSafeAllocator = std.heap.ThreadSafeAllocator{ .child_allocator = arena };
|
||||
const allocator = threadSafeAllocator.allocator();
|
||||
|
||||
errdefer {
|
||||
arenaAllocator.deinit();
|
||||
self._private.currentItemsAllocator = null;
|
||||
_ = self._private.currentItemsAllocator.reset(.free_all);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -80,18 +76,23 @@ pub const Tab = struct {
|
||||
defer self.currentItems.mutex.unlock();
|
||||
|
||||
self.currentItems.data = std.ArrayList(*Item).init(allocator);
|
||||
errdefer {
|
||||
self.currentItems.data.?.deinit();
|
||||
self.currentItems.data = null;
|
||||
}
|
||||
}
|
||||
errdefer {
|
||||
self.currentItems.data.?.deinit();
|
||||
self.currentItems.data = null;
|
||||
}
|
||||
|
||||
//TODO: add async
|
||||
while (location.childrenLoading) {
|
||||
std.Thread.sleep(1 * std.time.ns_per_ms);
|
||||
}
|
||||
|
||||
for (location.children.items) |item| {
|
||||
const resolvedItem = try location.item.provider.getItemByFullName(item, &.{ .skipChildInit = false }, allocator);
|
||||
const resolvedItem = location.item.provider.getItemByFullName(item, &.{ .skipChildInit = true }, allocator) catch |e| {
|
||||
//TODO: save error to container errors
|
||||
std.debug.print("error {} {s}\r\n", .{e, item.path});
|
||||
continue;
|
||||
};
|
||||
|
||||
self.currentItems.mutex.lock();
|
||||
defer self.currentItems.mutex.unlock();
|
||||
@@ -105,8 +106,6 @@ pub const Tab = struct {
|
||||
if (self.currentLocation) |c| {
|
||||
c.item.deinit();
|
||||
}
|
||||
if (self._private.currentItemsAllocator) |arena| {
|
||||
arena.deinit();
|
||||
}
|
||||
self._private.currentItemsAllocator.deinit();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user