Skip to content

Commit

Permalink
Move launch arg handling to background when running UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Jan 5, 2025
1 parent 529061b commit 5728699
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions recaf-ui/src/main/java/software/coley/recaf/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import software.coley.recaf.util.JFXValidation;
import software.coley.recaf.util.JdkValidation;
import software.coley.recaf.util.Lang;
import software.coley.recaf.util.threading.ThreadUtil;
import software.coley.recaf.workspace.model.BasicWorkspace;

import java.io.File;
Expand All @@ -34,6 +35,7 @@
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
Expand Down Expand Up @@ -90,13 +92,14 @@ public static void main(String[] args) {
launchArgs.setCommand(launchArgValues);
launchArgs.setRawArgs(args);

// Setup the launch-handler bean to load inputs if specified by the launch arguments.
// It will be executed
LaunchHandler.task = Main::initHandleInputs;
// Set up the launch-handler bean to load inputs if specified by the launch arguments.
Bean<?> bean = recaf.getContainer().getBeanContainer().getBeans(LaunchHandler.class).iterator().next();
if (launchArgValues.isHeadless()) {
LaunchHandler.task = Main::initHandleInputs;
EagerInitializationExtension.getApplicationScopedEagerBeans().add(bean);
} else {
// Run input handling in the background so that it does not block the UI
LaunchHandler.task = () -> CompletableFuture.runAsync(Main::initHandleInputs, ThreadUtil.executor());
EagerInitializationExtension.getApplicationScopedEagerBeansForUi().add(bean);
}

Expand Down

0 comments on commit 5728699

Please sign in to comment.