6616095: AWT's WindowDisposerRecord keeps AppContext alive too long

WindowDisposerRecord should not keep strong reference to AppContext.

Reviewed-by: art
This commit is contained in:
Oleg Sukhodolsky 2008-03-13 16:12:56 +03:00
parent 2a20e69f1a
commit ee0c8e43e4

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,6 @@
*/ */
package java.awt; package java.awt;
import java.applet.Applet;
import java.awt.event.*; import java.awt.event.*;
import java.awt.im.InputContext; import java.awt.im.InputContext;
import java.awt.image.BufferStrategy; import java.awt.image.BufferStrategy;
@ -355,18 +354,21 @@ public class Window extends Container implements Accessible {
static class WindowDisposerRecord implements sun.java2d.DisposerRecord { static class WindowDisposerRecord implements sun.java2d.DisposerRecord {
final WeakReference<Window> owner; final WeakReference<Window> owner;
final WeakReference weakThis; final WeakReference weakThis;
final AppContext context; final WeakReference<AppContext> context;
WindowDisposerRecord(AppContext context, Window victim) { WindowDisposerRecord(AppContext context, Window victim) {
owner = new WeakReference<Window>(victim.getOwner()); owner = new WeakReference<Window>(victim.getOwner());
weakThis = victim.weakThis; weakThis = victim.weakThis;
this.context = context; this.context = new WeakReference<AppContext>(context);
} }
public void dispose() { public void dispose() {
Window parent = owner.get(); Window parent = owner.get();
if (parent != null) { if (parent != null) {
parent.removeOwnedWindow(weakThis); parent.removeOwnedWindow(weakThis);
} }
Window.removeFromWindowList(context, weakThis); AppContext ac = context.get();
if (null != ac) {
Window.removeFromWindowList(ac, weakThis);
}
} }
} }