Skip to content
Snippets Groups Projects
Commit 95e3a7d9 authored by ben@chromium.org's avatar ben@chromium.org
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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_;
......
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment