null pointer when double click event occurs without an existing selection (happens...
[jalview.git] / src / jalview / gui / SeqPanel.java
index a961928..4036204 100755 (executable)
@@ -1425,12 +1425,14 @@ public class SeqPanel extends JPanel implements MouseListener,
 
   public void mouseClicked(MouseEvent evt)
   {
+    SequenceGroup sg=null;
     SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
     if (evt.getClickCount() > 1)
     {
-      if (av.getSelectionGroup().getSize() == 1
-              && av.getSelectionGroup().getEndRes()
-                      - av.getSelectionGroup().getStartRes() < 2)
+      sg = av.getSelectionGroup();
+      if (sg!=null && sg.getSize() == 1
+              && sg.getEndRes()
+                      - sg.getStartRes() < 2)
       {
         av.setSelectionGroup(null);
       }
@@ -1863,16 +1865,15 @@ public class SeqPanel extends JPanel implements MouseListener,
   {
     // TODO: fix this hack - source of messages is align viewport, but SeqPanel
     // handles selection messages...
-    if (av == source)
+    // TODO: extend config options to allow user to control if selections may be shared between viewports.
+    if (av == source || !av.followSelection || (source instanceof AlignViewport && ((AlignViewport)source).getSequenceSetId().equals(av.getSequenceSetId())))
     {
       return;
     }
     // do we want to thread this ? (contention with seqsel and colsel locks, I
     // suspect)
     boolean repaint = false;
-    if (av.followSelection)
-    {
-      if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+    if (av.selectionGroup == null || !av.isSelectionGroupChanged())
       {
         SequenceGroup sgroup = null;
         if (seqsel != null)
@@ -1917,7 +1918,6 @@ public class SeqPanel extends JPanel implements MouseListener,
         }
         repaint |= av.isColSelChanged();
       }
-    }
     if (av.hasHiddenColumns && (av.colSel==null || av.colSel.getHiddenColumns()==null))
     {
       System.err.println("Bad things");