diff --git a/js/ui/dnd.js b/js/ui/dnd.js index a38607c24..ec1ba1d41 100644 --- a/js/ui/dnd.js +++ b/js/ui/dnd.js @@ -396,10 +396,15 @@ var _Draggable = new Lang.Class({ return true; }, + _pickTargetActor() { + return this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, + this._dragX, this._dragY); + }, + _updateDragHover() { this._updateHoverId = 0; - let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, - this._dragX, this._dragY); + let target = this._pickTargetActor(); + let dragEvent = { x: this._dragX, y: this._dragY, @@ -407,6 +412,18 @@ var _Draggable = new Lang.Class({ source: this.actor._delegate, targetActor: target }; + + let targetActorDestroyHandlerId; + let handleTargetActorDestroyClosure; + handleTargetActorDestroyClosure = () => { + target = this._pickTargetActor(); + dragEvent.targetActor = target; + targetActorDestroyHandlerId = + target.connect('destroy', handleTargetActorDestroyClosure); + }; + targetActorDestroyHandlerId = + target.connect('destroy', handleTargetActorDestroyClosure); + for (let i = 0; i < dragMonitors.length; i++) { let motionFunc = dragMonitors[i].dragMotion; if (motionFunc) { @@ -417,6 +434,7 @@ var _Draggable = new Lang.Class({ } } } + dragEvent.targetActor.disconnect(targetActorDestroyHandlerId); while (target) { if (target._delegate && target._delegate.handleDragOver) {