Guard against uninstantiated globals in tests

Mikayla Maki created

Change summary

crates/audio/src/audio.rs | 4 ++++
1 file changed, 4 insertions(+)

Detailed changes

crates/audio/src/audio.rs 🔗

@@ -44,6 +44,10 @@ impl Audio {
     }
 
     pub fn play_sound(sound: Sound, cx: &AppContext) {
+        if !cx.has_global::<Self>() {
+            return;
+        }
+
         let this = cx.global::<Self>();
 
         let Some(output_handle) = this.output_handle.as_ref() else {