#219198: Exception when closing all editor panes, when an sql-editor has been used in earlier session
1.1 --- a/showtodos/src/org/netbeans/modules/showtodos/TodoAnnotationProvider.java Tue Oct 02 21:55:21 2012 -0400
1.2 +++ b/showtodos/src/org/netbeans/modules/showtodos/TodoAnnotationProvider.java Thu Oct 04 13:03:16 2012 +0200
1.3 @@ -104,11 +104,13 @@
1.4 final List<Annotation> annotations =
1.5 new ArrayList<Annotation>();
1.6 final BaseDocument doc = documentFor(dataObj);
1.7 - for (Annotatable annotatable : parse(doc)) {
1.8 - final TodoAnnotation ann =
1.9 - new TodoAnnotation(annotatable.getText());
1.10 - ann.attach(annotatable);
1.11 - annotations.add(ann);
1.12 + if (doc != null) { // #219198
1.13 + for (Annotatable annotatable : parse(doc)) {
1.14 + final TodoAnnotation ann =
1.15 + new TodoAnnotation(annotatable.getText());
1.16 + ann.attach(annotatable);
1.17 + annotations.add(ann);
1.18 + }
1.19 }
1.20 file2annotation.put(fo, annotations);
1.21 } catch (BadLocationException ex) {
1.22 @@ -123,6 +125,9 @@
1.23
1.24 private static BaseDocument documentFor(final DataObject ob) {
1.25 try {
1.26 + if (!ob.isValid()) { // #219198
1.27 + return null;
1.28 + }
1.29 EditorCookie ck = ob.getCookie(EditorCookie.class);
1.30 if (ck != null) {
1.31 return (BaseDocument)ck.openDocument();