code: handle out of memory as well as possible

This commit is contained in:
Isaac Freund
2020-07-05 22:49:17 +02:00
parent 3752a7879b
commit 341fe1e977
10 changed files with 55 additions and 44 deletions

View File

@ -86,13 +86,19 @@ pub fn deinit(self: *Self) void {
c.wlr_output_layout_destroy(self.wlr_output_layout);
// This literally cannot fail, but for some reason returns 0
if (c.wl_event_source_remove(self.transaction_timer) < 0) unreachable;
}
pub fn addOutput(self: *Self, wlr_output: *c.wlr_output) void {
// TODO: Handle failure
const node = self.outputs.allocateNode(util.gpa) catch unreachable;
node.data.init(self, wlr_output) catch unreachable;
const node = self.outputs.allocateNode(util.gpa) catch {
c.wlr_output_destroy(wlr_output);
return;
};
node.data.init(self, wlr_output) catch {
c.wlr_output_destroy(wlr_output);
return;
};
self.outputs.append(node);
// if we previously had no real outputs, move focus from the noop output