From 6155306acceed880b29f821373e46aeb2ac9ccec Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Wed, 12 May 2021 08:46:24 +0200 Subject: [PATCH] always try obtain application lock on startup --- .../com/sparrowwallet/sparrow/MainApp.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index ce1da249..cf7cb8d8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -173,16 +173,15 @@ public class MainApp extends Application { } List fileUriArguments = jCommander.getUnknownOptions(); - if(!fileUriArguments.isEmpty()) { - if(args.network == null && args.dir == null) { - try { - sparrowUnique = new SparrowUnique(APP_ID, fileUriArguments); - sparrowUnique.acquireLock(); //Will exit app after sending fileUriArguments if lock cannot be acquired - } catch(Unique4jException e) { - getLogger().error("Could not obtain unique lock", e); - } - } + try { + sparrowUnique = new SparrowUnique(fileUriArguments); + sparrowUnique.acquireLock(); //If fileUriArguments is not empty, will exit app after sending fileUriArguments if lock cannot be acquired + } catch(Unique4jException e) { + getLogger().error("Could not access application lock", e); + } + + if(!fileUriArguments.isEmpty()) { AppServices.parseFileUriArguments(fileUriArguments); } @@ -198,15 +197,17 @@ public class MainApp extends Application { private static class SparrowUnique extends Unique4jList { private final List fileUriArguments; - public SparrowUnique(String APP_ID, List fileUriArguments) { - super(APP_ID + "." + Network.get()); + public SparrowUnique(List fileUriArguments) { + super(MainApp.APP_ID + "." + Network.get(), !fileUriArguments.isEmpty()); this.fileUriArguments = fileUriArguments; } @Override protected void receiveMessageList(List messageList) { - AppServices.parseFileUriArguments(messageList); - AppServices.openFileUriArguments(null); + if(messageList != null && !messageList.isEmpty()) { + AppServices.parseFileUriArguments(messageList); + AppServices.openFileUriArguments(null); + } } @Override