diff --git a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java index 04dae9233..8fc07da8e 100644 --- a/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java +++ b/astrid/plugin-src/com/todoroo/astrid/files/FilesControlSet.java @@ -77,21 +77,23 @@ public class FilesControlSet extends PopupControlSet { } public void refreshMetadata() { - TodorooCursor cursor = metadataService.query( - Query.select(Metadata.PROPERTIES) - .where(MetadataCriteria.byTaskAndwithKey(model.getId(), FileMetadata.METADATA_KEY))); - try { - files.clear(); - for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { - Metadata metadata = new Metadata(); - metadata.readFromCursor(cursor); - files.add(metadata); + if (model != null) { + TodorooCursor cursor = metadataService.query( + Query.select(Metadata.PROPERTIES) + .where(MetadataCriteria.byTaskAndwithKey(model.getId(), FileMetadata.METADATA_KEY))); + try { + files.clear(); + for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { + Metadata metadata = new Metadata(); + metadata.readFromCursor(cursor); + files.add(metadata); + } + } finally { + cursor.close(); } - } finally { - cursor.close(); + if (initialized) + afterInflate(); } - if (initialized) - afterInflate(); } @Override