Skip to content

Commit f0d20b9

Browse files
authored
Remove CALayer from super layer on surface destruction (#355)
1 parent 66e0e2a commit f0d20b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/backends/cg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ impl<D, W> Drop for CGImpl<D, W> {
131131
self.root_layer
132132
.removeObserver_forKeyPath(&self.observer, ns_string!("bounds"));
133133
}
134+
135+
// Remove the layer we created from the root layer.
136+
self.layer.removeFromSuperlayer();
134137
}
135138
}
136139

@@ -179,6 +182,8 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
179182

180183
// Add a sublayer, to avoid interfering with the root layer, since setting the contents of
181184
// e.g. a view-controlled layer is brittle.
185+
//
186+
// This layer is removed from the root layer when the surface is `Drop`ped.
182187
let layer = CALayer::new();
183188
root_layer.addSublayer(&layer);
184189

0 commit comments

Comments
 (0)