Commit db7fbe90 authored by Sahel Sharify's avatar Sahel Sharify Committed by Commit Bot

[Payments] Do not show error message in dialog view during close.

Attempting to show an error message in payment request dialog view after
PaymentRequestDialogView::OnDialogClosed() call causes a crash. This is
because PaymentRequestDialogView::ShowErrorMessage() creates an error
view and adds it to the view stack[1] while the stack view gets destroyed
upon PaymentRequestDialogView::OnDialogClosed() call.

[1]https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/ui/views/payments/payment_request_dialog_view.cc;l=123

This cl fixes the crash by early-returning from
PaymentRequestDialogView::ShowErrorMessage() when the dialog is getting
closed (i.e after PaymentRequestDialogView::OnDialogClosed() has been
called.) The screencast of the fix is already attached to the bug.

Bug: 1114556
Change-Id: I10d9478a83913a167e52ed558a6a09cf18fcd6e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359562Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Sahel Sharify <sahel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798860}
parent 298d5b35
......@@ -120,6 +120,9 @@ void PaymentRequestDialogView::CloseDialog() {
}
void PaymentRequestDialogView::ShowErrorMessage() {
if (being_closed_)
return;
view_stack_->Push(CreateViewAndInstallController(
std::make_unique<ErrorMessageViewController>(
request_->spec(), request_->state(), this),
......
......@@ -226,8 +226,8 @@ class PaymentRequestDialogView : public views::DialogDelegateView,
// May be null.
ObserverForTest* observer_for_testing_;
// Used when the dialog is being closed to avoid re-entrancy into the
// controller_map_.
// Used when the dialog is being closed to avoid re-entrance into the
// controller_map_ or view_stack_.
bool being_closed_ = false;
// The number of initialization tasks that are not yet initialized.
......
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