[gnome-shell] dnd: Don't try to restore to parent location if parent got destroyed



commit 79acae41769ab46a3d11851c64e14779a3035bd2
Author: Sebastian Keller <skeller gnome org>
Date:   Sat Apr 17 19:53:43 2021 +0200

    dnd: Don't try to restore to parent location if parent got destroyed
    
    The original parent of a dragged actor might have been destroyed after
    the drag has been started. When the drag is canceled and _dragOrigParent
    is set, the code is trying to get the current position and size of it
    when restoring. With a destroyed parent this however would result in a
    crash.
    
    This could happen for example when starting a drag on a window preview
    while the overview is hiding and then releasing it once the transition
    is done.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4024
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1817>

 js/ui/dnd.js | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 0af1e7ecc7..03b56915f1 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -407,6 +407,10 @@ var _Draggable = class _Draggable {
             Main.uiGroup.add_child(this._dragActor);
             Main.uiGroup.set_child_above_sibling(this._dragActor, null);
             Shell.util_set_hidden_from_pick(this._dragActor, true);
+
+            this._dragOrigParentDestroyId = this._dragOrigParent.connect('destroy', () => {
+                this._dragOrigParent = null;
+            });
         }
 
         this._dragActorDestroyId = this._dragActor.connect('destroy', () => {
@@ -776,6 +780,11 @@ var _Draggable = class _Draggable {
             this._dragActor = null;
         }
 
+        if (this._dragOrigParent) {
+            this._dragOrigParent.disconnect(this._dragOrigParentDestroyId);
+            this._dragOrigParent = null;
+        }
+
         this._dragState = DragState.INIT;
         currentDraggable = null;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]