Implement Drop on AnyViewHandle

Nathan Sobo created

This was a pretty bad oversight.

Change summary

gpui/src/app.rs | 8 ++++++++
1 file changed, 8 insertions(+)

Detailed changes

gpui/src/app.rs 🔗

@@ -2363,6 +2363,14 @@ impl<T: View> From<ViewHandle<T>> for AnyViewHandle {
     }
 }
 
+impl Drop for AnyViewHandle {
+    fn drop(&mut self) {
+        if let Some(ref_counts) = self.ref_counts.upgrade() {
+            ref_counts.lock().dec_view(self.window_id, self.view_id);
+        }
+    }
+}
+
 pub struct WeakViewHandle<T> {
     window_id: usize,
     view_id: usize,