mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Change recursion to iteration. This is a bit more efficient, but also I've observed a stack overflow error with this recursion - so maybe iteration will help, unless there's another underlying logic error (e.g. a cycle).
This commit is contained in:
@@ -81,21 +81,21 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
|
|||||||
|
|
||||||
//support adding card panel and attached panels to display area recursively
|
//support adding card panel and attached panels to display area recursively
|
||||||
private void addCardPanelToDisplayArea(CardAreaPanel cardPanel) {
|
private void addCardPanelToDisplayArea(CardAreaPanel cardPanel) {
|
||||||
List<CardAreaPanel> attachedPanels = cardPanel.getAttachedPanels();
|
do {
|
||||||
if (!attachedPanels.isEmpty()) {
|
List<CardAreaPanel> attachedPanels = cardPanel.getAttachedPanels();
|
||||||
for (int i = attachedPanels.size() - 1; i >= 0; i--) {
|
if (!attachedPanels.isEmpty()) {
|
||||||
addCardPanelToDisplayArea(attachedPanels.get(i));
|
for (int i = attachedPanels.size() - 1; i >= 0; i--) {
|
||||||
|
addCardPanelToDisplayArea(attachedPanels.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (isVisible()) { //only set display area for card if area is visible
|
if (isVisible()) { //only set display area for card if area is visible
|
||||||
cardPanel.displayArea = this;
|
cardPanel.displayArea = this;
|
||||||
}
|
}
|
||||||
add(cardPanel);
|
add(cardPanel);
|
||||||
|
|
||||||
if (cardPanel.getNextPanelInStack() != null) {
|
cardPanel = cardPanel.getNextPanelInStack();
|
||||||
addCardPanelToDisplayArea(cardPanel.getNextPanelInStack());
|
} while (cardPanel != null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void removeCardPanel(final CardAreaPanel fromPanel) {
|
public final void removeCardPanel(final CardAreaPanel fromPanel) {
|
||||||
|
|||||||
Reference in New Issue
Block a user