JAL-3453 Some tests require different Desktop constructor
authorhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 7 Oct 2019 05:57:11 +0000 (07:57 +0200)
committerhansonr <hansonr@STO24954W.ad.stolaf.edu>
Mon, 7 Oct 2019 05:57:11 +0000 (07:57 +0200)
even better, simpler idea:

static boolean instanceOnly

  public static Desktop getInstanceOnly()
  {
    instanceOnly = true;
    return getInstance();
  }

src/jalview/gui/Desktop.java

index 91e1948..1899bd3 100644 (file)
@@ -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;
     }