summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorChristian Walther2013-01-30 05:24:46 (EST)
committer Gerrit Code Review @ Eclipse.org2013-07-25 11:31:54 (EDT)
commit2fdf604448009727b818987b0f0684abe8c4bc22 (patch)
treef4e14861dfd3eca68cdd5486586b99c5f6584cb7
parent2ca28faf3fff2ebc3bf650b826119a9295436b57 (diff)
downloadeclipse.platform.ui-2fdf604448009727b818987b0f0684abe8c4bc22.zip
eclipse.platform.ui-2fdf604448009727b818987b0f0684abe8c4bc22.tar.gz
eclipse.platform.ui-2fdf604448009727b818987b0f0684abe8c4bc22.tar.bz2
Bug 389012 - Division by zero exception in TrimBarLayout - Part 2refs/changes/27/14227/2
Don’t modify the Points contained in curLine.sizeMap because the same TrimLine can be reused in several layout calls. Change-Id: I9cbaa368bbe8a726425d9212a3c080dc126e52bc Signed-off-by: Christian Walther <walther@indel.ch>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
index baeebb6..254c5ff 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/TrimBarLayout.java
@@ -241,19 +241,21 @@ public class TrimBarLayout extends Layout {
continue;
}
Point ctrlSize = curLine.sizeMap.get(ctrl);
- boolean zeroSize = ctrlSize.x == 0 && ctrlSize.y == 0;
+ int ctrlWidth = ctrlSize.x;
+ int ctrlHeight = ctrlSize.y;
+ boolean zeroSize = ctrlWidth == 0 && ctrlHeight == 0;
// If its a 'spacer' then add any available 'extra' space to it
if (isSpacer(ctrl)) {
int extra = remainingExtraSpace / remainingSpacerCount;
if (horizontal) {
- ctrlSize.x += extra;
+ ctrlWidth += extra;
// leave out 4 pixels at the bottom to avoid overlapping the
// 1px bottom border of the toolbar (bug 389941)
- ctrl.setBounds(curX, curY, ctrlSize.x, curLine.minor - 4);
+ ctrl.setBounds(curX, curY, ctrlWidth, curLine.minor - 4);
} else {
- ctrlSize.y += extra;
- ctrl.setBounds(curX, curY, curLine.minor, extra);
+ ctrlHeight += extra;
+ ctrl.setBounds(curX, curY, curLine.minor, ctrlHeight);
}
zeroSize = false;
remainingExtraSpace -= extra;
@@ -261,19 +263,19 @@ public class TrimBarLayout extends Layout {
}
if (horizontal) {
- int offset = (curLine.minor - ctrlSize.y) / 2;
+ int offset = (curLine.minor - ctrlHeight) / 2;
if (!isSpacer(ctrl)) {
if (!zeroSize)
- ctrl.setBounds(curX, curY + offset, ctrlSize.x,
- ctrlSize.y);
+ ctrl.setBounds(curX, curY + offset, ctrlWidth,
+ ctrlHeight);
else
ctrl.setBounds(curX, curY, 0, 0);
}
- curX += ctrlSize.x;
+ curX += ctrlWidth;
} else {
- int offset = (curLine.minor - ctrlSize.x) / 2;
- ctrl.setBounds(curX + offset, curY, ctrlSize.x, ctrlSize.y);
- curY += ctrlSize.y;
+ int offset = (curLine.minor - ctrlWidth) / 2;
+ ctrl.setBounds(curX + offset, curY, ctrlWidth, ctrlHeight);
+ curY += ctrlHeight;
}
}
}