From c43b2b3bb95a781bdc392ba7018be2cf10e40227 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Tue, 30 Apr 2019 00:28:22 +0800 Subject: [PATCH] Fix potential "not on UI thread" exception --- .../java/org/jackhuang/hmcl/ui/LeftPaneController.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java index 8abbec4b4..5469889d0 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LeftPaneController.java @@ -120,11 +120,10 @@ public final class LeftPaneController extends AdvancedListBox { if (modpackFile.exists()) { Task.ofResult(() -> CompressingUtils.findSuitableEncoding(modpackFile.toPath())) .thenApply(encoding -> ModpackHelper.readModpackManifest(modpackFile.toPath(), encoding)) - .thenAccept(modpack -> { - AtomicReference region = new AtomicReference<>(); - TaskExecutor executor = ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack) - .with(Task.of(Schedulers.javafx(), this::checkAccount)).executor(); - region.set(Controllers.taskDialog(executor, i18n("modpack.installing"))); + .thenApply(modpack -> ModpackHelper.getInstallTask(repository.getProfile(), modpackFile, modpack.getName(), modpack) + .with(Task.of(Schedulers.javafx(), this::checkAccount)).executor()) + .thenAccept(Schedulers.javafx(), executor -> { + Controllers.taskDialog(executor, i18n("modpack.installing")); executor.start(); }).start(); }