Changes between Initial Version and Version 1 of Ticket #25012
- Timestamp:
- 2026-11-08T07:10:57+01:00 (2 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25012 – Description
initial v1 20 20 Normally, the two fields "mode" and "pWays" must always be consistent (i.e. mode == Mode.DRAGGING implies pWays != null). But if JOSM loses focus when dragging: 21 21 22 1. When the window loses focus during a drag, the mouseReleased event is never delivered, so 23 mouseReleased() is not called. The action therefore stays in the "dragging" state forever: 24 mode == Mode.DRAGGING, mouseIsDown == true, mouseHasBeenDragged == true, and 25 pWays still points to the preview object. 22 1. When the window loses focus during a drag, the mouseReleased event is never delivered, so mouseReleased() is not called. The action therefore stays in the "dragging" state forever: mode == Mode.DRAGGING, mouseIsDown == true, mouseHasBeenDragged == true, and pWays still points to the preview object. 26 23 27 24 2. On the next mousePressed(MouseEvent), the existing pWays is discarded: … … 30 27 pWays = null; 31 28 } 32 but mode and mouseIsDown/mouseHasBeenDragged are not reset at this point. Normally this is 33 masked because mouseReleased() resets them, but in this scenario mouseReleased() has already 34 been lost. 29 but mode and mouseIsDown/mouseHasBeenDragged are not reset at this point. Normally this is masked because mouseReleased() resets them, but in this scenario mouseReleased() has already been lost. 35 30 36 3. The subsequent mouseDragged(MouseEvent) passes the checks at the top of the method 37 (mouseIsDown is still true, and the INITIAL_MOVE_DELAY of 200 ms has already elapsed), but the 38 block "if (mode == Mode.NORMAL) { ... initParallelWays(...) }" is skipped because mode is still 39 DRAGGING. Execution falls through to: 31 3. The subsequent mouseDragged(MouseEvent) passes the checks at the top of the method (mouseIsDown is still true, and the INITIAL_MOVE_DELAY of 200 ms has already elapsed), but the block "if (mode == Mode.NORMAL) { ... initParallelWays(...) }" is skipped because mode is still DRAGGING. Execution falls through to: 40 32 41 33 ParallelWays.ClosestPoint closest = pWays.closestPoint(enp); // pWays == null … … 48 40 at org.openstreetmap.josm.actions.mapmode.ParallelWayAction.mouseDragged(ParallelWayAction.java:407) 49 41 50 So the combination "mode == DRAGGING while pWays == null" is what triggers the crash. The same 51 stale mouseHasBeenDragged flag is also why a plain click after returning to the window takes the 52 "end of drag" branch of mouseReleased() and clears the source ways. 42 So the combination "mode == DRAGGING while pWays == null" is what triggers the crash. The same stale mouseHasBeenDragged flag is also why a plain click after returning to the window takes the "end of drag" branch of mouseReleased() and clears the source ways. 53 43 54 The screenshot tool is just one easy way to lose the mouseReleased event; alt-tabbing, a popup 55 window stealing the button release, or a modal dialog appearing mid-drag should have the same 56 effect. 44 The screenshot tool is just one easy way to lose the mouseReleased event; alt-tabbing, a popup window stealing the button release, or a modal dialog appearing mid-drag should have the same effect. 57 45 58 46 It might be helpful to reset the whole drag state in mousePressed():


