mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
Merge pull request #335 from mitchellh/null-focus
core: set focused surface pointer to null if matches on delete
This commit is contained in:
10
src/App.zig
10
src/App.zig
@ -139,6 +139,16 @@ pub fn addSurface(self: *App, rt_surface: *apprt.Surface) !void {
|
||||
/// Delete the surface from the known surface list. This will NOT call the
|
||||
/// destructor or free the memory.
|
||||
pub fn deleteSurface(self: *App, rt_surface: *apprt.Surface) void {
|
||||
// If this surface is the focused surface then we need to clear it.
|
||||
// There was a bug where we relied on hasSurface to return false and
|
||||
// just let focused surface be but the allocator was reusing addresses
|
||||
// after free and giving false positives, so we must clear it.
|
||||
if (self.focused_surface) |focused| {
|
||||
if (focused == &rt_surface.core_surface) {
|
||||
self.focused_surface = null;
|
||||
}
|
||||
}
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < self.surfaces.items.len) {
|
||||
if (self.surfaces.items[i] == rt_surface) {
|
||||
|
Reference in New Issue
Block a user