Skip to content
Permalink
Browse files
8240709: Enable javax/swing/UI/UnninstallUIMemoryLeaks/UnninstallUIMe…
…moryLeaks.java on all L&F

Reviewed-by: kizune
  • Loading branch information
mrserb committed Oct 22, 2020
1 parent 5d26229 commit 7d3d4daefdd5c534d1622e39721950a158d8b269
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,16 +22,34 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.java.swing.plaf.motif;

import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.border.*;
import javax.swing.plaf.basic.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.event.KeyListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.Serializable;
import java.awt.event.*;
import java.beans.*;

import javax.swing.Icon;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;

/**
* ComboBox motif look and feel
@@ -59,16 +77,6 @@ public void installUI(JComponent c) {
arrowIcon = new MotifComboBoxArrowIcon(UIManager.getColor("controlHighlight"),
UIManager.getColor("controlShadow"),
UIManager.getColor("control"));

Runnable initCode = new Runnable() {
public void run(){
if ( motifGetEditor() != null ) {
motifGetEditor().setBackground( UIManager.getColor( "text" ) );
}
}
};

SwingUtilities.invokeLater( initCode );
}

public Dimension getMinimumSize( JComponent c ) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,37 @@

package javax.swing.plaf.synth;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.event.*;
import javax.swing.plaf.basic.*;
import java.beans.PropertyChangeListener;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.ComboBoxEditor;
import javax.swing.DefaultButtonModel;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.SwingConstants;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicComboBoxEditor;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;

/**
* Provides the Synth L&F UI delegate for
@@ -730,9 +753,9 @@ private EditorFocusHandler(JComboBox<?> comboBox) {
comboBox.addPropertyChangeListener("editor",this);
}

public void unregister(){
comboBox.removePropertyChangeListener(this);
if (editorComponent!=null){
public void unregister() {
comboBox.removePropertyChangeListener("editor", this);
if (editorComponent != null) {
editorComponent.removeFocusListener(this);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,23 @@

package javax.swing.plaf.synth;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.BasicDesktopIconUI;
import java.beans.*;
import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
import javax.swing.JPopupMenu;
import javax.swing.JToggleButton;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicDesktopIconUI;

/**
* Provides the Synth L&amp;F UI delegate for a minimized internal frame on a desktop.
@@ -89,6 +99,20 @@ protected void installComponents() {
desktopIcon.add(iconPane, BorderLayout.CENTER);
}

@Override
protected void uninstallComponents() {
// Uninstall the listeners here because the iconPane will be set to null
// in the super.uninstallComponents()
if (iconPane instanceof JToggleButton) {
((JToggleButton) iconPane).removeActionListener(handler);
frame.removePropertyChangeListener(this);
} else if (iconPane instanceof SynthInternalFrameTitlePane) {
// Uninstall the listeners added by the SynthInternalFrameTitlePane
((SynthInternalFrameTitlePane) iconPane).uninstallListeners();
}
super.uninstallComponents();
}

/**
* {@inheritDoc}
*/
@@ -108,10 +132,6 @@ protected void installListeners() {
*/
@Override
protected void uninstallListeners() {
if (iconPane instanceof JToggleButton) {
((JToggleButton)iconPane).removeActionListener(handler);
frame.removePropertyChangeListener(this);
}
desktopIcon.removePropertyChangeListener(this);
super.uninstallListeners();
}
@@ -76,7 +76,7 @@
/**
* @test
* @key headful
* @bug 8134947 8253977
* @bug 8134947 8253977 8240709
* @library /test/lib
* @run main/timeout=450/othervm UnninstallUIMemoryLeaks
*/
@@ -91,9 +91,7 @@ public static void main(String[] args) throws Exception {
List<Process> tasks = new ArrayList<>();
for (LookAndFeelInfo laf : getInstalledLookAndFeels()) {
String name = laf.getName();
if (name.contains("OS X") || name.contains("Metal")) {
tasks.add(runProcess(laf));
}
tasks.add(runProcess(laf));
}
for (Process p : tasks) {
if (!p.waitFor(end - System.nanoTime(), TimeUnit.NANOSECONDS)) {

1 comment on commit 7d3d4da

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on 7d3d4da Oct 22, 2020

Please sign in to comment.