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:
Myrd
2014-12-29 17:45:52 +00:00
parent 3d2156b429
commit 41a1c9b5e5

View File

@@ -81,21 +81,21 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
//support adding card panel and attached panels to display area recursively
private void addCardPanelToDisplayArea(CardAreaPanel cardPanel) {
List<CardAreaPanel> attachedPanels = cardPanel.getAttachedPanels();
if (!attachedPanels.isEmpty()) {
for (int i = attachedPanels.size() - 1; i >= 0; i--) {
addCardPanelToDisplayArea(attachedPanels.get(i));
do {
List<CardAreaPanel> attachedPanels = cardPanel.getAttachedPanels();
if (!attachedPanels.isEmpty()) {
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
cardPanel.displayArea = this;
}
add(cardPanel);
if (isVisible()) { //only set display area for card if area is visible
cardPanel.displayArea = this;
}
add(cardPanel);
if (cardPanel.getNextPanelInStack() != null) {
addCardPanelToDisplayArea(cardPanel.getNextPanelInStack());
}
cardPanel = cardPanel.getNextPanelInStack();
} while (cardPanel != null);
}
public final void removeCardPanel(final CardAreaPanel fromPanel) {