Răsfoiți Sursa

check for null

erikbackman 2 ani în urmă
părinte
comite
a24717457a
1 a modificat fișierele cu 3 adăugiri și 1 ștergeri
  1. 3 1
      src/main.zig

+ 3 - 1
src/main.zig

@@ -193,7 +193,9 @@ fn unmanage(allocator: std.mem.Allocator, node: *L.Node, destroyed: bool) void {
     // IMPROVE: There is no way of determining if a window is still alive so we have to make sure we set
     // previously_focused to null if we destroy it. Another way is to set an error handler to handle
     // BadWindow errors if we ever try to access it.
-    if (node.data.w == previously_focused.?.data.w) previously_focused = null;
+    if (previously_focused) |pf| {
+        if (node.data.w == pf.data.w) previously_focused = null;
+    }
 
     _ = C.XSetInputFocus(
         display,