summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 19:21:46 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 19:21:46 +0000
commit1ff45871a02cb6d42535c0f9ec317fd88d876248 (patch)
treee851eef3b7644e323c107cd7847216bebdabc181 /chrome/browser/views
parentb7d05ab3d0cce2d74d24f702641b3f5702584dab (diff)
downloadchromium_src-1ff45871a02cb6d42535c0f9ec317fd88d876248.zip
chromium_src-1ff45871a02cb6d42535c0f9ec317fd88d876248.tar.gz
chromium_src-1ff45871a02cb6d42535c0f9ec317fd88d876248.tar.bz2
Fix a memory leak in the StatusBubble. We were leaking a
WidgetWin for the popup. I observed this in Purify and confirmed in the debugger that the destructor for WidgetWin was never called. Review URL: http://codereview.chromium.org/13672 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/status_bubble.cc25
-rw-r--r--chrome/browser/views/status_bubble.h10
2 files changed, 15 insertions, 20 deletions
diff --git a/chrome/browser/views/status_bubble.cc b/chrome/browser/views/status_bubble.cc
index db19e0c..680d94a 100644
--- a/chrome/browser/views/status_bubble.cc
+++ b/chrome/browser/views/status_bubble.cc
@@ -237,7 +237,7 @@ void StatusBubble::StatusView::StartFade(double start,
opacity_start_ = start;
opacity_end_ = end;
- // This will also reset the currently-occuring animation.
+ // This will also reset the currently-occurring animation.
SetDuration(duration);
Start();
}
@@ -337,7 +337,7 @@ void StatusBubble::StatusView::Paint(ChromeCanvas* canvas) {
// Top Edges - if the bubble is in its bottom position (sticking downwards),
// then we square the top edges. Otherwise, we square the edges based on the
// position of the bubble within the window (the bubble is positioned in the
- // southeast corner in RTL and in the southwest conver in LTR).
+ // southeast corner in RTL and in the southwest corner in LTR).
if (style_ == STYLE_BOTTOM) {
// Top Left corner.
rad[0] = 0;
@@ -454,23 +454,20 @@ StatusBubble::StatusBubble(views::Widget* frame)
}
StatusBubble::~StatusBubble() {
- if (popup_) {
+ if (popup_.get())
popup_->CloseNow();
- }
- popup_ = NULL;
position_ = NULL;
size_ = NULL;
}
void StatusBubble::Init() {
- if (!popup_) {
- popup_ = new views::WidgetWin();
+ if (!popup_.get()) {
+ popup_.reset(new views::WidgetWin());
popup_->set_delete_on_destroy(false);
- if (!view_) {
- view_ = new StatusView(this, popup_);
- }
+ if (!view_)
+ view_ = new StatusView(this, popup_.get());
gfx::Rect rc(0, 0, 0, 0);
@@ -513,7 +510,7 @@ void StatusBubble::SetURL(const GURL& url, const std::wstring& languages) {
return;
}
- // Set Elided Text correspoding to the GURL object.
+ // Set Elided Text corresponding to the GURL object.
RECT parent_rect;
::GetWindowRect(popup_->GetHWND(), &parent_rect);
int text_width = static_cast<int>(parent_rect.right -
@@ -540,9 +537,8 @@ void StatusBubble::ClearURL() {
void StatusBubble::Hide() {
status_text_ = std::wstring();
url_text_ = std::wstring();
- if (view_) {
+ if (view_)
view_->Hide();
- }
}
void StatusBubble::MouseMoved() {
@@ -618,7 +614,7 @@ void StatusBubble::AvoidMouse() {
}
void StatusBubble::Reposition() {
- if (popup_) {
+ if (popup_.get()) {
gfx::Point top_left;
views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
@@ -644,4 +640,3 @@ void StatusBubble::SetBounds(int x, int y, int w, int h) {
size_.SetSize(w, h);
Reposition();
}
-
diff --git a/chrome/browser/views/status_bubble.h b/chrome/browser/views/status_bubble.h
index 834feccc..f54efdc 100644
--- a/chrome/browser/views/status_bubble.h
+++ b/chrome/browser/views/status_bubble.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H__
-#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H__
+#ifndef CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_
+#define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_
#include "base/gfx/rect.h"
#include "chrome/views/widget.h"
@@ -74,14 +74,14 @@ class StatusBubble {
// We use a HWND for the popup so that it may float above any HWNDs in our
// UI (the location bar, for example).
- views::WidgetWin* popup_;
+ scoped_ptr<views::WidgetWin> popup_;
double opacity_;
views::Widget* frame_;
StatusView* view_;
- DISALLOW_EVIL_CONSTRUCTORS(StatusBubble);
+ DISALLOW_COPY_AND_ASSIGN(StatusBubble);
};
-#endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H__
+#endif // CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H_