Some changes to reduce memory leaks.

This commit is contained in:
LevelX2 2014-01-31 15:08:40 +01:00
parent e2c0e211ef
commit 30ddcaf99b
12 changed files with 139 additions and 83 deletions

View file

@ -34,19 +34,27 @@
package mage.client.game;
import java.awt.Component;
import java.awt.KeyboardFocusManager;
import java.beans.PropertyVetoException;
import java.util.UUID;
import javax.swing.SwingUtilities;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.dialog.MageDialog;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class GamePane extends MagePane {
private static final Logger logger = Logger.getLogger(MageDialog.class);
/** Creates new form GamePane */
public GamePane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
SwingUtilities.invokeLater(new Runnable() {
@Override
@ -65,15 +73,26 @@ public class GamePane extends MagePane {
}
public void hideGame() {
// try {
MageFrame.deactivate(this);
MageFrame.getDesktop().remove(this);
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
gamePanel.cleanUp();
this.getUI().uninstallUI(this);
this.removeAll();
this.dispose();
try {
this.setClosed(true);
} catch (PropertyVetoException ex) {
logger.fatal("Closing Game: setClosed - ", ex);
}
MageFrame.deactivate(this);
MageFrame.getDesktop().remove(this);
logger.warn("Remove Dialog " + this.getClass().getName() + " Components left: "+ this.getComponentCount());
for (Component comp: this.getComponents()) {
logger.warn("Existing Component: " + comp.getClass().getName());
}
// this.getUI().uninstallUI(this);
// this.removeAll();
// this.dispose();
// this.setClosed(true);
// } catch (PropertyVetoException ex) {
// Logger.getLogger(GamePane.class.getName()).log(Level.SEVERE, "GamePane could not be closed", ex);