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. Use a single field, called '_delayedMoveData', to store all data related to delayed moves. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1447
This commit is contained in:
parent
aaff88a6bb
commit
d04daf6a1c
@ -199,8 +199,7 @@ var BaseAppView = GObject.registerClass({
|
|||||||
// Drag n' Drop
|
// Drag n' Drop
|
||||||
this._lastOvershoot = -1;
|
this._lastOvershoot = -1;
|
||||||
this._lastOvershootTimeoutId = 0;
|
this._lastOvershootTimeoutId = 0;
|
||||||
this._delayedMoveId = 0;
|
this._delayedMoveData = null;
|
||||||
this._targetDropPosition = null;
|
|
||||||
|
|
||||||
this._dragBeginId = 0;
|
this._dragBeginId = 0;
|
||||||
this._dragEndId = 0;
|
this._dragEndId = 0;
|
||||||
@ -355,29 +354,40 @@ var BaseAppView = GObject.registerClass({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._targetDropPosition ||
|
if (!this._delayedMoveData ||
|
||||||
this._targetDropPosition.page !== page ||
|
this._delayedMoveData.page !== page ||
|
||||||
this._targetDropPosition.position !== position) {
|
this._delayedMoveData.position !== position) {
|
||||||
// Update the item with a small delay
|
// Update the item with a small delay
|
||||||
this._removeDelayedMove();
|
this._removeDelayedMove();
|
||||||
this._targetDropPosition = { page, position };
|
this._delayedMoveData = {
|
||||||
|
page,
|
||||||
this._delayedMoveId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
position,
|
||||||
DELAYED_MOVE_TIMEOUT, () => {
|
source,
|
||||||
this._moveItem(source, page, position);
|
destroyId: source.connect('destroy', () => this._removeDelayedMove()),
|
||||||
this._targetDropPosition = null;
|
timeoutId: GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
||||||
this._delayedMoveId = 0;
|
DELAYED_MOVE_TIMEOUT, () => {
|
||||||
return GLib.SOURCE_REMOVE;
|
this._moveItem(source, page, position);
|
||||||
});
|
this._delayedMoveData.timeoutId = 0;
|
||||||
|
this._removeDelayedMove();
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
}),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeDelayedMove() {
|
_removeDelayedMove() {
|
||||||
if (this._delayedMoveId > 0) {
|
if (!this._delayedMoveData)
|
||||||
GLib.source_remove(this._delayedMoveId);
|
return;
|
||||||
this._delayedMoveId = 0;
|
|
||||||
}
|
const { source, destroyId, timeoutId } = this._delayedMoveData;
|
||||||
this._targetDropPosition = null;
|
|
||||||
|
if (timeoutId > 0)
|
||||||
|
GLib.source_remove(timeoutId);
|
||||||
|
|
||||||
|
if (destroyId > 0)
|
||||||
|
source.disconnect(destroyId);
|
||||||
|
|
||||||
|
this._delayedMoveData = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
_resetOvershoot() {
|
_resetOvershoot() {
|
||||||
@ -495,8 +505,8 @@ var BaseAppView = GObject.registerClass({
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Dropped before the icon was moved
|
// Dropped before the icon was moved
|
||||||
if (this._targetDropPosition) {
|
if (this._delayedMoveData) {
|
||||||
const { page, position } = this._targetDropPosition;
|
const { page, position } = this._delayedMoveData;
|
||||||
|
|
||||||
this._moveItem(source, page, position);
|
this._moveItem(source, page, position);
|
||||||
this._removeDelayedMove();
|
this._removeDelayedMove();
|
||||||
|
Loading…
Reference in New Issue
Block a user