tmf: Fix incorrect histogram state when concurrently cleared during drag
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 10 Dec 2013 17:06:32 +0000 (12:06 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 18 Dec 2013 21:30:08 +0000 (16:30 -0500)
- 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 <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/19605
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Hudson CI
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java

index 33e5136b3877d722a60fe50b619b99dbef22a75c..d47a9f80e666c28275ce6a9a142aa7f18b6cb7ea 100644 (file)
@@ -417,6 +417,9 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
      */
     public void clear() {
         fDataModel.clear();
      */
     public void clear() {
         fDataModel.clear();
+        if (fDragState == DRAG_SELECTION) {
+            updateSelectionTime();
+        }
         fDragState = DRAG_NONE;
         fDragButton = 0;
         synchronized (fDataModel) {
         fDragState = DRAG_NONE;
         fDragButton = 0;
         synchronized (fDataModel) {
index 103dacf7494beb3b150f9323f1214b57046d28bb..b9876f72cdffc4732b285c8d044ba5940cb8f5fb 100644 (file)
@@ -70,6 +70,7 @@ public class TimeRangeHistogram extends Histogram {
         fRangeDuration = 0L;
         fFullRangeStartTime = 0L;
         fFullRangeEndTime = 0L;
         fRangeDuration = 0L;
         fFullRangeStartTime = 0L;
         fFullRangeEndTime = 0L;
+        setOffset(0);
         if (fZoom != null) {
             fZoom.setFullRange(0L, 0L);
             fZoom.setNewRange(0L, 0L);
         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;
                 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;
                 return;
             } else if (event.button == 3) {
                 fDragState = DRAG_ZOOM;
This page took 0.026236 seconds and 5 git commands to generate.