Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2013-12-04 17:04:59 -0500
committerPatrick Tasse2013-12-06 09:43:41 -0500
commit3223f89cc702f8fe68194a4c73afb0a0941d53a4 (patch)
tree5f63e959bb1f13ed3f0de7b81d030f4733b6d34d
parent4bf37e3782337a831d98a012bdfd88927b31b5f4 (diff)
downloadorg.eclipse.linuxtools-3223f89cc702f8fe68194a4c73afb0a0941d53a4.tar.gz
org.eclipse.linuxtools-3223f89cc702f8fe68194a4c73afb0a0941d53a4.tar.xz
org.eclipse.linuxtools-3223f89cc702f8fe68194a4c73afb0a0941d53a4.zip
tmf: Fix concurrency issues in histogram view
- Make sure signals sent to itself with the signal throttler are executed in the UI thread, so that Histogram.clear() doesn't concurrently set fScaledData to null - Clear the drag state when Histogram.clear() is called so that subsequent mouse operations don't need to protect from clear during drag - Prevent the trace updated signal from constantly resetting the histogram range so that trace indexing doesn't interfere with drag move and drag zoom - Fix time range in full trace histogram being offset incorrectly when new trace events cause the scale to change during dragging - Fix mouse wheel zoom out snapped to current zoom start time in time range histogram when trace updated Change-Id: I1c6e71d9c7f26dec93192768e99306fdbb978dd1 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/19341
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java21
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java38
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java4
4 files changed, 40 insertions, 25 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java
index 9fa0bf4a73..6e6adc0805 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java
@@ -84,6 +84,7 @@ public class FullTraceHistogram extends Histogram {
*/
public void setFullRange(long startTime, long endTime) {
fZoom.setFullRange(startTime, endTime);
+ fZoom.setNewRange(fRangeStartTime, fRangeDuration);
}
/**
@@ -103,7 +104,7 @@ public class FullTraceHistogram extends Histogram {
// MouseListener
// ------------------------------------------------------------------------
- private int fStartPosition;
+ private int fStartDelta;
private boolean fMouseMoved;
@Override
@@ -112,7 +113,8 @@ public class FullTraceHistogram extends Histogram {
if (event.button == 2 || (event.button == 1 && (event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
fDragState = DRAG_RANGE;
fDragButton = event.button;
- fStartPosition = event.x;
+ int center = (int) (((fRangeStartTime + fRangeDuration / 2) - fScaledData.fFirstBucketTime) / fScaledData.fBucketDuration);
+ fStartDelta = center - event.x;
fMouseMoved = false;
return;
} else if (event.button == 3) {
@@ -172,18 +174,9 @@ public class FullTraceHistogram extends Histogram {
@Override
public void mouseMove(MouseEvent event) {
if (fDragState == DRAG_RANGE) {
- int nbBuckets = event.x - fStartPosition;
- long delta = nbBuckets * fScaledData.fBucketDuration;
- long newStart = fZoom.getStartTime() + delta;
- if (newStart < getStartTime()) {
- newStart = getStartTime();
- }
- long newEnd = newStart + fZoom.getDuration();
- if (newEnd > getEndTime()) {
- newEnd = getEndTime();
- newStart = newEnd - fZoom.getDuration();
- }
- fRangeStartTime = newStart;
+ int center = event.x + fStartDelta;
+ long newStart = getTimestamp(center) - fRangeDuration / 2;
+ fRangeStartTime = Math.max(getStartTime(), Math.min(getEndTime() - fRangeDuration, newStart));
fCanvas.redraw();
fMouseMoved = true;
return;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
index 41611e8177..33e5136b38 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
@@ -417,6 +417,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
*/
public void clear() {
fDataModel.clear();
+ fDragState = DRAG_NONE;
+ fDragButton = 0;
synchronized (fDataModel) {
fScaledData = null;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
index aa5e95f4da..121bd96bf0 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
@@ -50,6 +50,7 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IActionBars;
@@ -581,9 +582,6 @@ public class HistogramView extends TmfView {
fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
- fFullTraceHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
- fTimeRangeHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
-
if ((fFullTraceRequest != null) && fFullTraceRequest.getRange().getEndTime().compareTo(signal.getRange().getEndTime()) < 0) {
sendFullRangeRequest(fullRange);
}
@@ -596,9 +594,20 @@ public class HistogramView extends TmfView {
* @param signal the signal to process
*/
@TmfSignalHandler
- public void currentTimeUpdated(TmfTimeSynchSignal signal) {
- // Because this can't happen :-)
- assert (signal != null);
+ public void currentTimeUpdated(final TmfTimeSynchSignal signal) {
+ if (Display.getCurrent() == null) {
+ // Make sure the signal is handled in the UI thread
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (fParent.isDisposed()) {
+ return;
+ }
+ currentTimeUpdated(signal);
+ }
+ });
+ return;
+ }
// Update the selected time range
ITmfTimestamp beginTime = signal.getBeginTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE);
@@ -611,9 +620,20 @@ public class HistogramView extends TmfView {
* @param signal the signal to process
*/
@TmfSignalHandler
- public void timeRangeUpdated(TmfRangeSynchSignal signal) {
- // Because this can't happen :-)
- assert (signal != null);
+ public void timeRangeUpdated(final TmfRangeSynchSignal signal) {
+ if (Display.getCurrent() == null) {
+ // Make sure the signal is handled in the UI thread
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (fParent.isDisposed()) {
+ return;
+ }
+ timeRangeUpdated(signal);
+ }
+ });
+ return;
+ }
if (fTrace != null) {
// Validate the time range
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
index d86862048a..103dacf749 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
@@ -100,8 +100,8 @@ public class TimeRangeHistogram extends Histogram {
public void setFullRange(long startTime, long endTime) {
fFullRangeStartTime = startTime;
fFullRangeEndTime = endTime;
- long currentFirstEvent = getStartTime();
- fZoom.setFullRange((currentFirstEvent == 0) ? startTime : currentFirstEvent, endTime);
+ fZoom.setFullRange(startTime, endTime);
+ fZoom.setNewRange(fRangeStartTime, fRangeDuration);
}
// ------------------------------------------------------------------------

Back to the top