Verified Commit 3197c789 authored by ivan tkachenko's avatar ivan tkachenko
Browse files

effects/{private,desktopgrid,overview}: Guard against function execution when...

effects/{private,desktopgrid,overview}: Guard against function execution when component is being destroyed

Accept drop events correctly and use returned value (action) of
Drag.drop() to guard against the situation where the delegate is about
to be destroyed.

This does not fix any bugs per se, except suppressing a warning about
undefined targetScreen being printed to a console on every window dropped
onto a different virtual desktop.
parent c3f9aab3
Pipeline #215652 failed with stage
in 13 minutes and 55 seconds
......@@ -30,15 +30,21 @@ FocusScope {
onEntered: {
drag.accepted = true;
}
onDropped: {
onDropped: drop => {
drop.accepted = true;
if (drag.source instanceof DesktopView) {
// dragging a desktop as a whole
if (desktopView === drag.source) {
if (drag.source === desktopView) {
drop.action = Qt.IgnoreAction;
return;
}
effect.swapDesktops(drag.source.desktop.x11DesktopNumber, desktop.x11DesktopNumber);
} else {
// dragging a KWin::Window
if (drag.source.desktop === desktopView.desktop.x11DesktopNumber) {
drop.action = Qt.IgnoreAction;
return;
}
drag.source.desktop = desktopView.desktop.x11DesktopNumber;
}
}
......@@ -96,6 +102,8 @@ FocusScope {
y = 0;
}
Drag.active: dragHandler.active
Drag.proposedAction: Qt.MoveAction
Drag.supportedActions: Qt.MoveAction
Drag.source: desktopView
Drag.hotSpot: Qt.point(width * 0.5, height * 0.5)
width: parent.width
......
......@@ -199,10 +199,13 @@ Item {
id: dropArea
anchors.fill: parent
onEntered: {
drag.accepted = true;
}
onDropped: {
onDropped: drop => {
drop.accepted = true;
// dragging a KWin::Window
if (drag.source.desktop === delegate.desktop.x11DesktopNumber) {
drop.action = Qt.IgnoreAction;
return;
}
drag.source.desktop = delegate.desktop.x11DesktopNumber;
}
}
......
......@@ -92,6 +92,8 @@ Item {
state: thumb.activeDragHandler.active ? "drag" : "normal"
Drag.active: thumb.activeDragHandler.active
Drag.proposedAction: Qt.MoveAction
Drag.supportedActions: Qt.MoveAction
Drag.source: thumb.client
Drag.hotSpot: Qt.point(
thumb.activeDragHandler.centroid.pressPosition.x * thumb.targetScale,
......@@ -324,7 +326,12 @@ Item {
if (active) {
thumb.activeDragHandler = this;
} else {
thumbSource.Drag.drop();
var action = thumbSource.Drag.drop();
if (action === Qt.MoveAction) {
// this whole component is in the process of being destroyed due to drop onto
// another virtual desktop (not another screen).
return;
}
var globalPos = targetScreen.mapToGlobal(centroid.scenePosition);
effect.checkItemDroppedOutOfScreen(globalPos, thumbSource);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment