From 8ce30ccd5a3fa10fc29c8acbfdba58e2d00a5d8b Mon Sep 17 00:00:00 2001 From: andrzej Date: Fri, 25 Feb 2005 02:21:12 +0000 Subject: [PATCH] Added some extra checks for lingering icons. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1599 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/swing/dnd/DnDManager.java | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/swing/dnd/DnDManager.java b/projects/samskivert/src/java/com/samskivert/swing/dnd/DnDManager.java index e94f2c16..bdcd4950 100644 --- a/projects/samskivert/src/java/com/samskivert/swing/dnd/DnDManager.java +++ b/projects/samskivert/src/java/com/samskivert/swing/dnd/DnDManager.java @@ -25,6 +25,8 @@ import javax.swing.Timer; import javax.swing.event.AncestorEvent; import javax.swing.event.MouseInputAdapter; +import com.samskivert.Log; + import com.samskivert.swing.event.AncestorAdapter; /** @@ -194,12 +196,34 @@ public class DnDManager { Cursor c = comp.getCursor(); if (c != _curCursor) { + assertComponentCursorCleared(); _lastComp = comp; _oldCursor = comp.isCursorSet() ? c : null; comp.setCursor(_curCursor); } } + /** + * Makes sure the component cursor is cleared. If it isn't, generates a + * warning message and clears it. + */ + protected void assertComponentCursorCleared () + { + if (_lastComp != null) { + Log.warning("In DnDManager, last component cursor not cleared."); + clearComponentCursor(); + } + } + + protected void assertTopCursorCleared () + { + if (_topComp != null) { + Log.warning("In DnDManager, top component cursor not cleared."); + _topComp.setCursor(_topCursor); + _topComp = null; + } + } + /** * Clear out the component-level cursor. */ @@ -210,13 +234,21 @@ public class DnDManager _lastComp = null; } } - + /** * Are we currently involved in a drag? */ protected boolean isDragging () { - return (_source != null); + boolean dragging = (_source != null); + + if (!dragging) { + // make sure there's no component/top cursor + assertComponentCursorCleared(); + assertTopCursorCleared(); + } + + return dragging; } /**