Bug 400174 - [Table] Stack overflow with SWT.MeasureItem listener
Change-Id: I5437292a7cce404f354d3b9c4c0ffd506fb6220c
Signed-off-by: Niraj Modi <niraj.modi@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
index 143f501..4f53ab7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -2864,12 +2864,7 @@
boolean hitTestSelection (int index, int x, int y) {
int count = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
if (count == 0) return false;
- /*
- * Return when redraw is false & index is 0, to avoid a possible
- * recursion, when user sets ItemHeight during SWT.MeasureItem event
- * processing & with a non-zero table-row selection, refer bug 400174.
- */
- if (!hooks (SWT.MeasureItem) || (!redraw && index == 0)) return false;
+ if (!hooks (SWT.MeasureItem)) return false;
boolean result = false;
if (0 <= index && index < count) {
TableItem item = _getItem (index);
@@ -4676,9 +4671,14 @@
* visible and are shown afterwards. The fix is to
* save the top index, scroll to the top of the table
* and then restore the original top index.
+ *
+ * Note: Above fix causes recursion when setItemHeight is
+ * called during during SWT.MeasureItem event processing
+ * & with a non-zero table-row selection, bug 400174.
+ * Solution is skip the fix when redraw is false.
*/
int topIndex = getTopIndex ();
- if (fixScroll && topIndex != 0) {
+ if (fixScroll && topIndex != 0 && redraw) {
setRedraw (false);
setTopIndex (0);
}