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

Unified Diff: views/controls/native/native_view_host.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.h ('k') | views/controls/native/native_view_host_gtk.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.cc
diff --git a/views/controls/native/native_view_host.cc b/views/controls/native/native_view_host.cc
index ce2e4d0266ffd461498c1943e7665773ac366216..1274e5c97494773ed1cd24aef1b3511f096f1a6e 100644
--- a/views/controls/native/native_view_host.cc
+++ b/views/controls/native/native_view_host.cc
@@ -40,6 +40,7 @@ NativeViewHost::~NativeViewHost() {
}
void NativeViewHost::Attach(gfx::NativeView native_view) {
+ DCHECK(native_view);
DCHECK(!native_view_);
native_view_ = native_view;
// If set_focus_view() has not been invoked, this view is the one that should
@@ -50,9 +51,7 @@ void NativeViewHost::Attach(gfx::NativeView native_view) {
}
void NativeViewHost::Detach() {
- DCHECK(native_view_);
- native_wrapper_->NativeViewDetaching();
- native_view_ = NULL;
+ Detach(false);
}
void NativeViewHost::SetPreferredSize(const gfx::Size& size) {
@@ -63,7 +62,7 @@ void NativeViewHost::SetPreferredSize(const gfx::Size& size) {
void NativeViewHost::NativeViewDestroyed() {
// Detach so we can clear our state and notify the native_wrapper_ to release
// ref on the native view.
- Detach();
+ Detach(true);
}
////////////////////////////////////////////////////////////////////////////////
@@ -146,4 +145,13 @@ void NativeViewHost::Focus() {
native_wrapper_->SetFocus();
}
+////////////////////////////////////////////////////////////////////////////////
+// NativeViewHost, private:
+
+void NativeViewHost::Detach(bool destroyed) {
+ DCHECK(native_view_);
+ native_wrapper_->NativeViewDetaching(destroyed);
+ native_view_ = NULL;
+}
+
} // namespace views
« no previous file with comments | « views/controls/native/native_view_host.h ('k') | views/controls/native/native_view_host_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698