Skip to content

Commit

Permalink
Fix null pointers.
Browse files Browse the repository at this point in the history
Former-commit-id: 95e9c073e3397e0bced2040aaf429706e2ad0fc3
  • Loading branch information
dkocher committed May 13, 2014
1 parent 27e153a commit 232d9fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 8 additions & 5 deletions source/ch/cyberduck/core/local/WorkspaceApplicationLauncher.java
Expand Up @@ -23,6 +23,7 @@
import ch.cyberduck.ui.cocoa.foundation.NSDistributedNotificationCenter;
import ch.cyberduck.ui.cocoa.foundation.NSNotification;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

/**
Expand Down Expand Up @@ -60,12 +61,14 @@ public boolean open(final Local file) {
@Override
public boolean open(final Local file, final Application application) {
synchronized(NSWorkspace.class) {
if(!NSWorkspace.sharedWorkspace().openFile(file.getAbsolute(),
NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(application.getIdentifier()))) {
log.warn(String.format("Error opening file %s with application %s", file, application));
return false;
final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(application.getIdentifier());
if(StringUtils.isNotBlank(path)) {
if(NSWorkspace.sharedWorkspace().openFile(file.getAbsolute(), path)) {
return true;
}
}
return true;
log.warn(String.format("Error opening file %s with application %s", file, application));
return false;
}
}

Expand Down
11 changes: 7 additions & 4 deletions source/ch/cyberduck/ui/resources/NSImageIconCache.java
Expand Up @@ -236,10 +236,13 @@ public NSImage fileIcon(final Local path, final Integer size) {
public NSImage applicationIcon(final Application app, final Integer size) {
NSImage icon = this.load(app.getIdentifier(), size);
if(null == icon) {
icon = NSWorkspace.sharedWorkspace().iconForFile(
NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()));
icon = this.convert(app.getIdentifier(), icon, size);
this.put(app.getIdentifier(), icon, size);
final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier());
// Null if the bundle cannot be found
if(StringUtils.isNotBlank(path)) {
icon = NSWorkspace.sharedWorkspace().iconForFile(path);
icon = this.convert(app.getIdentifier(), icon, size);
this.put(app.getIdentifier(), icon, size);
}
}
if(null == icon) {
return this.iconNamed("notfound.tiff", size);
Expand Down

0 comments on commit 232d9fe

Please sign in to comment.