summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 20:25:17 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-29 20:25:17 +0000
commit95e3a7d9f296355a32a167451ee40f7c773a3eb0 (patch)
treefa44bb0b6d63706a3f273afbe66e4504d749244c /views
parent7b59cdcf03334495ff196483e18e29650110a9dc (diff)
downloadchromium_src-95e3a7d9f296355a32a167451ee40f7c773a3eb0.zip
chromium_src-95e3a7d9f296355a32a167451ee40f7c773a3eb0.tar.gz
chromium_src-95e3a7d9f296355a32a167451ee40f7c773a3eb0.tar.bz2
Fix a memory leak... the wrapped platform helper isn't a view, so it's not auto-deleted... use a scoped_ptr instead!
BUG=none TEST=none Review URL: http://codereview.chromium.org/118025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/native/native_view_host.cc9
-rw-r--r--views/controls/native/native_view_host.h2
-rw-r--r--views/controls/native/native_view_host_wrapper.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/views/controls/native/native_view_host.cc b/views/controls/native/native_view_host.cc
index 18ba870..ad1ed75 100644
--- a/views/controls/native/native_view_host.cc
+++ b/views/controls/native/native_view_host.cc
@@ -19,7 +19,6 @@ const char NativeViewHost::kViewClassName[] = "views/NativeViewHost";
NativeViewHost::NativeViewHost()
: native_view_(NULL),
- native_wrapper_(NULL),
fast_resize_(false),
focus_view_(NULL) {
// The native widget is placed relative to the root. As such, we need to
@@ -62,7 +61,7 @@ gfx::Size NativeViewHost::GetPreferredSize() {
}
void NativeViewHost::Layout() {
- if (!native_view_ || !native_wrapper_)
+ if (!native_view_ || !native_wrapper_.get())
return;
// Since widgets know nothing about the View hierarchy (they are direct
@@ -75,7 +74,7 @@ void NativeViewHost::Layout() {
gfx::Rect vis_bounds = GetVisibleBounds();
bool visible = !vis_bounds.IsEmpty();
- if (visible && !fast_resize_ && native_wrapper_) {
+ if (visible && !fast_resize_) {
if (vis_bounds.size() != size()) {
// Only a portion of the Widget is really visible.
int x = vis_bounds.x();
@@ -118,8 +117,8 @@ void NativeViewHost::VisibleBoundsInRootChanged() {
void NativeViewHost::ViewHierarchyChanged(bool is_add, View* parent,
View* child) {
if (is_add && GetWidget()) {
- if (!native_wrapper_)
- native_wrapper_ = NativeViewHostWrapper::CreateWrapper(this);
+ if (!native_wrapper_.get())
+ native_wrapper_.reset(NativeViewHostWrapper::CreateWrapper(this));
native_wrapper_->AddedToWidget();
} else if (!is_add) {
native_wrapper_->RemovedFromWidget();
diff --git a/views/controls/native/native_view_host.h b/views/controls/native/native_view_host.h
index c9dce23..d34ccf9 100644
--- a/views/controls/native/native_view_host.h
+++ b/views/controls/native/native_view_host.h
@@ -84,7 +84,7 @@ class NativeViewHost : public View {
// A platform-specific wrapper that does the OS-level manipulation of the
// attached gfx::NativeView.
- NativeViewHostWrapper* native_wrapper_;
+ scoped_ptr<NativeViewHostWrapper> native_wrapper_;
// The preferred size of this View
gfx::Size preferred_size_;
diff --git a/views/controls/native/native_view_host_wrapper.h b/views/controls/native/native_view_host_wrapper.h
index 4b14403..948f0ce 100644
--- a/views/controls/native/native_view_host_wrapper.h
+++ b/views/controls/native/native_view_host_wrapper.h
@@ -14,6 +14,8 @@ class NativeViewHost;
// native view when attached, detached, moved and sized.
class NativeViewHostWrapper {
public:
+ virtual ~NativeViewHostWrapper() {}
+
// Called when a gfx::NativeView has been attached to the associated
// NativeViewHost, allowing the wrapper to perform platform-specific
// initialization.