Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dialog to Launcher #11800

Merged
merged 9 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/main/java/org/jabref/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,29 @@ private static void initLogging(String[] args) {
/**
* @return true if JabRef should continue starting up, false if it should quit.
*/
private static boolean handleMultipleAppInstances(String[] args, RemotePreferences remotePreferences) {
private static boolean handleMultipleAppInstances(String[] args, RemotePreferences remotePreferences) throws InterruptedException {
LOGGER.trace("Checking for remote handling...");
if (remotePreferences.useRemoteServer()) {
// Try to contact already running JabRef
RemoteClient remoteClient = new RemoteClient(remotePreferences.getPort());
if (remoteClient.ping()) {
LOGGER.debug("Pinging other instance succeeded.");
// We are not alone, there is already a server out there, send command line
// arguments to other instance
LOGGER.debug("Passing arguments passed on to running JabRef...");
if (remoteClient.sendCommandLineArguments(args)) {
// So we assume it's all taken care of, and quit.
// Output to both to the log and the screen. Therefore, we do not have an additional System.out.println.
LOGGER.info("Arguments passed on to running JabRef instance. Shutting down.");
return false;
if (args.length == 0) {
// There is already a server out there, avoid showing log "Passing arguments" while no arguments are provided.
LOGGER.warn("This JabRef instance is already running. Please switch to that instance.");
} else {
LOGGER.warn("Could not communicate with other running JabRef instance.");
// We do not launch a new instance in presence of an error
return false;
// We are not alone, there is already a server out there, send command line arguments to other instance
LOGGER.debug("Passing arguments passed on to running JabRef...");
if (remoteClient.sendCommandLineArguments(args)) {
// So we assume it's all taken care of, and quit.
// Output to both to the log and the screen. Therefore, we do not have an additional System.out.println.
LOGGER.info("Arguments passed on to running JabRef instance. Shutting down.");
} else {
LOGGER.warn("Could not communicate with other running JabRef instance.");
}
}
// We do not launch a new instance in presence if there is another instance running
return false;
} else {
LOGGER.debug("Could not ping JabRef instance.");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ public void stopBackgroundTasks() {

public static void shutdownThreadPools() {
LOGGER.trace("Shutting down taskExecutor");
taskExecutor.shutdown();
if (taskExecutor != null) {
taskExecutor.shutdown();
}
LOGGER.trace("Shutting down fileUpdateMonitor");
fileUpdateMonitor.shutdown();
LOGGER.trace("Shutting down directoryMonitor");
Expand Down
Loading