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

Unified Diff: views/controls/native/native_view_host_gtk.cc

Issue 510004: Fix crash/leak issue in native_view_host_gtk.cc. (Closed)
Patch Set: " Created 11 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 | « views/controls/native/native_view_host_gtk.h ('k') | views/controls/native/native_view_host_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/native/native_view_host_gtk.cc
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index 581f08d692afdb0f1ab8e80a5cdd3ac9f95ed621..ed4f5bac89d5f872b893cdd2e878b1402319a628 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -63,7 +63,7 @@ void NativeViewHostGtk::NativeViewAttached() {
// TODO(port): figure out focus.
}
-void NativeViewHostGtk::NativeViewDetaching() {
+void NativeViewHostGtk::NativeViewDetaching(bool destroyed) {
DCHECK(host_->native_view());
g_signal_handler_disconnect(G_OBJECT(host_->native_view()),
@@ -76,6 +76,14 @@ void NativeViewHostGtk::NativeViewDetaching() {
installed_clip_ = false;
+ if (fixed_ && !destroyed) {
+ DCHECK_NE(static_cast<gfx::NativeView>(NULL),
+ gtk_widget_get_parent(host_->native_view()));
+ gtk_container_remove(GTK_CONTAINER(fixed_), host_->native_view());
+ DCHECK_EQ(
+ 0U, g_list_length(gtk_container_get_children(GTK_CONTAINER(fixed_))));
+ }
+
g_object_unref(G_OBJECT(host_->native_view()));
}
@@ -200,7 +208,9 @@ void NativeViewHostGtk::DestroyFixed() {
// widget from the moment it is attached.
gtk_container_remove(GTK_CONTAINER(fixed_), host_->native_view());
}
-
+ // fixed_ should not have any children this point.
+ DCHECK_EQ(0U,
+ g_list_length(gtk_container_get_children(GTK_CONTAINER(fixed_))));
gtk_widget_destroy(fixed_);
fixed_ = NULL;
}
« no previous file with comments | « views/controls/native/native_view_host_gtk.h ('k') | views/controls/native/native_view_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698