tmf: Fix for time-alignment bug
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Thu, 26 Nov 2015 16:19:55 +0000 (11:19 -0500)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Fri, 27 Nov 2015 22:08:19 +0000 (17:08 -0500)
SashForm.setWeights() fails and throws runtime exceptions if
the sum of the passed values is 0 or if one of the values is
negative.

In some cases that include switching to a not-yet-initialized
Resource View, this situation could happen. Simply ignore sash
resize for invalid arguments. No need to time-sync an uninitialized
view anyway.

Change-Id: I3b7724795529ee91ae903ba3551491b5e0a7a645
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/59881
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java

index ac6ac327094ca348b66c8a9a9e5b05df47016c35..5f36e0c06f35dbac79afced72265dde4867b7799 100644 (file)
@@ -204,8 +204,10 @@ public class CpuUsageView extends TmfView implements ITmfTimeAligned {
         int plotAreaOffset = fXYViewer.getPointAreaOffset();
         int width1 = Math.max(0, offset - plotAreaOffset - fSashForm.getSashWidth());
         int width2 = Math.max(0, total - width1 - fSashForm.getSashWidth());
-        fSashForm.setWeights(new int[] { width1, width2 });
-        fSashForm.layout();
+        if (width1 >= 0 && width2 > 0 || width1 > 0 && width2 >= 0) {
+            fSashForm.setWeights(new int[] { width1, width2 });
+            fSashForm.layout();
+        }
 
         Composite composite = fXYViewerContainer;
         GridLayout layout = (GridLayout) composite.getLayout();
index 21c48829b9736bd0a5a0f4896b66f1b9cbf4c099..a85f4d6b403e288f87866b74ae74ed5a78ac87f6 100644 (file)
@@ -225,8 +225,10 @@ public abstract class TmfChartView extends TmfView implements ITmfTimeAligned {
         int plotAreaOffset = fChartViewer.getPointAreaOffset();
         int width1 = Math.max(0, offset - plotAreaOffset - fSashForm.getSashWidth());
         int width2 = Math.max(0, total - width1 - fSashForm.getSashWidth());
-        fSashForm.setWeights(new int[] { width1, width2 });
-        fSashForm.layout();
+        if (width1 >= 0 && width2 > 0 || width1 > 0 && width2 >= 0) {
+            fSashForm.setWeights(new int[] { width1, width2 });
+            fSashForm.layout();
+        }
 
         Composite composite = fXYViewerContainer;
         GridLayout layout = (GridLayout) composite.getLayout();
index 84922b4c63cae086b5deac855502dcb187e0c74a..f4ad39087e3dd8e95debc6cd10f99ca726a0468e 100644 (file)
@@ -441,8 +441,10 @@ public class HistogramView extends TmfView implements ITmfTimeAligned {
         int plotAreaOffset = fTimeRangeHistogram.getPointAreaOffset();
         int width1 = Math.max(0, offset - plotAreaOffset - fSashForm.getSashWidth());
         int width2 = Math.max(0, total - width1 - fSashForm.getSashWidth());
-        fSashForm.setWeights(new int[] { width1, width2 });
-        fSashForm.layout();
+        if (width1 >= 0 && width2 > 0 || width1 > 0 && width2 >= 0) {
+            fSashForm.setWeights(new int[] { width1, width2 });
+            fSashForm.layout();
+        }
 
         // calculate right margin
         GridLayout layout = (GridLayout) fTimeRangeComposite.getLayout();
index 3f11847659060a2a3bd57c105363accb2b31fc7e..3af99530f334861de5ddd3d92ee48ccebbcabb63 100644 (file)
@@ -1200,8 +1200,10 @@ public class TimeGraphCombo extends Composite {
         int timeAxisOffset = Math.min(offset, total);
         int width1 = Math.max(0, timeAxisOffset - fSashForm.getSashWidth());
         int width2 = total - timeAxisOffset;
-        fSashForm.setWeights(new int[] { width1, width2 });
-        fSashForm.layout();
+        if (width1 >= 0 && width2 > 0 || width1 > 0 && width2 >= 0) {
+            fSashForm.setWeights(new int[] { width1, width2 });
+            fSashForm.layout();
+        }
 
         Composite composite = fTimeGraphViewer.getTimeAlignedComposite();
         GridLayout layout = (GridLayout) composite.getLayout();
This page took 0.02755 seconds and 5 git commands to generate.