Skip to content

Commit

Permalink
Attempted fix for a null pointer exception in #123.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Han <[email protected]>
  • Loading branch information
itdelatrisu committed Aug 15, 2015
1 parent 96f882b commit 8efcc1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/itdelatrisu/opsu/downloads/DownloadNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void createDownload(DownloadServer server) {
return;
String path = String.format("%s%c%d", Options.getOSZDir(), File.separatorChar, beatmapSetID);
String rename = String.format("%d %s - %s.osz", beatmapSetID, artist, title);
this.download = new Download(url, path, rename);
Download download = new Download(url, path, rename);
download.setListener(new DownloadListener() {
@Override
public void completed() {
Expand All @@ -260,6 +260,7 @@ public void error() {
UI.sendBarNotification("Download failed due to a connection error.");
}
});
this.download = download;
if (Options.useUnicodeMetadata()) // load glyphs
Utils.loadGlyphs(Utils.FONT_LARGE, getTitle(), null);
}
Expand Down Expand Up @@ -372,6 +373,7 @@ public void drawResult(Graphics g, int index, boolean hover, boolean focus, bool
* @param hover true if the mouse is hovering over this button
*/
public void drawDownload(Graphics g, int index, int id, boolean hover) {
Download download = this.download; // in case clearDownload() is called asynchronously
if (download == null) {
ErrorHandler.error("Trying to draw download information for button without Download object.", null, false);
return;
Expand Down

0 comments on commit 8efcc1f

Please sign in to comment.