From 988ddd62f4af9bdd9d7285e6ae9876cce6a54b41 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 17 Feb 2025 11:33:50 +0800 Subject: [PATCH] Fix crash in frame deletion on Android * java/org/gnu/emacs/EmacsWindow.java (destroyHandle): Invalidate the input focus in the UI thread, as is proper. (cherry picked from commit e3dc0ea2544dc09908546c6e6baba47371cbc176) --- java/org/gnu/emacs/EmacsWindow.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/java/org/gnu/emacs/EmacsWindow.java b/java/org/gnu/emacs/EmacsWindow.java index 241927d8f1b..b91d2de46d9 100644 --- a/java/org/gnu/emacs/EmacsWindow.java +++ b/java/org/gnu/emacs/EmacsWindow.java @@ -271,20 +271,26 @@ public final class EmacsWindow extends EmacsHandleObject } } - EmacsActivity.invalidateFocus (4); - + /* This is just a sanity test and is not reliable since `children' + may be modified between isEmpty and handle destruction. */ if (!children.isEmpty ()) throw new IllegalStateException ("Trying to destroy window with " + "children!"); /* Remove the view from its parent and make it invisible. */ EmacsService.SERVICE.runOnUiThread (new Runnable () { + @Override public void run () { ViewManager parent; EmacsWindowManager manager; + /* Invalidate the focus; this should transfer the input focus + to the next eligible window as this window is no longer + present in parent.children. */ + EmacsActivity.invalidateFocus (4); + if (EmacsActivity.focusedWindow == EmacsWindow.this) EmacsActivity.focusedWindow = null; -- 2.39.5