Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Unified Diff: ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc

Issue 819793002: Reland: Fix crash when the source browser window is deleted during a drag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc
diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc
index d135a8977a06f88374a331a3990b12e4922d0f54..49c20e9095ddc84cb818dedecaff2cc945d4e53d 100644
--- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc
+++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_win.cc
@@ -18,11 +18,14 @@ DesktopDragDropClientWin::DesktopDragDropClientWin(
aura::Window* root_window,
HWND window)
: drag_drop_in_progress_(false),
- drag_operation_(0) {
+ drag_operation_(0),
+ weak_factory_(this) {
drop_target_ = new DesktopDropTargetWin(root_window, window);
}
DesktopDragDropClientWin::~DesktopDragDropClientWin() {
+ if (drag_drop_in_progress_)
+ DragCancel();
}
int DesktopDragDropClientWin::StartDragAndDrop(
@@ -35,7 +38,11 @@ int DesktopDragDropClientWin::StartDragAndDrop(
drag_drop_in_progress_ = true;
drag_operation_ = operation;
+ base::WeakPtr<DesktopDragDropClientWin> alive(weak_factory_.GetWeakPtr());
+
drag_source_ = new ui::DragSourceWin;
+ scoped_refptr<ui::DragSourceWin> drag_source_copy = drag_source_;
+
DWORD effect;
// Use task stopwatch to exclude the drag-drop time current task, if any.
@@ -46,7 +53,8 @@ int DesktopDragDropClientWin::StartDragAndDrop(
ui::DragDropTypes::DragOperationToDropEffect(operation), &effect);
stopwatch.Stop();
- drag_drop_in_progress_ = false;
+ if (alive)
+ drag_drop_in_progress_ = false;
if (result != DRAGDROP_S_DROP)
effect = DROPEFFECT_NONE;
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h ('k') | ui/views/widget/widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698