From: Matti Tahvonen Date: Wed, 21 May 2008 09:10:52 +0000 (+0000) Subject: avoiding possible infinite loop if lot of cache row requests in variable burst queue X-Git-Tag: 6.7.0.beta1~4723 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9191d6b62d637fd1f9e92f18ec0fefe44cec3b65;p=vaadin-framework.git avoiding possible infinite loop if lot of cache row requests in variable burst queue svn changeset:4592/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java index ae0266cd1f..8244f74851 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java @@ -331,16 +331,18 @@ public class IScrollTable extends Composite implements Table, ScrollListener, final int optimalFirstRow = (int) (firstRowInViewPort - pageLength * CACHE_RATE); - while (tBody.getLastRendered() > optimalFirstRow + boolean cont = true; + while (cont && tBody.getLastRendered() > optimalFirstRow && tBody.getFirstRendered() < optimalFirstRow) { // client.console.log("removing row from start"); - tBody.unlinkRow(true); + cont = tBody.unlinkRow(true); } final int optimalLastRow = (int) (firstRowInViewPort + pageLength + pageLength * CACHE_RATE); - while (tBody.getLastRendered() > optimalLastRow) { + cont = true; + while (cont && tBody.getLastRendered() > optimalLastRow) { // client.console.log("removing row from the end"); - tBody.unlinkRow(false); + cont = tBody.unlinkRow(false); } tBody.fixSpacers(); @@ -1769,9 +1771,12 @@ public class IScrollTable extends Composite implements Table, ScrollListener, return renderedRows.iterator(); } - public void unlinkRow(boolean fromBeginning) { + /** + * @return false if couldn't remove row + */ + public boolean unlinkRow(boolean fromBeginning) { if (lastRendered - firstRendered < 0) { - return; + return false; } int index; if (fromBeginning) { @@ -1788,6 +1793,7 @@ public class IScrollTable extends Composite implements Table, ScrollListener, orphan(toBeRemoved); renderedRows.remove(index); fixSpacers(); + return true; } public boolean remove(Widget w) {