diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 23:29:59 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-19 23:29:59 +0000 |
commit | fd81a10dc199076671eab98cc5722522004a84d5 (patch) | |
tree | fa675dce91f57cd9c8bbe7d87e0fbcef71258cae /chrome | |
parent | faeaa946158d500de841248de8a0caab3d597309 (diff) | |
download | chromium_src-fd81a10dc199076671eab98cc5722522004a84d5.zip chromium_src-fd81a10dc199076671eab98cc5722522004a84d5.tar.gz chromium_src-fd81a10dc199076671eab98cc5722522004a84d5.tar.bz2 |
Fix memory leak in nine_box.
Review URL: http://codereview.chromium.org/112040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gtk/nine_box.cc | 12 | ||||
-rw-r--r-- | chrome/browser/gtk/nine_box.h | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/gtk/nine_box.cc b/chrome/browser/gtk/nine_box.cc index 1f30a0c..9fb6a52 100644 --- a/chrome/browser/gtk/nine_box.cc +++ b/chrome/browser/gtk/nine_box.cc @@ -35,7 +35,8 @@ GdkPixbuf* GetPixbufNamed(ThemeProvider* theme_provider, int name) { } // namespace NineBox::NineBox(int top_left, int top, int top_right, int left, int center, - int right, int bottom_left, int bottom, int bottom_right) { + int right, int bottom_left, int bottom, int bottom_right) + : ninebox_owns_images_(false) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); images_[0] = top_left ? rb.GetPixbufNamed(top_left) : NULL; images_[1] = top ? rb.GetPixbufNamed(top) : NULL; @@ -50,7 +51,8 @@ NineBox::NineBox(int top_left, int top, int top_right, int left, int center, NineBox::NineBox(ThemeProvider* theme_provider, int top_left, int top, int top_right, int left, int center, - int right, int bottom_left, int bottom, int bottom_right) { + int right, int bottom_left, int bottom, int bottom_right) + : ninebox_owns_images_(true) { images_[0] = top_left ? GetPixbufNamed(theme_provider, top_left) : NULL; images_[1] = top ? @@ -72,6 +74,12 @@ NineBox::NineBox(ThemeProvider* theme_provider, } NineBox::~NineBox() { + if (ninebox_owns_images_) { + for (size_t i = 0; i < 9; i++) { + if (images_[i]) + g_object_unref(images_[i]); + } + } } void NineBox::RenderToWidget(GtkWidget* dst) const { diff --git a/chrome/browser/gtk/nine_box.h b/chrome/browser/gtk/nine_box.h index 9cd0e81..c59e322 100644 --- a/chrome/browser/gtk/nine_box.h +++ b/chrome/browser/gtk/nine_box.h @@ -53,8 +53,9 @@ class NineBox { void ContourWidget(GtkWidget* widget) const; private: - GdkPixbuf* images_[9]; + // Determine if we own and need to free images_. + bool ninebox_owns_images_; }; #endif // CHROME_BROWSER_GTK_NINE_BOX_H_ |