From 06fcc8feb401aa6756ce53eb98c3dd6ea5d6f79d Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Tue, 10 Dec 2013 12:06:32 -0500 Subject: [PATCH] tmf: Fix incorrect histogram state when concurrently cleared during drag - Reset the offset when drag zoom interrupted by clear - Update selection when drag selection interrupted by clear - Fix overflow in min and max offset calculation Change-Id: I6eea70d713d4b46e75d254b9374631623c023600 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/19605 Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann Tested-by: Hudson CI --- .../linuxtools/tmf/ui/views/histogram/Histogram.java | 3 +++ .../tmf/ui/views/histogram/TimeRangeHistogram.java | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java index 33e5136b38..d47a9f80e6 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java @@ -417,6 +417,9 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi */ public void clear() { fDataModel.clear(); + if (fDragState == DRAG_SELECTION) { + updateSelectionTime(); + } fDragState = DRAG_NONE; fDragButton = 0; synchronized (fDataModel) { diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java index 103dacf749..b9876f72cd 100644 --- a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java +++ b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java @@ -70,6 +70,7 @@ public class TimeRangeHistogram extends Histogram { fRangeDuration = 0L; fFullRangeStartTime = 0L; fFullRangeEndTime = 0L; + setOffset(0); if (fZoom != null) { fZoom.setFullRange(0L, 0L); fZoom.setNewRange(0L, 0L); @@ -119,8 +120,10 @@ public class TimeRangeHistogram extends Histogram { fDragState = DRAG_RANGE; fDragButton = event.button; fStartPosition = event.x; - fMaxOffset = (int) ((fRangeStartTime - fFullRangeStartTime) / fScaledData.fBucketDuration); - fMinOffset = (int) ((fRangeStartTime + fRangeDuration - fFullRangeEndTime) / fScaledData.fBucketDuration); + long maxOffset = (fRangeStartTime - fFullRangeStartTime) / fScaledData.fBucketDuration; + long minOffset = (fRangeStartTime + fRangeDuration - fFullRangeEndTime) / fScaledData.fBucketDuration; + fMaxOffset = (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, maxOffset)); + fMinOffset = (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, minOffset)); return; } else if (event.button == 3) { fDragState = DRAG_ZOOM; -- 2.34.1