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:
parent
2fa6f7ba7e
commit
95ac478f87
11
js/ui/dnd.js
11
js/ui/dnd.js
@ -86,6 +86,9 @@ _Draggable.prototype = {
|
|||||||
Lang.bind(this, this._onButtonPress));
|
Lang.bind(this, this._onButtonPress));
|
||||||
|
|
||||||
this.actor.connect('destroy', Lang.bind(this, function() {
|
this.actor.connect('destroy', Lang.bind(this, function() {
|
||||||
|
this._actorDestroyed = true;
|
||||||
|
if (this._dragInProgress)
|
||||||
|
this._cancelDrag(global.get_current_time());
|
||||||
this.disconnectAll();
|
this.disconnectAll();
|
||||||
}));
|
}));
|
||||||
this._onEventId = null;
|
this._onEventId = null;
|
||||||
@ -417,6 +420,8 @@ _Draggable.prototype = {
|
|||||||
targX,
|
targX,
|
||||||
targY,
|
targY,
|
||||||
event.get_time())) {
|
event.get_time())) {
|
||||||
|
if (this._actorDestroyed)
|
||||||
|
return true;
|
||||||
// If it accepted the drop without taking the actor,
|
// If it accepted the drop without taking the actor,
|
||||||
// handle it ourselves.
|
// handle it ourselves.
|
||||||
if (this._dragActor.get_parent() == this._dragActor.get_stage()) {
|
if (this._dragActor.get_parent() == this._dragActor.get_stage()) {
|
||||||
@ -458,6 +463,12 @@ _Draggable.prototype = {
|
|||||||
this._dragInProgress = false;
|
this._dragInProgress = false;
|
||||||
let [snapBackX, snapBackY] = this._getRestoreLocation();
|
let [snapBackX, snapBackY] = this._getRestoreLocation();
|
||||||
|
|
||||||
|
if (this._actorDestroyed) {
|
||||||
|
global.unset_cursor();
|
||||||
|
this.emit('drag-end', eventTime, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._animationInProgress = true;
|
this._animationInProgress = true;
|
||||||
// No target, so snap back
|
// No target, so snap back
|
||||||
Tweener.addTween(this._dragActor,
|
Tweener.addTween(this._dragActor,
|
||||||
|
Loading…
Reference in New Issue
Block a user