fix: 禁止取消未生效 (#5600)
This commit is contained in:
@@ -31,7 +31,6 @@ import org.jackhuang.hmcl.util.TaskCancellationAction;
|
|||||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed;
|
import static org.jackhuang.hmcl.ui.FXUtils.onEscPressed;
|
||||||
@@ -83,8 +82,9 @@ public class TaskExecutorDialogPane extends BorderPane {
|
|||||||
setCancel(cancel);
|
setCancel(cancel);
|
||||||
|
|
||||||
btnCancel.setOnAction(e -> {
|
btnCancel.setOnAction(e -> {
|
||||||
Optional.ofNullable(executor).ifPresent(TaskExecutor::cancel);
|
|
||||||
if (onCancel.getCancellationAction() != null) {
|
if (onCancel.getCancellationAction() != null) {
|
||||||
|
if (executor != null)
|
||||||
|
executor.cancel();
|
||||||
onCancel.getCancellationAction().accept(this);
|
onCancel.getCancellationAction().accept(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user