[gnome-shell/gbsneto/icon-grid-dnd-fixes: 11/11] appDisplay: Protect against source icon destruction




commit 5b6b0c8dcd471c22919b56eb5a86c34ad2540d37
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Sep 24 18:57:56 2020 -0300

    appDisplay: Protect against source icon destruction
    
    When dragging icons out of a folder dialog, there is a very peculiar
    combination of steps that may break GNOME Shell:
    
     1. Open an app folder dialog
     2. Start dragging an icon to outside the grid
     3. Wait until the popdown animation starts
     4. Before it finishes, drop the icon
     5. See the warnings / crash
    
    That's caused by the source icon being destroyed after the delayed
    move timer starts, and before it finishes.
    
    Protect against the source icon being destroyed before the delayed
    move timeout triggers by connecting to the 'destroy' signal and
    removing the timeout on the callback.

 js/ui/appDisplay.js | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index a1558ff39f..99f209fa32 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -359,11 +359,17 @@ var BaseAppView = GObject.registerClass({
             this._removeDelayedMove();
             this._targetDropPosition = { page, position };
 
+            const id = source.connect('destroy', () => {
+                source.disconnect(id);
+                this._removeDelayedMove();
+            });
+
             this._delayedMoveId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
                 DELAYED_MOVE_TIMEOUT, () => {
                     this._moveItem(source, page, position);
                     this._targetDropPosition = null;
                     this._delayedMoveId = 0;
+                    source.disconnect(id);
                     return GLib.SOURCE_REMOVE;
                 });
         }


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