JAL-1332 regression from 7ce72ca7fadf35a249427ecb836b22abb04ab653 - allow 'null'...
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 27 Aug 2013 14:42:06 +0000 (15:42 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Tue, 27 Aug 2013 14:42:06 +0000 (15:42 +0100)
src/jalview/structure/StructureSelectionManager.java

index 7415712..8d684c1 100644 (file)
@@ -53,13 +53,25 @@ public class StructureSelectionManager
   }
 
   Hashtable mappingData = new Hashtable();
-
+  private static StructureSelectionManager nullProvider = null;
   public static StructureSelectionManager getStructureSelectionManager(
           StructureSelectionManagerProvider context)
   {
-    if (context==null)
-    {
-      throw new Error("Implementation error. Structure selection manager's context is 'null'", new NullPointerException("SSM context is null"));
+    if (context==null) { 
+      if (nullProvider == null)
+      {
+        if (instances != null)
+        {
+          throw new Error(
+                  "Implementation error. Structure selection manager's context is 'null'",
+                  new NullPointerException("SSM context is null"));
+        }
+        else
+        {
+          nullProvider = new StructureSelectionManager();
+        }
+        return nullProvider;
+      }
     }
     if (instances == null)
     {
@@ -68,7 +80,13 @@ public class StructureSelectionManager
     StructureSelectionManager instance = instances.get(context);
     if (instance == null)
     {
-      instances.put(context, instance = new StructureSelectionManager());
+      if (nullProvider!=null)
+      {
+        instance = nullProvider;
+      } else {
+        instance = new StructureSelectionManager();
+      }
+      instances.put(context, instance);
     }
     return instance;
   }