mirror of
https://github.com/correl/mage.git
synced 2025-04-11 09:11:12 -09: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
Mage.Client/src/main/java/mage/client
components/ext/dlg
dialog
game
plugins/adapters
Mage.Server/src/main/java/mage/server/game
|
@ -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
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
* @param gameId
|
||||
*/
|
||||
public static void removeGame(UUID gameId) {
|
||||
if (!dialogManagers.containsKey(gameId)) {
|
||||
if (dialogManagers.containsKey(gameId)) {
|
||||
synchronized (dialogManagers) {
|
||||
DialogManager dialogManager = dialogManagers.get(gameId);
|
||||
dialogManager.cleanUp();
|
||||
|
@ -80,7 +80,10 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
|
||||
public void cleanUp() {
|
||||
this.currentDialog = null;
|
||||
this.dialogContainer = null;
|
||||
if (dialogContainer != null) {
|
||||
this.dialogContainer.cleanUp();
|
||||
this.dialogContainer = null;
|
||||
}
|
||||
this.removeMouseListener(this);
|
||||
this.removeMouseMotionListener(this);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import javax.swing.*;
|
|||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* @author mw, noxx
|
||||
|
@ -115,6 +116,15 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
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) {
|
||||
if (cards.size() == 0) {
|
||||
return;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
@ -51,7 +52,7 @@ import mage.client.util.SettingsManager;
|
|||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.view.CardsView;
|
||||
import mage.view.SimpleCardsView;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -70,7 +71,12 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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<String, ShowCardsDialog> revealed = 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 playerId;
|
||||
private Session session;
|
||||
|
@ -235,6 +236,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
lookedAtDialog.cleanUp();
|
||||
lookedAtDialog.removeDialog();
|
||||
}
|
||||
for (ShowCardsDialog pickTargetDialog: pickTarget) {
|
||||
pickTargetDialog.cleanUp();
|
||||
pickTargetDialog.removeDialog();
|
||||
}
|
||||
|
||||
try {
|
||||
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) {
|
||||
ShowCardsDialog dialog = null;
|
||||
updateGame(gameView);
|
||||
Map<String, Serializable> options0 = options == null ? new HashMap<String, Serializable>() : options;
|
||||
if (cardView != null && cardView.size() > 0) {
|
||||
ShowCardsDialog dialog = showCards(message, cardView, required, options0);
|
||||
dialog = showCards(message, cardView, required, options0);
|
||||
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) {
|
||||
|
@ -748,6 +756,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
PickChoiceDialog pickChoice = new PickChoiceDialog();
|
||||
pickChoice.showDialog(message, choices);
|
||||
session.sendPlayerString(gameId, pickChoice.getChoice());
|
||||
pickChoice.removeDialog();
|
||||
}
|
||||
|
||||
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) {
|
||||
if (data.gameId != null) {
|
||||
if (data.gameId != null && MageFrame.getGame(data.gameId) != null) {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(data.gameId).getPlayers().values()) {
|
||||
PlayerPanelExt playAreaPanel = pa.getPlayerPanel();
|
||||
if (playAreaPanel != null && playAreaPanel.getPlayer() != null && playAreaPanel.getPlayer().hasAttachments()) {
|
||||
|
|
|
@ -76,16 +76,7 @@ public class GameWatcher {
|
|||
if (!killed) {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
logger.warn("before gameUpdate");
|
||||
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");
|
||||
user.fireCallback(new ClientCallback("gameUpdate", game.getId(), getGameView()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue