Fix potential "not on UI thread" exception

This commit is contained in:
huanghongxun
2019-04-30 00:28:22 +08:00
parent ea19e6efd8
commit c43b2b3bb9

View File

@@ -120,11 +120,10 @@ public final class LeftPaneController extends AdvancedListBox {
if (modpackFile.exists()) { if (modpackFile.exists()) {
Task.ofResult(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath())) Task.ofResult(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath()))
.thenApply(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding)) .thenApply(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding))
.thenAccept(modpack -> { .thenApply(modpack -> ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack)
AtomicReference<Region> region = new AtomicReference<>(); .with(Task.of(Schedulers.javafx(), this::checkAccount)).executor())
TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack) .thenAccept(Schedulers.javafx(), executor -> {
.with(Task.of(Schedulers.javafx(), this::checkAccount)).executor(); Controllers.taskDialog(executor, i18n("modpack.installing"));
region.set(Controllers.taskDialog(executor, i18n("modpack.installing")));
executor.start(); executor.start();
}).start(); }).start();
} }