summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-27 01:43:25 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-27 01:43:25 +0000
commit550c2e55ca73daff47dbcfffd1789c121064f093 (patch)
treeae47ea346a7acbd961d50ee68ff47e842cfda085 /chrome
parentf1d62975aceef9f3b165f15cfb91c30fe4a66778 (diff)
downloadchromium_src-550c2e55ca73daff47dbcfffd1789c121064f093.zip
chromium_src-550c2e55ca73daff47dbcfffd1789c121064f093.tar.gz
chromium_src-550c2e55ca73daff47dbcfffd1789c121064f093.tar.bz2
We're leaking almost all the theme bitmaps. Properly delete images
when we create them. We have to copy images that come from ResourceBundle because ResourceBundle owns them. Valgrind still sees more leaks in this area, but I need to investigate some more and these are the biggies. Review URL: http://codereview.chromium.org/149112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_theme_provider.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/chrome/browser/browser_theme_provider.cc b/chrome/browser/browser_theme_provider.cc
index e88d019..c5aeed9 100644
--- a/chrome/browser/browser_theme_provider.cc
+++ b/chrome/browser/browser_theme_provider.cc
@@ -166,7 +166,7 @@ SkBitmap* BrowserThemeProvider::GetBitmapNamed(int id) {
// If we still don't have an image, load it from resourcebundle.
if (!result.get())
- result.reset(rb_.GetBitmapNamed(id));
+ result.reset(new SkBitmap(*rb_.GetBitmapNamed(id)));
if (result.get()) {
// If the requested image is part of the toolbar button set, and we have
@@ -566,7 +566,7 @@ void BrowserThemeProvider::GenerateFrameImages() {
std::map<const int, int>::iterator iter = frame_tints_.begin();
while (iter != frame_tints_.end()) {
int id = iter->first;
- SkBitmap* frame;
+ scoped_ptr<SkBitmap> frame;
// If there's no frame image provided for the specified id, then load
// the default provided frame. If that's not provided, skip this whole
// thing and just use the default images.
@@ -575,18 +575,18 @@ void BrowserThemeProvider::GenerateFrameImages() {
IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
if (images_.find(id) != images_.end()) {
- frame = LoadThemeBitmap(id);
+ frame.reset(LoadThemeBitmap(id));
} else if (base_id != id && images_.find(base_id) != images_.end()) {
- frame = LoadThemeBitmap(base_id);
+ frame.reset(LoadThemeBitmap(base_id));
} else {
// If the theme doesn't specify an image, then apply the tint to
// the default frame. Note that the default theme provides default
// bitmaps for all frame types, so this isn't strictly necessary
// in the case where no tint is provided either.
- frame = rb_.GetBitmapNamed(IDR_THEME_FRAME);
+ frame.reset(new SkBitmap(*rb_.GetBitmapNamed(IDR_THEME_FRAME)));
}
- if (frame) {
+ if (frame.get()) {
SkBitmap* tinted = new SkBitmap(TintBitmap(*frame, iter->second));
image_cache_[id] = tinted;
}
@@ -738,6 +738,11 @@ void BrowserThemeProvider::FreeImages() {
delete *i;
}
generated_images_.clear();
+
+ for (ImageCache::iterator i = image_cache_.begin();
+ i != image_cache_.end(); i++) {
+ delete i->second;
+ }
image_cache_.clear();
}