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 (); }