Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2013-12-03 15:36:09 -0500
committerBernd Hufmann2013-12-04 12:22:42 -0500
commitd3e571b039dda47e1e7a8b8a35ccbcaacc31e2ec (patch)
tree0d04f104e7946688cbe6486df1f1b3aff54ac6b2
parentcab8ee19031ce8a6e36eae1cd7680c389d4a433d (diff)
downloadorg.eclipse.linuxtools-d3e571b039dda47e1e7a8b8a35ccbcaacc31e2ec.tar.gz
org.eclipse.linuxtools-d3e571b039dda47e1e7a8b8a35ccbcaacc31e2ec.tar.xz
org.eclipse.linuxtools-d3e571b039dda47e1e7a8b8a35ccbcaacc31e2ec.zip
tmf: Fix NullPointerExeptions in Histogram view
These NPEs happens when clicking or dragging the mouse in the histogram windows before any data is available in the scaled data instance. Change-Id: I57efdb03cd53e2198580fa6c0ed047fc2dc4c3ac Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/19268 Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/FullTraceHistogram.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java2
3 files changed, 7 insertions, 3 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 12d7a29a5c..ebb16cba99 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
@@ -108,7 +108,7 @@ public class FullTraceHistogram extends Histogram {
@Override
public void mouseDown(MouseEvent event) {
- if (fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
+ if (fScaledData != null && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
if (event.button == 2 || (event.button == 1 && (event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
fDragState = DRAG_RANGE;
fDragButton = event.button;
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 823789c4fa..b2882d7ea1 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
@@ -778,6 +778,10 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
*/
protected void drawTimeRangeWindow(GC imageGC, long rangeStartTime, long rangeDuration) {
+ if (fScaledData == null) {
+ return;
+ }
+
// Map times to histogram coordinates
long bucketSpan = Math.max(fScaledData.fBucketDuration, 1);
long startTime = Math.min(rangeStartTime, rangeStartTime + rangeDuration);
@@ -834,7 +838,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
@Override
public void mouseDown(final MouseEvent event) {
- if (event.button == 1 && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
+ if (fScaledData != null && event.button == 1 && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
fDragState = DRAG_SELECTION;
fDragButton = event.button;
if ((event.stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
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 e5d5b22b4c..04b99e932e 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
@@ -114,7 +114,7 @@ public class TimeRangeHistogram extends Histogram {
@Override
public void mouseDown(MouseEvent event) {
- if (fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
+ if (fScaledData != null && fDragState == DRAG_NONE && fDataModel.getNbEvents() != 0) {
if (event.button == 2 || (event.button == 1 && (event.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL)) {
fDragState = DRAG_RANGE;
fDragButton = event.button;

Back to the top