Skip to content

Commit 4488a35

Browse files
hansonrhansonr
authored andcommitted
Window dispose better
1 parent e43ef7b commit 4488a35

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,18 +1022,25 @@ public void dispose() {
10221022
*/
10231023
void disposeImpl() {
10241024
dispose();
1025-
// if (getPeer() != null) {
1026-
// doDispose();
1027-
// }
1025+
if (!_disposed && getPeer() != null) {
1026+
doDispose();
1027+
}
10281028
}
10291029

1030+
private boolean _disposed;
1031+
10301032
void doDispose() {
1031-
final JComponent me = this;
1033+
_disposed = true;
1034+
final Window me = this;
10321035

10331036
Runnable action = new Runnable() {
10341037
@Override
10351038
public void run() {
10361039

1040+
Window parent = getOwner();
1041+
if (parent != null) {
1042+
parent.removeOwnedWindow(me);
1043+
}
10371044
JSComponentUI ui = (JSComponentUI) me.getUI();
10381045
if (ui != null) {
10391046
ui.reinstallUI(me, null);
@@ -2588,8 +2595,6 @@ public void applyResourceBundle(String rbName) {
25882595
void addOwnedWindow(Window weakWindow) {
25892596
if (weakWindow != null) {
25902597
synchronized(ownedWindowList) {
2591-
// this if statement should really be an assert, but we don't
2592-
// have asserts...
25932598
if (!ownedWindowList.contains(weakWindow)) {
25942599
ownedWindowList.addElement(weakWindow);
25952600
}

0 commit comments

Comments
 (0)