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.
This commit is contained in:
Po Lu 2024-04-04 09:53:07 +08:00
parent 3608c1399f
commit 42c0603c7a
3 changed files with 20 additions and 8 deletions

View file

@ -207,6 +207,18 @@ children and RESETWHENCHILDLESS is set (implying it is a
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 ();
}

View file

@ -1322,10 +1322,6 @@ private static class Coordinate
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. */

View file

@ -238,15 +238,19 @@ && isWindowEligible (consumer, window))
{
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 ();
}