Skip to content

Commit

Permalink
2142-added null check on DB to eleminate null pointers when case clos…
Browse files Browse the repository at this point in the history
…ed while recatagorizing
  • Loading branch information
William Schaefer committed Dec 27, 2016
1 parent 9c6486d commit d671227
Showing 1 changed file with 18 additions and 15 deletions.
Expand Up @@ -188,7 +188,7 @@ synchronized public Set<GroupKey<?>> getGroupKeysForFile(DrawableFile file) {
* the groups the given file is a part of
*
* @return a a set of {@link GroupKey}s representing the group(s) the given
* file is a part of
* file is a part of
*/
synchronized public Set<GroupKey<?>> getGroupKeysForFileID(Long fileID) {
try {
Expand All @@ -208,7 +208,7 @@ synchronized public Set<GroupKey<?>> getGroupKeysForFileID(Long fileID) {
* @param groupKey
*
* @return return the DrawableGroup (if it exists) for the given GroupKey,
* or null if no group exists for that key.
* or null if no group exists for that key.
*/
@Nullable
public DrawableGroup getGroupForKey(@Nonnull GroupKey<?> groupKey) {
Expand Down Expand Up @@ -266,15 +266,16 @@ public boolean isRegrouping() {
*/
@ThreadConfined(type = ThreadType.JFX)
public void markGroupSeen(DrawableGroup group, boolean seen) {

db.markGroupSeen(group.getGroupKey(), seen);
group.setSeen(seen);
if (seen) {
unSeenGroups.removeAll(group);
} else if (unSeenGroups.contains(group) == false) {
unSeenGroups.add(group);
if (!Objects.isNull(db)) {
db.markGroupSeen(group.getGroupKey(), seen);
group.setSeen(seen);
if (seen) {
unSeenGroups.removeAll(group);
} else if (unSeenGroups.contains(group) == false) {
unSeenGroups.add(group);
}
FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy));
}
FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy));
}

/**
Expand All @@ -283,7 +284,7 @@ public void markGroupSeen(DrawableGroup group, boolean seen) {
* no-op
*
* @param groupKey the value of groupKey
* @param fileID the value of file
* @param fileID the value of file
*/
public synchronized DrawableGroup removeFromGroup(GroupKey<?> groupKey, final Long fileID) {
//get grouping this file would be in
Expand Down Expand Up @@ -496,7 +497,7 @@ public ReadOnlyObjectProperty<SortOrder> getSortOrderProperty() {
* @param groupBy
* @param sortBy
* @param sortOrder
* @param force true to force a full db query regroup
* @param force true to force a full db query regroup
*/
public synchronized <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) {

Expand Down Expand Up @@ -644,8 +645,8 @@ private DrawableGroup popuplateIfAnalyzed(GroupKey<?> groupKey, ReGroupTask<?> t
* task was still running)
*/

} else { // no task or un-cancelled task
if ((groupKey.getAttribute() != DrawableAttribute.PATH) || db.isGroupAnalyzed(groupKey)) {
} else // no task or un-cancelled task
if ((groupKey.getAttribute() != DrawableAttribute.PATH) || db.isGroupAnalyzed(groupKey)) {
/*
* for attributes other than path we can't be sure a group is
* fully analyzed because we don't know all the files that will
Expand Down Expand Up @@ -681,12 +682,12 @@ private DrawableGroup popuplateIfAnalyzed(GroupKey<?> groupKey, ReGroupTask<?> t
markGroupSeen(group, groupSeen);
});
return group;

}
} catch (TskCoreException ex) {
LOGGER.log(Level.SEVERE, "failed to get files for group: " + groupKey.getAttribute().attrName.toString() + " = " + groupKey.getValue(), ex); //NON-NLS
}
}
}
return null;
}

Expand Down Expand Up @@ -776,7 +777,9 @@ protected Void call() throws Exception {
updateMessage(Bundle.ReGroupTask_progressUpdate(groupBy.attrName.toString(), val));
updateProgress(p, vals.size());
groupProgress.progress(Bundle.ReGroupTask_progressUpdate(groupBy.attrName.toString(), val), p);

popuplateIfAnalyzed(new GroupKey<A>(groupBy, val), this);

}
Platform.runLater(() -> FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy)));

Expand Down

0 comments on commit d671227

Please sign in to comment.