Fixed BE client potentially segfaulting on startup

This commit is contained in:
Anuken
2020-08-18 11:07:38 -04:00
parent 88dba65593
commit 065a8e712c
+3 -3
View File
@@ -47,7 +47,7 @@ public class BeControl{
/** asynchronously checks for updates. */ /** asynchronously checks for updates. */
public void checkUpdate(Boolc done){ public void checkUpdate(Boolc done){
Core.net.httpGet("https://api.github.com/repos/Anuken/MindustryBuilds/releases/latest", res -> { Core.net.httpGet("https://api.github.com/repos/Anuken/MindustryBuilds/releases/latest", res -> Core.app.post(() -> {
if(res.getStatus() == HttpStatus.OK){ if(res.getStatus() == HttpStatus.OK){
Jval val = Jval.read(res.getResultAsString()); Jval val = Jval.read(res.getResultAsString());
int newBuild = Strings.parseInt(val.getString("tag_name", "0")); int newBuild = Strings.parseInt(val.getString("tag_name", "0"));
@@ -65,13 +65,13 @@ public class BeControl{
}else{ }else{
Core.app.post(() -> done.get(false)); Core.app.post(() -> done.get(false));
} }
}, error -> { }), error -> Core.app.post(() -> {
if(!headless){ if(!headless){
ui.showException(error); ui.showException(error);
}else{ }else{
error.printStackTrace(); error.printStackTrace();
} }
}); }));
} }
/** @return whether a new update is available */ /** @return whether a new update is available */