mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-03 19:36:53 -04:00
parent
46502875c5
commit
acc96b95c8
@ -59,6 +59,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import static javafx.application.Platform.runLater;
|
import static javafx.application.Platform.runLater;
|
||||||
import static javafx.application.Platform.setImplicitExit;
|
import static javafx.application.Platform.setImplicitExit;
|
||||||
@ -125,6 +126,9 @@ public final class LauncherHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void launch0() {
|
private void launch0() {
|
||||||
|
// https://github.com/HMCL-dev/HMCL/pull/4121
|
||||||
|
PROCESSES.removeIf(it -> it.get() == null);
|
||||||
|
|
||||||
HMCLGameRepository repository = profile.getRepository();
|
HMCLGameRepository repository = profile.getRepository();
|
||||||
DefaultDependencyManager dependencyManager = profile.getDependency();
|
DefaultDependencyManager dependencyManager = profile.getDependency();
|
||||||
AtomicReference<Version> version = new AtomicReference<>(MaintainTask.maintain(repository, repository.getResolvedVersion(selectedVersion)));
|
AtomicReference<Version> version = new AtomicReference<>(MaintainTask.maintain(repository, repository.getResolvedVersion(selectedVersion)));
|
||||||
@ -209,7 +213,7 @@ public final class LauncherHelper {
|
|||||||
}
|
}
|
||||||
}).thenAcceptAsync(process -> { // process is LaunchTask's result
|
}).thenAcceptAsync(process -> { // process is LaunchTask's result
|
||||||
if (scriptFile == null) {
|
if (scriptFile == null) {
|
||||||
PROCESSES.add(process);
|
PROCESSES.add(new WeakReference<>(process));
|
||||||
if (launcherVisibility == LauncherVisibility.CLOSE)
|
if (launcherVisibility == LauncherVisibility.CLOSE)
|
||||||
Launcher.stopApplication();
|
Launcher.stopApplication();
|
||||||
else
|
else
|
||||||
@ -896,10 +900,10 @@ public final class LauncherHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Queue<ManagedProcess> PROCESSES = new ConcurrentLinkedQueue<>();
|
public static final Queue<WeakReference<ManagedProcess>> PROCESSES = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
public static void stopManagedProcesses() {
|
public static void stopManagedProcesses() {
|
||||||
while (!PROCESSES.isEmpty())
|
while (!PROCESSES.isEmpty())
|
||||||
Optional.ofNullable(PROCESSES.poll()).ifPresent(ManagedProcess::stop);
|
Optional.ofNullable(PROCESSES.poll()).map(WeakReference::get).ifPresent(ManagedProcess::stop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user