diff options
author | Siva Velusamy <vsiva@google.com> | 2011-12-12 11:10:33 -0800 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2011-12-12 11:17:50 -0800 |
commit | 4481c9d73bcbb7afb958a575d1d86dd2e2c21719 (patch) | |
tree | 3a8c6b4d8d85f8d982e61c9823d4a45e3efb4e2a /ddms/libs | |
parent | 542d119b6c8353283199e493402c3b2fd720c57c (diff) | |
download | sdk-4481c9d73bcbb7afb958a575d1d86dd2e2c21719.zip sdk-4481c9d73bcbb7afb958a575d1d86dd2e2c21719.tar.gz sdk-4481c9d73bcbb7afb958a575d1d86dd2e2c21719.tar.bz2 |
logcat: fix npe & clear log in filtered view
1. Fix NPE when selecting all items: Issue is that in case of a
table with SWT.VIRTUAL, tableItem.getData() could return NULL if
the item hasn't been shown. So we have to rely on the original
model to retrieve the items.
2. When viewing items after applying a filter, clear log will
clear the full log but not the filtered view. To clear the filtered
view, the SWT ViewerFilters have to be reapplied.
Change-Id: I6c66be4e0e8abb6db114588f382bcd3b9fe8ee0f
Diffstat (limited to 'ddms/libs')
-rw-r--r-- | ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java index 9084623..22052f9 100644 --- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java +++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java @@ -75,6 +75,7 @@ import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; /** @@ -547,6 +548,9 @@ public final class LogCatPanel extends SelectionDependentPanel if (mReceiver != null) { mReceiver.clearMessages(); refreshLogCatTable(); + + // the filters view is not cleared unless the filters are re-applied. + updateAppliedFilters(); } } }); @@ -663,10 +667,21 @@ public final class LogCatPanel extends SelectionDependentPanel int[] indices = table.getSelectionIndices(); Arrays.sort(indices); /* Table.getSelectionIndices() does not specify an order */ + // Get items from the table's input as opposed to getting each table item's data. + // Retrieving table item's data can return NULL in case of a virtual table if the item + // has not been displayed yet. + Object input = mViewer.getInput(); + if (!(input instanceof LogCatMessageList)) { + return Collections.emptyList(); + } + Object []items = ((LogCatMessageList) input).toArray(); + List<LogCatMessage> selectedMessages = new ArrayList<LogCatMessage>(indices.length); for (int i : indices) { - LogCatMessage m = (LogCatMessage) table.getItem(i).getData(); - selectedMessages.add(m); + if (i < items.length) { + LogCatMessage m = (LogCatMessage) items[i]; + selectedMessages.add(m); + } } return selectedMessages; |