JAL-4026 ignore StructureSelectionManager events if no viewer is available to act...
[jalview.git] / src / jalview / structures / models / AAStructureBindingModel.java
index 44d698d..906cb59 100644 (file)
@@ -20,8 +20,6 @@
  */
 package jalview.structures.models;
 
-import java.util.Locale;
-
 import java.awt.Color;
 import java.io.File;
 import java.io.IOException;
@@ -31,6 +29,7 @@ import java.util.BitSet;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.swing.SwingUtilities;
@@ -1280,6 +1279,12 @@ public abstract class AAStructureBindingModel
   @Override
   public void updateColours(Object source)
   {
+    if (getViewer() == null)
+    {
+      // can happen if a viewer was not instantiated or cleaned up and is still
+      // registered - mostly during tests
+      return;
+    }
     AlignmentViewPanel ap = (AlignmentViewPanel) source;
     // ignore events from panels not used to colour this view
     if (!getViewer().isUsedForColourBy(ap))