| Index: chrome/browser/ui/views/payments/payment_request_dialog_view.cc
|
| diff --git a/chrome/browser/ui/views/payments/payment_request_dialog_view.cc b/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
|
| index d6a122e5ad73950e18d6ad7ab4cffd4a46c5285c..cf9f4b732ab437670505225bc6330caf070a2d6c 100644
|
| --- a/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
|
| +++ b/chrome/browser/ui/views/payments/payment_request_dialog_view.cc
|
| @@ -65,9 +65,12 @@ ui::ModalType PaymentRequestDialogView::GetModalType() const {
|
| }
|
|
|
| bool PaymentRequestDialogView::Cancel() {
|
| - // Called when the widget is about to close. We send a message to the
|
| - // PaymentRequest object to signal user cancellation.
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| + // Called when the widget is about to close. We send a message to the
|
| + // PaymentRequest object to signal user cancellation. Before destroying the
|
| + // PaymentRequest object, we destroy all controllers so that they are not left
|
| + // alive with an invalid PaymentRequest pointer.
|
| + controller_map_.clear();
|
| request_->UserCancelled();
|
| return true;
|
| }
|
| @@ -140,6 +143,7 @@ void PaymentRequestDialogView::ShowDialog() {
|
|
|
| void PaymentRequestDialogView::CloseDialog() {
|
| // This calls PaymentRequestDialogView::Cancel() before closing.
|
| + // ViewHierarchyChanged() also gets called after Cancel().
|
| GetWidget()->Close();
|
| }
|
|
|
|
|