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

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

Issue 795303002: Fix crash when the source browser window is deleted during a drag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@drag_drop_end_move_loop2
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 f471b3254bf1825823c32f48e1c72e1105b0d757..fc581e201d781c71844f10973ed056e015a68bad 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
@@ -17,11 +17,13 @@ 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() {
+ DragCancel();
}
int DesktopDragDropClientWin::StartDragAndDrop(
@@ -34,13 +36,18 @@ 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;
HRESULT result = DoDragDrop(
ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_.get(),
ui::DragDropTypes::DragOperationToDropEffect(operation), &effect);
- drag_drop_in_progress_ = false;
+ if (alive)
+ drag_drop_in_progress_ = false;
if (result != DRAGDROP_S_DROP)
effect = DROPEFFECT_NONE;
@@ -57,7 +64,8 @@ void DesktopDragDropClientWin::Drop(aura::Window* target,
}
void DesktopDragDropClientWin::DragCancel() {
- drag_source_->CancelDrag();
+ if (drag_drop_in_progress_)
sky 2014/12/15 20:44:13 Should this be a DCHECK?
pkotwicz 2014/12/15 21:54:11 In patch set #2, I moved the check to the destruct
+ drag_source_->CancelDrag();
drag_operation_ = 0;
}
« 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