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

Side by Side Diff: ui/views/cocoa/drag_drop_client_mac.mm

Issue 2572473004: Fix Crash in DragDropClientMac::Drop()
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/views/cocoa/drag_drop_client_mac.h" 5 #import "ui/views/cocoa/drag_drop_client_mac.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ui/base/dragdrop/os_exchange_data_provider_mac.h" 10 #import "ui/base/dragdrop/os_exchange_data_provider_mac.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 [sender draggingSourceOperationMask]); 141 [sender draggingSourceOperationMask]);
142 } 142 }
143 143
144 drag_operation = drop_helper_.OnDragOver( 144 drag_operation = drop_helper_.OnDragOver(
145 *[data_source_ data], LocationInView([sender draggingLocation]), 145 *[data_source_ data], LocationInView([sender draggingLocation]),
146 operation_); 146 operation_);
147 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation); 147 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation);
148 } 148 }
149 149
150 NSDragOperation DragDropClientMac::Drop(id<NSDraggingInfo> sender) { 150 NSDragOperation DragDropClientMac::Drop(id<NSDraggingInfo> sender) {
151 int drag_operation = drop_helper_.OnDrop( 151 // OnDrop can optionally delete |this|, so clear data members first.
152 *[data_source_ data], LocationInView([sender draggingLocation]), 152 base::scoped_nsobject<CocoaDragDropDataProvider> data_source = data_source_;
153 operation_); 153 int operation = operation_;
154 data_source_.reset(); 154 data_source_.reset();
155 operation_ = 0; 155 operation_ = 0;
156
157 int drag_operation = drop_helper_.OnDrop(
158 *[data_source data], LocationInView([sender draggingLocation]),
159 operation);
156 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation); 160 return ui::DragDropTypes::DragOperationToNSDragOperation(drag_operation);
157 } 161 }
158 162
159 void DragDropClientMac::EndDrag() { 163 void DragDropClientMac::EndDrag() {
160 data_source_.reset(); 164 data_source_.reset();
161 165
162 // Allow a test to invoke EndDrag() without spinning the nested run loop. 166 // Allow a test to invoke EndDrag() without spinning the nested run loop.
163 if (!quit_closure_.is_null()) { 167 if (!quit_closure_.is_null()) {
164 quit_closure_.Run(); 168 quit_closure_.Run();
165 quit_closure_.Reset(); 169 quit_closure_.Reset();
166 } 170 }
167 } 171 }
168 172
169 gfx::Point DragDropClientMac::LocationInView(NSPoint point) const { 173 gfx::Point DragDropClientMac::LocationInView(NSPoint point) const {
170 return gfx::Point(point.x, NSHeight([bridge_->ns_window() frame]) - point.y); 174 return gfx::Point(point.x, NSHeight([bridge_->ns_window() frame]) - point.y);
171 } 175 }
172 176
173 } // namespace views 177 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698