mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
gtk: fix closing of windows that contains splits
This commit is contained in:

committed by
Mitchell Hashimoto

parent
0065bae0d4
commit
a18fb4a661
@ -90,16 +90,11 @@ pub fn init(
|
||||
surface.grabFocus();
|
||||
}
|
||||
|
||||
pub fn destroy(self: *Split) void {
|
||||
const window = self.container.window() orelse return;
|
||||
pub fn destroy(self: *Split, alloc: Allocator) void {
|
||||
self.top_left.deinit(alloc);
|
||||
self.bottom_right.deinit(alloc);
|
||||
|
||||
self.top_left.destroy();
|
||||
self.bottom_right.destroy();
|
||||
|
||||
self.removeChildren();
|
||||
|
||||
// TODO: this is the same as in removeChild?
|
||||
window.app.core_app.alloc.destroy(self);
|
||||
alloc.destroy(self);
|
||||
}
|
||||
|
||||
/// Remove the top left child.
|
||||
@ -115,6 +110,7 @@ pub fn removeBottomRight(self: *Split) void {
|
||||
// TODO: Is this Zig-y?
|
||||
inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surface.Container.Elem) void {
|
||||
const window = self.container.window() orelse return;
|
||||
const alloc = window.app.core_app.alloc;
|
||||
|
||||
// TODO: Grab focus
|
||||
|
||||
@ -132,8 +128,8 @@ inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surfac
|
||||
self.container.replace(keep);
|
||||
|
||||
// TODO: is this correct?
|
||||
remove.destroy();
|
||||
window.app.core_app.alloc.destroy(self);
|
||||
remove.deinit(alloc);
|
||||
alloc.destroy(self);
|
||||
}
|
||||
|
||||
// TODO: ehhhhhh
|
||||
|
@ -79,10 +79,10 @@ pub const Container = union(enum) {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn destroy(self: Elem) void {
|
||||
pub fn deinit(self: Elem, alloc: Allocator) void {
|
||||
switch (self) {
|
||||
.surface => |s| s.unref(),
|
||||
.split => |s| s.destroy(),
|
||||
.split => |s| s.destroy(alloc),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,15 +141,13 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void {
|
||||
}
|
||||
|
||||
/// Deinits tab by deiniting child elem.
|
||||
pub fn deinit(self: *Tab) void {
|
||||
self.elem.destroy();
|
||||
pub fn deinit(self: *Tab, alloc: Allocator) void {
|
||||
self.elem.deinit(alloc);
|
||||
}
|
||||
|
||||
// TODO: move this
|
||||
/// Replace the surface element that this tab is showing.
|
||||
pub fn replaceElem(self: *Tab, elem: Surface.Container.Elem) void {
|
||||
// _ = c.g_object_ref_sink(self.elem.widget());
|
||||
|
||||
// Remove our previous widget
|
||||
c.gtk_box_remove(self.box, self.elem.widget());
|
||||
|
||||
|
@ -193,7 +193,7 @@ fn initActions(self: *Window) void {
|
||||
pub fn deinit(self: *Window) void {
|
||||
self.icon.deinit(self.app);
|
||||
for (self.tabs.items) |tab| {
|
||||
tab.deinit();
|
||||
tab.deinit(self.app.core_app.alloc);
|
||||
self.app.core_app.alloc.destroy(tab);
|
||||
}
|
||||
self.tabs.deinit(self.app.core_app.alloc);
|
||||
@ -219,7 +219,7 @@ pub fn removeTab(self: *Window, tab: *Tab) !void {
|
||||
if (tab_idx) |idx| _ = self.tabs.orderedRemove(idx) else return error.TabNotFound;
|
||||
|
||||
// Deallocate the tab
|
||||
tab.deinit();
|
||||
tab.deinit(self.app.core_app.alloc);
|
||||
self.app.core_app.alloc.destroy(tab);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user