From: kiramt Date: Mon, 4 Sep 2017 15:31:00 +0000 (+0100) Subject: JAL-2673 turn off update to running flag from scrollUp/scrollRight X-Git-Tag: Release_2_10_2b1~11^2~3^2~1^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2ca31c294c758a1f7e6c314ff671ddd03f937e60;p=jalview.git JAL-2673 turn off update to running flag from scrollUp/scrollRight --- diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index be4f9e6..57bfa68 100644 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -1451,7 +1451,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { if (scrollThread != null) { - scrollThread.running = false; + scrollThread.threadRunning = false; scrollThread = null; } @@ -1701,7 +1701,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, mouseExited(evt); } - if (scrollThread != null) + if ((scrollThread != null) && (scrollThread.isRunning())) { scrollThread.setEvent(evt); } @@ -1717,9 +1717,9 @@ public class SeqPanel extends Panel implements MouseMotionListener, oldSeq = 0; } - if (scrollThread != null) + if ((scrollThread != null) && (scrollThread.isRunning())) { - scrollThread.running = false; + scrollThread.stopScrolling(); scrollThread = null; } } @@ -1742,9 +1742,9 @@ public class SeqPanel extends Panel implements MouseMotionListener, { if (evt == null) { - if (scrollThread != null) + if ((scrollThread != null) && (scrollThread.isRunning())) { - scrollThread.running = false; + scrollThread.stopScrolling(); scrollThread = null; } mouseDragging = false; @@ -1767,7 +1767,7 @@ public class SeqPanel extends Panel implements MouseMotionListener, { MouseEvent evt; - boolean running = false; + private volatile boolean threadRunning = true; public ScrollThread() { @@ -1781,14 +1781,18 @@ public class SeqPanel extends Panel implements MouseMotionListener, public void stopScrolling() { - running = false; + threadRunning = false; + } + + public boolean isRunning() + { + return threadRunning; } @Override public void run() { - running = true; - while (running) + while (threadRunning) { if (evt != null) @@ -1797,23 +1801,23 @@ public class SeqPanel extends Panel implements MouseMotionListener, if (mouseDragging && evt.getY() < 0 && av.getRanges().getStartSeq() > 0) { - running = av.getRanges().scrollUp(true); + av.getRanges().scrollUp(true); } if (mouseDragging && evt.getY() >= getSize().height && av .getAlignment().getHeight() > av.getRanges().getEndSeq()) { - running = av.getRanges().scrollUp(false); + av.getRanges().scrollUp(false); } if (mouseDragging && evt.getX() < 0) { - running = av.getRanges().scrollRight(false); + av.getRanges().scrollRight(false); } else if (mouseDragging && evt.getX() >= getSize().width) { - running = av.getRanges().scrollRight(true); + av.getRanges().scrollRight(true); } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index cb29c3f..c3aa15f 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1542,7 +1542,7 @@ public class SeqPanel extends JPanel return; } - if (mouseDragging) + if (mouseDragging && scrollThread == null) { scrollThread = new ScrollThread(); }