From 7b7275a27e01f6ed3a0e41c7801b926de9f93d4a Mon Sep 17 00:00:00 2001 From: Mark Longair Date: Mon, 26 Jul 2010 18:03:05 +0200 Subject: [PATCH] Fix for a race condition when starting painting It was possible for the last mouseMoved event (with no buttons held down) to update flags after the mousePressed and mouseDragged events (with the left button held down) had set them, which would cause the Painter thread to exit immediately. This can be fixed by updating the flags in mouseMoved() before dispatching the event to the MouseMovedThread for further processing. --- ini/trakem2/display/DisplayCanvas.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ini/trakem2/display/DisplayCanvas.java b/ini/trakem2/display/DisplayCanvas.java index dbbd04df..c685a1ff 100644 --- a/ini/trakem2/display/DisplayCanvas.java +++ b/ini/trakem2/display/DisplayCanvas.java @@ -1359,8 +1359,6 @@ public final class DisplayCanvas extends ImageCanvas implements KeyListener/*, F private void mouseMoved(MouseEvent me) { if (null == me) return; - DisplayCanvas.super.flags = me.getModifiers(); - if (input_disabled || display.getMode().isDragging()) return; xMouse = (int)(me.getX() / magnification) + srcRect.x; @@ -1368,7 +1366,7 @@ public final class DisplayCanvas extends ImageCanvas implements KeyListener/*, F final Displayable active = display.getActive(); // only when no mouse buttons are down - final int flags = me.getModifiers(); // override, the super fails for some reason + final int flags = DisplayCanvas.super.flags; if (0 == (flags & InputEvent.BUTTON1_MASK) /* && 0 == (flags & InputEvent.BUTTON2_MASK) */ // this is the alt key down .. && 0 == (flags & InputEvent.BUTTON3_MASK) @@ -1416,9 +1414,6 @@ public final class DisplayCanvas extends ImageCanvas implements KeyListener/*, F for (Displayable d : al) sb.append(pr.getShortMeaningfulTitle(d)).append(", "); sb.setLength(sb.length()-2); Utils.showStatus(sb.toString(), false); - } else { - // set xMouse, yMouse, and print pixel value - DisplayCanvas.super.mouseMoved(me); } } } @@ -1428,7 +1423,10 @@ public final class DisplayCanvas extends ImageCanvas implements KeyListener/*, F } public void mouseMoved(final MouseEvent me) { + super.flags = me.getModifiers(); mouse_moved.dispatch(me); + if (!me.isShiftDown()) + DisplayCanvas.super.mouseMoved(me); } /** Zoom in using the current mouse position, or the center if the mouse is out. */ -- 2.11.4.GIT