mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
* Memory leaks - removed some more memory leaks for match / game handling.
This commit is contained in:
parent
ed64a9ff49
commit
b92a2c83b9
7 changed files with 45 additions and 18 deletions
|
|
@ -169,6 +169,14 @@ public class DialogContainer extends JPanel {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
for (Component component:this.getComponents()) {
|
||||||
|
if (component instanceof ChoiceDialog) {
|
||||||
|
((ChoiceDialog) component).cleanUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
* @param gameId
|
* @param gameId
|
||||||
*/
|
*/
|
||||||
public static void removeGame(UUID gameId) {
|
public static void removeGame(UUID gameId) {
|
||||||
if (!dialogManagers.containsKey(gameId)) {
|
if (dialogManagers.containsKey(gameId)) {
|
||||||
synchronized (dialogManagers) {
|
synchronized (dialogManagers) {
|
||||||
DialogManager dialogManager = dialogManagers.get(gameId);
|
DialogManager dialogManager = dialogManagers.get(gameId);
|
||||||
dialogManager.cleanUp();
|
dialogManager.cleanUp();
|
||||||
|
|
@ -80,7 +80,10 @@ public class DialogManager extends JComponent implements MouseListener,
|
||||||
|
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
this.currentDialog = null;
|
this.currentDialog = null;
|
||||||
this.dialogContainer = null;
|
if (dialogContainer != null) {
|
||||||
|
this.dialogContainer.cleanUp();
|
||||||
|
this.dialogContainer = null;
|
||||||
|
}
|
||||||
this.removeMouseListener(this);
|
this.removeMouseListener(this);
|
||||||
this.removeMouseMotionListener(this);
|
this.removeMouseMotionListener(this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author mw, noxx
|
* @author mw, noxx
|
||||||
|
|
@ -115,6 +116,15 @@ public class ChoiceDialog extends IDialogPanel {
|
||||||
displayCards(params.getCards(), params.gameId, params.bigCard);
|
displayCards(params.getCards(), params.gameId, params.bigCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
for (Component comp : this.getComponents()) {
|
||||||
|
if (comp instanceof CardPanel) {
|
||||||
|
((CardPanel) comp).cleanUp();
|
||||||
|
this.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) {
|
private void displayCards(CardsView cards, UUID gameId, BigCard bigCard) {
|
||||||
if (cards.size() == 0) {
|
if (cards.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
|
|
@ -51,7 +52,7 @@ import mage.client.util.SettingsManager;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import mage.view.SimpleCardsView;
|
import mage.view.SimpleCardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -70,7 +71,12 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
|
for(Component comp: cardArea.getComponents()) {
|
||||||
|
if (comp instanceof CardPanel) {
|
||||||
|
((CardPanel) comp).cleanUp();
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
private final Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
|
private final Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
|
||||||
private final Map<String, ShowCardsDialog> revealed = new HashMap<String, ShowCardsDialog>();
|
private final Map<String, ShowCardsDialog> revealed = new HashMap<String, ShowCardsDialog>();
|
||||||
private final Map<String, ShowCardsDialog> lookedAt = new HashMap<String, ShowCardsDialog>();
|
private final Map<String, ShowCardsDialog> lookedAt = new HashMap<String, ShowCardsDialog>();
|
||||||
|
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<ShowCardsDialog>();
|
||||||
private UUID gameId;
|
private UUID gameId;
|
||||||
private UUID playerId;
|
private UUID playerId;
|
||||||
private Session session;
|
private Session session;
|
||||||
|
|
@ -235,6 +236,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
lookedAtDialog.cleanUp();
|
lookedAtDialog.cleanUp();
|
||||||
lookedAtDialog.removeDialog();
|
lookedAtDialog.removeDialog();
|
||||||
}
|
}
|
||||||
|
for (ShowCardsDialog pickTargetDialog: pickTarget) {
|
||||||
|
pickTargetDialog.cleanUp();
|
||||||
|
pickTargetDialog.removeDialog();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
|
||||||
|
|
@ -646,14 +651,17 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickTarget(String message, CardsView cardView, GameView gameView, Set<UUID> targets, boolean required, Map<String, Serializable> options, int messageId) {
|
public void pickTarget(String message, CardsView cardView, GameView gameView, Set<UUID> targets, boolean required, Map<String, Serializable> options, int messageId) {
|
||||||
|
ShowCardsDialog dialog = null;
|
||||||
updateGame(gameView);
|
updateGame(gameView);
|
||||||
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
||||||
if (cardView != null && cardView.size() > 0) {
|
if (cardView != null && cardView.size() > 0) {
|
||||||
ShowCardsDialog dialog = showCards(message, cardView, required, options0);
|
dialog = showCards(message, cardView, required, options0);
|
||||||
options0.put("dialog", dialog);
|
options0.put("dialog", dialog);
|
||||||
}
|
}
|
||||||
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId);
|
this.feedbackPanel.getFeedback(required?FeedbackMode.INFORM:FeedbackMode.CANCEL, message, gameView.getSpecial(), options0, messageId);
|
||||||
|
if (dialog != null) {
|
||||||
|
this.pickTarget.add(dialog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inform(String information, GameView gameView, int messageId) {
|
public void inform(String information, GameView gameView, int messageId) {
|
||||||
|
|
@ -748,6 +756,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
||||||
pickChoice.showDialog(message, choices);
|
pickChoice.showDialog(message, choices);
|
||||||
session.sendPlayerString(gameId, pickChoice.getChoice());
|
session.sendPlayerString(gameId, pickChoice.getChoice());
|
||||||
|
pickChoice.removeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pickPile(String message, CardsView pile1, CardsView pile2) {
|
public void pickPile(String message, CardsView pile1, CardsView pile2) {
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) {
|
private void drawArrowsForEnchantPlayers(TransferData data, Point parentPoint) {
|
||||||
if (data.gameId != null) {
|
if (data.gameId != null && MageFrame.getGame(data.gameId) != null) {
|
||||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||||
PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
|
PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
|
||||||
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
|
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
|
||||||
|
|
|
||||||
|
|
@ -76,16 +76,7 @@ public class GameWatcher {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
logger.warn("before gameUpdate");
|
user.fireCallback(new ClientCallback("gameUpdate", game.getId(), getGameView()));
|
||||||
GameView gameView = getGameView();
|
|
||||||
logger.warn("after View");
|
|
||||||
UUID id = game.getId();
|
|
||||||
logger.warn("after ID");
|
|
||||||
ClientCallback clientCallback = new ClientCallback("gameUpdate", id, gameView);
|
|
||||||
logger.warn("callback obj");
|
|
||||||
user.fireCallback(clientCallback);
|
|
||||||
// user.fireCallback(new ClientCallback("gameUpdate", game.getId(), getGameView()));
|
|
||||||
logger.warn("after gameUpdate");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue