dnd: Skip drag target when its acceptDrop() throws an exception
In the case of bugs in a drag target's acceptDrop() function, it may
throw an exception. In the previous code, this would break out of the
loop entirely and never cancel the drag, so the mouse button release
event would be ignored and you would have to press Esc to get out of the
drag.
In this change, if acceptDrop() throws an exception, we log it and move
on to the next parent target instead.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/777
(cherry picked from commit 055c007ac2
)
This commit is contained in:
parent
246150d8b6
commit
750c5acd30
14
js/ui/dnd.js
14
js/ui/dnd.js
@ -573,11 +573,15 @@ var _Draggable = class _Draggable {
|
|||||||
while (target) {
|
while (target) {
|
||||||
if (target._delegate && target._delegate.acceptDrop) {
|
if (target._delegate && target._delegate.acceptDrop) {
|
||||||
let [r_, targX, targY] = target.transform_stage_point(dropX, dropY);
|
let [r_, targX, targY] = target.transform_stage_point(dropX, dropY);
|
||||||
if (target._delegate.acceptDrop(this.actor._delegate,
|
let accepted = false;
|
||||||
this._dragActor,
|
try {
|
||||||
targX,
|
accepted = target._delegate.acceptDrop(this.actor._delegate,
|
||||||
targY,
|
this._dragActor, targX, targY, event.get_time());
|
||||||
event.get_time())) {
|
} catch (e) {
|
||||||
|
// On error, skip this target
|
||||||
|
logError(e, "Skipping drag target");
|
||||||
|
}
|
||||||
|
if (accepted) {
|
||||||
// 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 && this._dragActor.get_parent() == Main.uiGroup) {
|
if (this._dragActor && this._dragActor.get_parent() == Main.uiGroup) {
|
||||||
|
Loading…
Reference in New Issue
Block a user