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

@ -76,6 +76,9 @@ fn handleNewPopup(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
const wlr_xdg_popup = util.voidCast(c.wlr_xdg_popup, data.?);
// This will free itself on destroy
var xdg_popup = util.gpa.create(Self) catch unreachable;
var xdg_popup = util.gpa.create(Self) catch {
c.wl_resource_post_no_memory(wlr_xdg_popup.resource);
return;
};
xdg_popup.init(self.output, self.parent_box, wlr_xdg_popup);
}