]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid destroying windows after they are unmapped
authorPo Lu <luangruo@yahoo.com>
Thu, 4 Apr 2024 01:53:07 +0000 (09:53 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 4 Apr 2024 11:40:24 +0000 (13:40 +0200)
* java/org/gnu/emacs/EmacsActivity.java (destroy): Detach from
current window before calling finish.

* java/org/gnu/emacs/EmacsWindow.java (reparentTo): Don't clear
attachment state here...

* java/org/gnu/emacs/EmacsWindowManager.java (detachWindow):
...but do so here instead.

(cherry picked from commit 42c0603c7aab191c9cc15a7eca1253060ff5b71a)

java/org/gnu/emacs/EmacsActivity.java
java/org/gnu/emacs/EmacsWindow.java
java/org/gnu/emacs/EmacsWindowManager.java

index a939641a75297db10a292b171c21bc0461fe3165..28bb6e4c065367381d8d21b647755e349c83ce84 100644 (file)
@@ -207,6 +207,18 @@ public class EmacsActivity extends Activity
   public final void
   destroy ()
   {
+    if (window != null)
+      {
+       /* Clear the window's pointer to this activity and remove the
+          window's view.  */
+       window.setConsumer (null);
+
+       /* The window can't be iconified any longer.  */
+       window.noticeDeiconified ();
+       layout.removeView (window.view);
+       window = null;
+      }
+
     finish ();
   }
 
index 05d55ce4e542ce9a7dc39b4810d71b5e6a37cbd1..b0957bcab44de78063b06f6d2cf507324fb4f651 100644 (file)
@@ -1322,10 +1322,6 @@ public final class EmacsWindow extends EmacsHandleObject
          manager = EmacsWindowManager.MANAGER;
          manager.detachWindow (EmacsWindow.this);
 
-         /* Reset window management state.  */
-         previouslyAttached = false;
-         attachmentToken = 0;
-
          /* Also unparent this view.  */
 
          /* If the window manager is set, use that instead.  */
index 21df77587b0c95d1f84613fdb8a9775951db14ad..a239fdc8ac2e97241917916d85ac9c40983cd320 100644 (file)
@@ -238,15 +238,19 @@ public final class EmacsWindowManager
   {
     WindowConsumer consumer;
 
-    if (window.getAttachedConsumer () != null)
-      {
-       consumer = window.getAttachedConsumer ();
+    /* Reset window management state.  */
+    window.previouslyAttached = false;
+    window.attachmentToken = 0;
+
+    /* Remove WINDOW from the list of active windows.  */
+    windows.remove (window);
 
+    if ((consumer = window.getAttachedConsumer ()) != null)
+      {
        consumers.remove (consumer);
        consumer.destroy ();
       }
 
-    windows.remove (window);
     pruneWindows ();
   }