From 1e9f882c52f5b95d198c42973e7b2b1ce2b420df Mon Sep 17 00:00:00 2001 From: hansonr Date: Mon, 7 Oct 2019 07:57:11 +0200 Subject: [PATCH] JAL-3453 Some tests require different Desktop constructor even better, simpler idea: static boolean instanceOnly public static Desktop getInstanceOnly() { instanceOnly = true; return getInstance(); } --- src/jalview/gui/Desktop.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 91e1948..1899bd3 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -237,7 +237,7 @@ public class Desktop extends GDesktop * It is set by invoking Desktop.getInstanceOnly(). * */ - boolean instanceOnly; + static boolean instanceOnly; class MyDesktopManager implements DesktopManager { @@ -388,17 +388,14 @@ public class Desktop extends GDesktop */ public static Desktop getInstanceOnly() { - Desktop d = (Desktop) ApplicationSingletonProvider - .getInstance(Desktop.class); - d.instanceOnly = true; - return d; + instanceOnly = true; + return getInstance(); } /** * Private constructor enforces singleton pattern. It is called by reflection * from ApplicationSingletonProvider.getInstance(). */ - @SuppressWarnings("unused") private Desktop() { Cache.initLogger(); @@ -929,7 +926,7 @@ public class Desktop extends GDesktop // A HEADLESS STATE WHEN NO DESKTOP EXISTS. MUST RETURN // IF JALVIEW IS RUNNING HEADLESS OR IN INSTANCE-ONLY (testNG) MODE // /////////////////////////////////////////////// - if (Jalview.isHeadlessMode() || Desktop.getInstance().instanceOnly) + if (Jalview.isHeadlessMode() || Desktop.instanceOnly) { return; } -- 1.7.10.2