diff --git a/river/Root.zig b/river/Root.zig index a74d0ee..3ea79cf 100644 --- a/river/Root.zig +++ b/river/Root.zig @@ -384,13 +384,12 @@ fn commitTransaction(self: *Self) void { var view_it = output.views.first; while (view_it) |view_node| { const view = &view_node.view; + view_it = view_node.next; if (view.destroying) { - view_it = view_node.next; view.destroy(); continue; } - defer view_it = view_node.next; if (view.pending_serial != null and !view.shouldTrackConfigure()) continue; diff --git a/river/View.zig b/river/View.zig index 816c72e..5b57774 100644 --- a/river/View.zig +++ b/river/View.zig @@ -19,6 +19,7 @@ const Self = @This(); const build_options = @import("build_options"); const std = @import("std"); +const assert = std.debug.assert; const math = std.math; const os = std.os; const wlr = @import("wlroots"); @@ -486,7 +487,9 @@ pub fn map(self: *Self) void { pub fn unmap(self: *Self) void { log.debug("view '{s}' unmapped", .{self.getTitle()}); + assert(!self.destroying); self.destroying = true; + if (self.saved_buffers.items.len == 0) self.saveBuffers(); if (self.opacity_timer != null) { diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index 96b618b..ca360c3 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -248,8 +248,6 @@ fn handleMap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurfa fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSurface) void { const self = @fieldParentPtr(Self, "unmap", listener); - self.view.unmap(); - // Remove listeners that are only active while mapped self.commit.link.remove(); self.request_fullscreen.link.remove(); @@ -257,6 +255,8 @@ fn handleUnmap(listener: *wl.Listener(*wlr.XdgSurface), xdg_surface: *wlr.XdgSur self.request_resize.link.remove(); self.set_title.link.remove(); self.set_app_id.link.remove(); + + self.view.unmap(); } /// Called when the surface is comitted