From dd1b8882b2e6bd7720868bd019b55fcedf163dff Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Thu, 14 Mar 2024 00:07:15 +0100 Subject: [PATCH] native: Take back the EventSender to avoid leakage --- native/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/native/src/lib.rs b/native/src/lib.rs index 999bf16d..e9c47e12 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -474,6 +474,16 @@ fn run(app: AndroidApp) { } } } + + unsafe { + let vm = JavaVM::from_raw(app.vm_as_ptr() as *mut sys::JavaVM).expect("JVM must exist"); + let activity = JObject::from_raw(app.activity_as_ptr() as jobject); + // Ensure that we take the EventSender back, or we'll leak it + let _: Result = vm + .get_env() + .unwrap() + .take_rust_field(activity, "eventLoopHandle"); + } } #[no_mangle]