Commit 95e3a7d9 authored by ben@chromium.org's avatar ben@chromium.org

Fix a memory leak... the wrapped platform helper isn't a view, so it's not...

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
parent 7b59cdcf
...@@ -19,7 +19,6 @@ const char NativeViewHost::kViewClassName[] = "views/NativeViewHost"; ...@@ -19,7 +19,6 @@ const char NativeViewHost::kViewClassName[] = "views/NativeViewHost";
NativeViewHost::NativeViewHost() NativeViewHost::NativeViewHost()
: native_view_(NULL), : native_view_(NULL),
native_wrapper_(NULL),
fast_resize_(false), fast_resize_(false),
focus_view_(NULL) { focus_view_(NULL) {
// The native widget is placed relative to the root. As such, we need to // The native widget is placed relative to the root. As such, we need to
...@@ -62,7 +61,7 @@ gfx::Size NativeViewHost::GetPreferredSize() { ...@@ -62,7 +61,7 @@ gfx::Size NativeViewHost::GetPreferredSize() {
} }
void NativeViewHost::Layout() { void NativeViewHost::Layout() {
if (!native_view_ || !native_wrapper_) if (!native_view_ || !native_wrapper_.get())
return; return;
// Since widgets know nothing about the View hierarchy (they are direct // Since widgets know nothing about the View hierarchy (they are direct
...@@ -75,7 +74,7 @@ void NativeViewHost::Layout() { ...@@ -75,7 +74,7 @@ void NativeViewHost::Layout() {
gfx::Rect vis_bounds = GetVisibleBounds(); gfx::Rect vis_bounds = GetVisibleBounds();
bool visible = !vis_bounds.IsEmpty(); bool visible = !vis_bounds.IsEmpty();
if (visible && !fast_resize_ && native_wrapper_) { if (visible && !fast_resize_) {
if (vis_bounds.size() != size()) { if (vis_bounds.size() != size()) {
// Only a portion of the Widget is really visible. // Only a portion of the Widget is really visible.
int x = vis_bounds.x(); int x = vis_bounds.x();
...@@ -118,8 +117,8 @@ void NativeViewHost::VisibleBoundsInRootChanged() { ...@@ -118,8 +117,8 @@ void NativeViewHost::VisibleBoundsInRootChanged() {
void NativeViewHost::ViewHierarchyChanged(bool is_add, View* parent, void NativeViewHost::ViewHierarchyChanged(bool is_add, View* parent,
View* child) { View* child) {
if (is_add && GetWidget()) { if (is_add && GetWidget()) {
if (!native_wrapper_) if (!native_wrapper_.get())
native_wrapper_ = NativeViewHostWrapper::CreateWrapper(this); native_wrapper_.reset(NativeViewHostWrapper::CreateWrapper(this));
native_wrapper_->AddedToWidget(); native_wrapper_->AddedToWidget();
} else if (!is_add) { } else if (!is_add) {
native_wrapper_->RemovedFromWidget(); native_wrapper_->RemovedFromWidget();
......
...@@ -84,7 +84,7 @@ class NativeViewHost : public View { ...@@ -84,7 +84,7 @@ class NativeViewHost : public View {
// A platform-specific wrapper that does the OS-level manipulation of the // A platform-specific wrapper that does the OS-level manipulation of the
// attached gfx::NativeView. // attached gfx::NativeView.
NativeViewHostWrapper* native_wrapper_; scoped_ptr<NativeViewHostWrapper> native_wrapper_;
// The preferred size of this View // The preferred size of this View
gfx::Size preferred_size_; gfx::Size preferred_size_;
......
...@@ -14,6 +14,8 @@ class NativeViewHost; ...@@ -14,6 +14,8 @@ class NativeViewHost;
// native view when attached, detached, moved and sized. // native view when attached, detached, moved and sized.
class NativeViewHostWrapper { class NativeViewHostWrapper {
public: public:
virtual ~NativeViewHostWrapper() {}
// Called when a gfx::NativeView has been attached to the associated // Called when a gfx::NativeView has been attached to the associated
// NativeViewHost, allowing the wrapper to perform platform-specific // NativeViewHost, allowing the wrapper to perform platform-specific
// initialization. // initialization.
......
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