emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 42c0603c7aa: Avoid destroying windows after they are unmapped


From: Po Lu
Subject: master 42c0603c7aa: Avoid destroying windows after they are unmapped
Date: Wed, 3 Apr 2024 21:53:21 -0400 (EDT)

branch: master
commit 42c0603c7aab191c9cc15a7eca1253060ff5b71a
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Avoid destroying windows after they are unmapped
    
    * 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.
---
 java/org/gnu/emacs/EmacsActivity.java      | 12 ++++++++++++
 java/org/gnu/emacs/EmacsWindow.java        |  4 ----
 java/org/gnu/emacs/EmacsWindowManager.java | 12 ++++++++----
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/java/org/gnu/emacs/EmacsActivity.java 
b/java/org/gnu/emacs/EmacsActivity.java
index a939641a752..28bb6e4c065 100644
--- a/java/org/gnu/emacs/EmacsActivity.java
+++ b/java/org/gnu/emacs/EmacsActivity.java
@@ -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 ();
   }
 
diff --git a/java/org/gnu/emacs/EmacsWindow.java 
b/java/org/gnu/emacs/EmacsWindow.java
index b085614de23..91e97fa8b61 100644
--- a/java/org/gnu/emacs/EmacsWindow.java
+++ b/java/org/gnu/emacs/EmacsWindow.java
@@ -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.  */
diff --git a/java/org/gnu/emacs/EmacsWindowManager.java 
b/java/org/gnu/emacs/EmacsWindowManager.java
index 21df77587b0..a239fdc8ac2 100644
--- a/java/org/gnu/emacs/EmacsWindowManager.java
+++ b/java/org/gnu/emacs/EmacsWindowManager.java
@@ -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 ();
   }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]