diff --git a/src/backends/cg.rs b/src/backends/cg.rs index 789dd442..29879b70 100644 --- a/src/backends/cg.rs +++ b/src/backends/cg.rs @@ -131,6 +131,9 @@ impl Drop for CGImpl { self.root_layer .removeObserver_forKeyPath(&self.observer, ns_string!("bounds")); } + + // Remove the layer we created from the root layer. + self.layer.removeFromSuperlayer(); } } @@ -179,6 +182,8 @@ impl SurfaceInterface for CGImpl< // Add a sublayer, to avoid interfering with the root layer, since setting the contents of // e.g. a view-controlled layer is brittle. + // + // This layer is removed from the root layer when the surface is `Drop`ped. let layer = CALayer::new(); root_layer.addSublayer(&layer);