diff --git a/platform-independent/c/core/build.gradle b/platform-independent/c/core/build.gradle index 1b4a617d..05e00537 100644 --- a/platform-independent/c/core/build.gradle +++ b/platform-independent/c/core/build.gradle @@ -14,11 +14,10 @@ artifacts { from 'lib' components.withType( ComponentWithRuntimeFile ) { - if (isOptimized()) { + if (optimized) from runtimeFile, { into standardOperatingSystem( targetPlatform ) + '/' + standardArchitecture( targetPlatform ) } - } } } } @@ -55,27 +54,29 @@ library { from files( new File( Jvm.current().javaHome, 'include' ) ) { first().eachDir { from it } } } - binaries.configureEach { - def system = standardOperatingSystem( targetPlatform ) - + binaries.whenElementFinalized { project.dependencies { - add( linkLibraries.name, - fileTree( "$rootDir/../lib/libsodium/build-${system}~/out/lib" ) ) - } + def system = standardOperatingSystem( targetPlatform ) - archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec.class ).configure { - commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}" - privateHeaders.from "$rootDir/../lib/libsodium/build-${system}~/out/include" - } - clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec.class ).configure { - commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}", 'clean' - } - archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec.class ).configure { - commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}" - privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out/include" - } - clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec.class ).configure { - commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}", 'clean' + // libsodium + archive.dependsOn project.tasks.maybeCreate( "build_libsodium-${system}", Exec ).configure { + commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}" + privateHeaders.from "$rootDir/../lib/libsodium/build-${system}~/out/include" + add( linkLibraries.name, fileTree( "$rootDir/../lib/libsodium/build-${system}~/out/lib" ) ) + } + clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec ).configure { + commandLine 'bash', "$rootDir/../lib/bin/build_libsodium-${system}", 'clean' + } + + // libjson-c + archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec ).configure { + commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}" + privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out/include" + add( linkLibraries.name, fileTree( "$rootDir/../lib/libjson-c/build-${system}~/out/lib" ) ) + } + clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec ).configure { + commandLine 'bash', "$rootDir/../lib/bin/build_libjson-c-${system}", 'clean' + } } } } diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java index da703b2f..23f42e3b 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/GUI.java @@ -47,7 +47,7 @@ public class GUI { public static void main(final String... args) { Thread.setDefaultUncaughtExceptionHandler( - (t, e) -> logger.err( e, "Uncaught: %s", e.getLocalizedMessage() ) ); + (t, e) -> logger.bug( e, "Uncaught: %s", e.getLocalizedMessage() ) ); if (Config.get().checkForUpdates()) checkUpdate(); diff --git a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/SwingExecutorService.java b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/SwingExecutorService.java index b273203c..e4241d0f 100644 --- a/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/SwingExecutorService.java +++ b/platform-independent/java/gui/src/main/java/com/lyndir/masterpassword/gui/SwingExecutorService.java @@ -33,7 +33,7 @@ public class SwingExecutorService extends AbstractExecutorService { synchronized (pendingCommands) { if (pendingCommands.isEmpty()) - terminated.offer( true ); + terminated.add( true ); } } @@ -85,7 +85,7 @@ public class SwingExecutorService extends AbstractExecutorService { pendingCommands.remove( command ); if (shutdown && pendingCommands.isEmpty()) - terminated.offer( true ); + terminated.add( true ); } } } diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/Changeable.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/Changeable.java index 5efdf5a9..b21b2610 100644 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/Changeable.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/Changeable.java @@ -11,11 +11,12 @@ public class Changeable { private static final ExecutorService changeExecutor = Executors.newSingleThreadExecutor(); - private boolean changed; - private Grouping grouping = Grouping.APPLY; + private final Object mutex = new Object(); + private Grouping grouping = Grouping.APPLY; + private boolean changed; void setChanged() { - synchronized (changeExecutor) { + synchronized (mutex) { if (changed) return; @@ -23,36 +24,36 @@ public class Changeable { changed = true; if (grouping != Grouping.APPLY) return; - - changeExecutor.submit( () -> { - synchronized (changeExecutor) { - if (grouping != Grouping.APPLY) - return; - changed = false; - } - - onChanged(); - } ); } + + changeExecutor.submit( () -> { + synchronized (changeExecutor) { + if (grouping != Grouping.APPLY) + return; + changed = false; + } + + onChanged(); + } ); } protected void onChanged() { } public void beginChanges() { - synchronized (changeExecutor) { + synchronized (mutex) { grouping = Grouping.BATCH; } } public void ignoreChanges() { - synchronized (changeExecutor) { + synchronized (mutex) { grouping = Grouping.IGNORE; } } public boolean endChanges() { - synchronized (changeExecutor) { + synchronized (mutex) { grouping = Grouping.APPLY; if (changed) { diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileSite.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileSite.java index fa118371..cac0e91b 100644 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileSite.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileSite.java @@ -159,7 +159,7 @@ public class MPFileSite extends MPBasicSite { @Override public int compareTo(final MPSite o) { - int comparison = (o instanceof MPFileSite)? -getLastUsed().compareTo( ((MPFileSite) o).getLastUsed() ): 0; + int comparison = (o instanceof MPFileSite)? ((MPFileSite) o).getLastUsed().compareTo( getLastUsed() ): 0; if (comparison != 0) return comparison; diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileUser.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileUser.java index 158768ce..9b40aefc 100755 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileUser.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPFileUser.java @@ -171,7 +171,7 @@ public class MPFileUser extends MPBasicUser { @Override public int compareTo(final MPUser o) { - int comparison = (o instanceof MPFileUser)? -getLastUsed().compareTo( ((MPFileUser) o).getLastUsed() ): 0; + int comparison = (o instanceof MPFileUser)? ((MPFileUser) o).getLastUsed().compareTo( getLastUsed() ): 0; if (comparison != 0) return comparison; diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java index 8c9adf52..194a750b 100644 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONAnyObject.java @@ -19,6 +19,7 @@ package com.lyndir.masterpassword.model.impl; import com.fasterxml.jackson.annotation.*; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.*; @@ -41,6 +42,7 @@ class MPJSONAnyObject { @Override @SuppressWarnings({ "ChainOfInstanceofChecks", "Contract" }) + @SuppressFBWarnings({"EQ_UNUSUAL","EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", "HE_EQUALS_USE_HASHCODE"}) public boolean equals(final Object obj) { if (obj instanceof Collection) return ((Collection) obj).isEmpty(); diff --git a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java index 7e5959aa..ecc7a207 100644 --- a/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java +++ b/platform-independent/java/model/src/main/java/com/lyndir/masterpassword/model/impl/MPJSONFile.java @@ -82,8 +82,7 @@ public class MPJSONFile extends MPJSONAnyObject { user.default_type = modelUser.getDefaultType(); // Section "sites" - if (sites == null) - sites = new LinkedHashMap<>(); + sites = new LinkedHashMap<>(); for (final MPFileSite modelSite : modelUser.getSites()) { String content = null, loginContent = null;