From: jungwook.ryu Date: Tue, 8 Jul 2014 09:25:09 +0000 (+0900) Subject: Common : fix potential bugs. (type casting, null pointer exception) X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a190837546828188414abfa2bf4f57d17c4b2e09;p=sdk%2Ftools%2Fdynamic-analyzer.git Common : fix potential bugs. (type casting, null pointer exception) Change-Id: I66ec7197e23d81d577cb7b105d2024b3aee0f523 Signed-off-by: jungwook.ryu --- diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/timeline/DATimeline.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/timeline/DATimeline.java index 6658654..4dc8593 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/timeline/DATimeline.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/timeline/DATimeline.java @@ -300,18 +300,18 @@ public class DATimeline extends Canvas { .getTime()); double endMarkerPosition = secondToPixcel(endRangeMarker.getTime()); - // it's means that mouse pointer is in end marker image. + // it's means that mouse pointer is in range of end marker image. if (x >= endMarkerPosition - - endRangeMarker.getImage().getBounds().width / 2 + (int)(endRangeMarker.getImage().getBounds().width / 2 + 1) && x <= endMarkerPosition + - endRangeMarker.getImage().getBounds().width / 2) { + (int)(endRangeMarker.getImage().getBounds().width / 2 + 1)) { endRangeMarker.setStatus(status); DATimeline.this.redraw(); - // it's means that mouse pointer is in start marker image. + // it's means that mouse pointer is in range of start marker image. } else if (x >= startMarkerPosition - - startRangeMarker.getImage().getBounds().width / 2 + (int)(startRangeMarker.getImage().getBounds().width / 2 + 1) && x <= startMarkerPosition - + startRangeMarker.getImage().getBounds().width / 2) { + + (int)(startRangeMarker.getImage().getBounds().width / 2 + 1)) { startRangeMarker.setStatus(status); DATimeline.this.redraw(); } else { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java index 94cb326..1764d37 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/TableTooltipListener.java @@ -68,6 +68,7 @@ import org.tizen.dynamicanalyzer.ui.timeline.calltrace.FunctionEntryDBTable; import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat; import org.tizen.dynamicanalyzer.util.CommonUtil; +import org.tizen.dynamicanalyzer.util.DALogger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; @@ -243,7 +244,7 @@ public class TableTooltipListener implements Listener { } DATableDataFormat tableData = (DATableDataFormat) item.getData(); long addr = -1; - String libName = null; + String libName = ""; int pid = -1; long time = 0; @@ -265,12 +266,17 @@ public class TableTooltipListener implements Listener { } public void viewSource(int x, int y, SourceLine sl, boolean onViewSourceFromContext) { + if (sl == null) { + DALogger.getInstance().warning("Input SourceLine is null."); + return; + } + this.onViewSourceFromContext = onViewSourceFromContext; GridItem item = grid.getItem(new Point(x, y)); if (null != item) { disposeTooltip(); - if (null == sl || sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { + if (sl.getError() != AnalyzerConstants.SOURCELINE_NOERROR) { createErrorTooltip(x, y, sl.getError()); return; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUChart.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUChart.java index 6e06476..866c4c3 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUChart.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/chart/CPUChart.java @@ -48,6 +48,7 @@ import org.tizen.dynamicanalyzer.ui.timeline.ProcessLoadDBTable; import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable; import org.tizen.dynamicanalyzer.ui.timeline.TargetProcessDBTable; import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.util.DALogger; import org.tizen.dynamicanalyzer.utils.Formatter; import org.tizen.dynamicanalyzer.widgets.chart.DAChart; import org.tizen.dynamicanalyzer.widgets.chart.DAChartPlot; @@ -267,12 +268,11 @@ public class CPUChart extends TimelineChart { ColorResources.SERIES_COLOR_CPU_SYSTEM); newSeries.addSeriesItem(new DAChartSeriesItem(time, load, Formatter.toPercentageFormat(load))); - try { - processItem.getChart().addSeries(newSeries); - } catch (NullPointerException e) { - e.printStackTrace(); + if (processItem == null) { + DALogger.getInstance().error("processItem is null"); + return; } - + processItem.getChart().addSeries(newSeries); childSeriesMap.put(pid, newSeries); } } else { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineEditItemsDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineEditItemsDialog.java index b344bdd..e42a9fc 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineEditItemsDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineEditItemsDialog.java @@ -81,6 +81,7 @@ import org.tizen.dynamicanalyzer.resources.FontResources; import org.tizen.dynamicanalyzer.resources.ImageResources; import org.tizen.dynamicanalyzer.ui.timeline.chart.TimelineChart; import org.tizen.dynamicanalyzer.ui.toolbar.ConfigureManager; +import org.tizen.dynamicanalyzer.util.DALogger; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; import org.tizen.dynamicanalyzer.widgets.button.DACustomButton; import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener; @@ -360,6 +361,10 @@ public class TimelineEditItemsDialog extends DAMessageBox { source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { TableItem sourceItem = findTableItem(event.x, event.y); + if (sourceItem == null) { + DALogger.getInstance().warning("drag sourceItem is null."); + return; + } event.data = sourceItem.getText(); chartTableViewer.getTable().redraw(); } @@ -368,6 +373,10 @@ public class TimelineEditItemsDialog extends DAMessageBox { public void dragStart(DragSourceEvent event) { // set drag image. this image will be shown below of mouse pointer. TableItem selection = findTableItem(event.x, event.y); + if (selection == null) { + DALogger.getInstance().warning("drag selection is null."); + return; + } Image dropImage = imageMap.get(((TableItemData)selection.getData()).chartType); ((TableItemData)selection.getData()).isDrag = true; event.image = dropImage;