From: Marc-Andre Laperle Date: Thu, 26 Nov 2015 16:19:55 +0000 (-0500) Subject: tmf: Fix for time-alignment bug X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=40f88571dde1c83c6972a766f8157c2874b5865b;p=deliverable%2Ftracecompass.git tmf: Fix for time-alignment bug 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 Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/59881 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java index ac6ac32709..5f36e0c06f 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/analysis/os/linux/ui/views/cpuusage/CpuUsageView.java @@ -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(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java index 21c48829b9..a85f4d6b40 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java @@ -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(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java index 84922b4c63..f4ad39087e 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java @@ -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(); diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java index 3f11847659..3af99530f3 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java @@ -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();