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

Unified Diff: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc

Issue 2474783002: Fix memory leak for extension uninstall dialog. (Closed)
Patch Set: Add test coverage. Created 4 years, 1 month 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
Index: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
index 6aed9daa19761504bf3c996fc6fcc8ded121dbbf..203704deb9f38cf30ee555a49c5d40489fc9678b 100644
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
@@ -44,8 +44,8 @@ class ExtensionUninstallDialogViews
~ExtensionUninstallDialogViews() override;
// Called when the ExtensionUninstallDialogDelegate has been destroyed to make
- // sure we invalidate pointers.
- void DialogDelegateDestroyed() { view_ = NULL; }
+ // sure we invalidate pointers. This object will also be freed.
+ void DialogDelegateDestroyed();
// Forwards the accept and cancels to the delegate.
void DialogAccepted(bool handle_report_abuse);
@@ -119,6 +119,7 @@ ExtensionUninstallDialogViews::ExtensionUninstallDialogViews(
parent_(parent) {
if (parent_)
parent_window_tracker_ = NativeWindowTracker::Create(parent_);
+ LOG(ERROR) << this << " Dialog Created";
}
ExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() {
@@ -127,6 +128,7 @@ ExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() {
view_->DialogDestroyed();
view_->GetWidget()->CloseNow();
}
+ LOG(ERROR) << this << " Dialog Died";
}
void ExtensionUninstallDialogViews::Show() {
@@ -140,6 +142,11 @@ void ExtensionUninstallDialogViews::Show() {
constrained_window::CreateBrowserModalDialogViews(view_, parent_)->Show();
}
+void ExtensionUninstallDialogViews::DialogDelegateDestroyed() {
+ view_ = NULL;
+ OnDialogClosed(CLOSE_ACTION_CANCELED);
Devlin 2016/11/05 06:26:18 It seems like there's a potential that this could
lgcheng 2016/11/10 21:39:51 Thanks for pointing out the potential issue. But a
+}
+
void ExtensionUninstallDialogViews::DialogAccepted(bool report_abuse_checked) {
// The widget gets destroyed when the dialog is accepted.
view_->DialogDestroyed();
@@ -176,6 +183,7 @@ ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
heading_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
heading_->SetAllowCharacterBreak(true);
AddChildView(heading_);
+ LOG(ERROR) << this << " Dialog View Created";
}
ExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() {
@@ -187,6 +195,7 @@ ExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() {
// about to be freed by the Widget framework.
if (dialog_)
dialog_->DialogDelegateDestroyed();
+ LOG(ERROR) << this << " Dialog View Died";
}
views::View* ExtensionUninstallDialogDelegateView::CreateExtraView() {

Powered by Google App Engine
This is Rietveld 408576698