Commit 1f6fc1e2 authored by Alexander Dunaev's avatar Alexander Dunaev Committed by Commit Bot

[ozone] Added a check that DnD client is alive after the operation ends.

During the drag and drop operation, the origin window can be destroyed,
which will result in destruction of its DnD client that was controlling
the operation.  This CL adds a check for that.

Bug: 1014860
Change-Id: I43410be1262d3ffee30b183c3942f1b309404a73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2243131
Auto-Submit: Alexander Dunaev <adunaev@igalia.com>
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779918}
parent b14537df
......@@ -154,10 +154,18 @@ int DesktopDragDropClientOzone::StartDragAndDrop(
CreateDragWidget(root_location, drag_image, drag_context_->offset);
}
// This object is owned by a DesktopNativeWidgetAura that can be destroyed
// during the drag loop, which will also destroy this object. So keep track
// of whether we are still alive after the drag ends.
auto alive = weak_factory_.GetWeakPtr();
drag_handler_->StartDrag(*data.get(), operation, cursor_client->GetCursor(),
this);
run_loop.Run();
if (!alive)
return ui::DragDropTypes::DRAG_NONE;
if (cursor_client)
cursor_client->SetCursor(initial_cursor);
drag_context_.reset();
......@@ -203,17 +211,17 @@ int DesktopDragDropClientOzone::OnDragMotion(const gfx::PointF& point,
int operation) {
last_drag_point_ = point;
drag_operation_ = operation;
int client_operation =
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE;
// If |data_to_drop_| has a valid data, ask |drag_drop_delegate_| about the
// operation that it would accept.
if (data_to_drop_) {
std::unique_ptr<ui::DropTargetEvent> event =
UpdateTargetAndCreateDropEvent(point);
if (drag_drop_delegate_ && event)
client_operation = drag_drop_delegate_->OnDragUpdated(*event);
}
// If |data_to_drop_| doesn't have data, return that we accept everything.
if (!data_to_drop_)
return ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_MOVE;
// Ask the delegate what operation it would accept for the current data.
int client_operation = ui::DragDropTypes::DRAG_NONE;
std::unique_ptr<ui::DropTargetEvent> event =
UpdateTargetAndCreateDropEvent(point);
if (drag_drop_delegate_ && event)
client_operation = drag_drop_delegate_->OnDragUpdated(*event);
return client_operation;
}
......
Markdown is supported
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