dnd: Handle destruction of drag actor during drag

The shell crashes if the drag actor is destroyed during the drag
operation. Cancel the drag gracefully in this case.
https://bugzilla.gnome.org/show_bug.cgi?id=620389
This commit is contained in:
Maxim Ermilov 2010-10-24 05:45:54 +04:00
parent 2fa6f7ba7e
commit 95ac478f87

View File

@ -86,6 +86,9 @@ _Draggable.prototype = {
Lang.bind(this, this._onButtonPress));
this.actor.connect('destroy', Lang.bind(this, function() {
this._actorDestroyed = true;
if (this._dragInProgress)
this._cancelDrag(global.get_current_time());
this.disconnectAll();
}));
this._onEventId = null;
@ -417,6 +420,8 @@ _Draggable.prototype = {
targX,
targY,
event.get_time())) {
if (this._actorDestroyed)
return true;
// If it accepted the drop without taking the actor,
// handle it ourselves.
if (this._dragActor.get_parent() == this._dragActor.get_stage()) {
@ -458,6 +463,12 @@ _Draggable.prototype = {
this._dragInProgress = false;
let [snapBackX, snapBackY] = this._getRestoreLocation();
if (this._actorDestroyed) {
global.unset_cursor();
this.emit('drag-end', eventTime, false);
return;
}
this._animationInProgress = true;
// No target, so snap back
Tweener.addTween(this._dragActor,